langchainrb 0.6.11 → 0.6.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -7
- data/lib/langchain/agent/base.rb +1 -0
- data/lib/langchain/agent/{react_agent/react_agent.rb → react_agent.rb} +12 -11
- data/lib/langchain/ai_message.rb +9 -0
- data/lib/langchain/conversation.rb +11 -11
- data/lib/langchain/conversation_memory.rb +3 -7
- data/lib/langchain/human_message.rb +9 -0
- data/lib/langchain/llm/cohere.rb +2 -1
- data/lib/langchain/llm/google_palm.rb +15 -10
- data/lib/langchain/llm/llama_cpp.rb +5 -5
- data/lib/langchain/llm/openai.rb +24 -25
- data/lib/langchain/llm/replicate.rb +2 -1
- data/lib/langchain/message.rb +35 -0
- data/lib/langchain/output_parsers/base.rb +5 -4
- data/lib/langchain/output_parsers/{fix.rb → output_fixing_parser.rb} +3 -1
- data/lib/langchain/prompt/loading.rb +73 -67
- data/lib/langchain/prompt.rb +5 -0
- data/lib/langchain/system_message.rb +9 -0
- data/lib/langchain/tool/base.rb +14 -14
- data/lib/langchain/vectorsearch/pgvector.rb +7 -5
- data/lib/langchain/version.rb +1 -1
- data/lib/langchain.rb +19 -97
- metadata +37 -38
- data/.env.example +0 -21
- data/.rspec +0 -3
- data/.rubocop.yml +0 -11
- data/.tool-versions +0 -1
- data/Gemfile +0 -14
- data/Gemfile.lock +0 -360
- data/Rakefile +0 -17
- data/examples/conversation_with_openai.rb +0 -52
- data/examples/create_and_manage_few_shot_prompt_templates.rb +0 -36
- data/examples/create_and_manage_prompt_templates.rb +0 -25
- data/examples/create_and_manage_prompt_templates_using_structured_output_parser.rb +0 -116
- data/examples/llama_cpp.rb +0 -24
- data/examples/open_ai_function_calls.rb +0 -41
- data/examples/open_ai_qdrant_function_calls.rb +0 -39
- data/examples/pdf_store_and_query_with_chroma.rb +0 -40
- data/examples/store_and_query_with_pinecone.rb +0 -46
- data/examples/store_and_query_with_qdrant.rb +0 -37
- data/examples/store_and_query_with_weaviate.rb +0 -32
- data/lefthook.yml +0 -5
- data/sig/langchain.rbs +0 -4
- /data/lib/langchain/agent/{sql_query_agent/sql_query_agent.rb → sql_query_agent.rb} +0 -0
- /data/lib/langchain/output_parsers/{structured.rb → structured_output_parser.rb} +0 -0
@@ -11,82 +11,88 @@ module Langchain::Prompt
|
|
11
11
|
"few_shot" => ->(config) { load_few_shot_prompt(config) }
|
12
12
|
}
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
#
|
18
|
-
# @param file_path [String, Pathname] The path of the file to read the configuration data from.
|
19
|
-
#
|
20
|
-
# @return [Object] The loaded prompt loaded.
|
21
|
-
#
|
22
|
-
# @raise [ArgumentError] If the file type of the specified file path is not supported.
|
23
|
-
#
|
24
|
-
def load_from_path(file_path:)
|
25
|
-
file_path = file_path.is_a?(String) ? Pathname.new(file_path) : file_path
|
26
|
-
|
27
|
-
case file_path.extname
|
28
|
-
when ".json"
|
29
|
-
config = JSON.parse(File.read(file_path))
|
30
|
-
when ".yaml", ".yml"
|
31
|
-
config = YAML.safe_load(File.read(file_path))
|
32
|
-
else
|
33
|
-
raise ArgumentError, "Got unsupported file type #{file_path.extname}"
|
34
|
-
end
|
35
|
-
|
36
|
-
load_from_config(config)
|
14
|
+
module Loading
|
15
|
+
def self.included(base)
|
16
|
+
base.extend ClassMethods
|
37
17
|
end
|
38
18
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
19
|
+
module ClassMethods
|
20
|
+
#
|
21
|
+
# Load prompt from file.
|
22
|
+
#
|
23
|
+
# @param file_path [String, Pathname] The path of the file to read the configuration data from.
|
24
|
+
#
|
25
|
+
# @return [Object] The loaded prompt loaded.
|
26
|
+
#
|
27
|
+
# @raise [ArgumentError] If the file type of the specified file path is not supported.
|
28
|
+
#
|
29
|
+
def load_from_path(file_path:)
|
30
|
+
file_path = file_path.is_a?(String) ? Pathname.new(file_path) : file_path
|
50
31
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
prefix, suffix, example_prompt, examples, input_variables = config.values_at("prefix", "suffix", "example_prompt", "examples", "input_variables")
|
60
|
-
example_prompt = load_prompt(example_prompt)
|
61
|
-
FewShotPromptTemplate.new(prefix: prefix, suffix: suffix, example_prompt: example_prompt, examples: examples, input_variables: input_variables)
|
62
|
-
end
|
32
|
+
case file_path.extname
|
33
|
+
when ".json"
|
34
|
+
config = JSON.parse(File.read(file_path))
|
35
|
+
when ".yaml", ".yml"
|
36
|
+
config = YAML.safe_load(File.read(file_path))
|
37
|
+
else
|
38
|
+
raise ArgumentError, "Got unsupported file type #{file_path.extname}"
|
39
|
+
end
|
63
40
|
|
64
|
-
|
41
|
+
load_from_config(config)
|
42
|
+
end
|
65
43
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
# If `_type` key is not present in the configuration hash, add it with a default value of `prompt`
|
77
|
-
unless config.key?("_type")
|
78
|
-
Langchain.logger.warn "No `_type` key found, defaulting to `prompt`"
|
79
|
-
config["_type"] = "prompt"
|
44
|
+
#
|
45
|
+
# Loads a prompt template with the given configuration.
|
46
|
+
#
|
47
|
+
# @param config [Hash] A hash containing the configuration for the prompt.
|
48
|
+
#
|
49
|
+
# @return [PromptTemplate] The loaded prompt loaded.
|
50
|
+
#
|
51
|
+
def load_prompt(config)
|
52
|
+
template, input_variables = config.values_at("template", "input_variables")
|
53
|
+
PromptTemplate.new(template: template, input_variables: input_variables)
|
80
54
|
end
|
81
55
|
|
82
|
-
#
|
83
|
-
|
84
|
-
|
56
|
+
#
|
57
|
+
# Loads a prompt template with the given configuration.
|
58
|
+
#
|
59
|
+
# @param config [Hash] A hash containing the configuration for the prompt.
|
60
|
+
#
|
61
|
+
# @return [FewShotPromptTemplate] The loaded prompt loaded.
|
62
|
+
#
|
63
|
+
def load_few_shot_prompt(config)
|
64
|
+
prefix, suffix, example_prompt, examples, input_variables = config.values_at("prefix", "suffix", "example_prompt", "examples", "input_variables")
|
65
|
+
example_prompt = load_prompt(example_prompt)
|
66
|
+
FewShotPromptTemplate.new(prefix: prefix, suffix: suffix, example_prompt: example_prompt, examples: examples, input_variables: input_variables)
|
85
67
|
end
|
86
68
|
|
87
|
-
|
88
|
-
|
89
|
-
|
69
|
+
private
|
70
|
+
|
71
|
+
#
|
72
|
+
# Loads the prompt from the given configuration hash
|
73
|
+
#
|
74
|
+
# @param config [Hash] the configuration hash to load from
|
75
|
+
#
|
76
|
+
# @return [Object] the loaded prompt
|
77
|
+
#
|
78
|
+
# @raise [ArgumentError] if the prompt type specified in the config is not supported
|
79
|
+
#
|
80
|
+
def load_from_config(config)
|
81
|
+
# If `_type` key is not present in the configuration hash, add it with a default value of `prompt`
|
82
|
+
unless config.key?("_type")
|
83
|
+
Langchain.logger.warn "No `_type` key found, defaulting to `prompt`"
|
84
|
+
config["_type"] = "prompt"
|
85
|
+
end
|
86
|
+
|
87
|
+
# If the prompt type specified in the configuration hash is not supported, raise an exception
|
88
|
+
unless TYPE_TO_LOADER.key?(config["_type"])
|
89
|
+
raise ArgumentError, "Loading #{config["_type"]} prompt not supported"
|
90
|
+
end
|
91
|
+
|
92
|
+
# Load the prompt using the corresponding loader function from the `TYPE_TO_LOADER` hash
|
93
|
+
prompt_loader = TYPE_TO_LOADER[config["_type"]]
|
94
|
+
prompt_loader.call(config)
|
95
|
+
end
|
90
96
|
end
|
91
97
|
end
|
92
98
|
end
|
data/lib/langchain/tool/base.rb
CHANGED
@@ -7,16 +7,18 @@ module Langchain::Tool
|
|
7
7
|
#
|
8
8
|
# == Available Tools
|
9
9
|
#
|
10
|
-
# - {Langchain::Tool::Calculator}:
|
11
|
-
# - {Langchain::Tool::
|
10
|
+
# - {Langchain::Tool::Calculator}: calculate the result of a math expression
|
11
|
+
# - {Langchain::Tool::Database}: executes SQL queries
|
12
12
|
# - {Langchain::Tool::GoogleSearch}: search on Google (via SerpAPI)
|
13
|
+
# - {Langchain::Tool::RubyCodeInterpreter}: runs ruby code
|
14
|
+
# - {Langchain::Tool::Weather}: gets current weather data
|
13
15
|
# - {Langchain::Tool::Wikipedia}: search on Wikipedia
|
14
16
|
#
|
15
17
|
# == Usage
|
16
18
|
#
|
17
19
|
# 1. Pick the tools you'd like to pass to an Agent and install the gems listed under **Gem Requirements**
|
18
20
|
#
|
19
|
-
# #
|
21
|
+
# # For example to use the Calculator, GoogleSearch, and Wikipedia:
|
20
22
|
# gem install eqn
|
21
23
|
# gem install google_search_results
|
22
24
|
# gem install wikipedia-client
|
@@ -28,16 +30,14 @@ module Langchain::Tool
|
|
28
30
|
# 3. Pass the tools when Agent is instantiated.
|
29
31
|
#
|
30
32
|
# agent = Langchain::Agent::ReActAgent.new(
|
31
|
-
# llm: :
|
32
|
-
#
|
33
|
-
#
|
33
|
+
# llm: Langchain::LLM::OpenAI.new(api_key: "YOUR_API_KEY"), # or other like Cohere, Hugging Face, Google Palm or Replicate
|
34
|
+
# tools: [
|
35
|
+
# Langchain::Tool::GoogleSearch.new(api_key: "YOUR_API_KEY"),
|
36
|
+
# Langchain::Tool::Calculator.new,
|
37
|
+
# Langchain::Tool::Wikipedia.new
|
38
|
+
# ]
|
34
39
|
# )
|
35
40
|
#
|
36
|
-
# 4. Confirm that the Agent is using the Tools you passed in:
|
37
|
-
#
|
38
|
-
# agent.tools
|
39
|
-
# # => ["google_search", "calculator", "wikipedia"]
|
40
|
-
#
|
41
41
|
# == Adding Tools
|
42
42
|
#
|
43
43
|
# 1. Create a new file in lib/langchain/tool/your_tool_name.rb
|
@@ -53,7 +53,7 @@ module Langchain::Tool
|
|
53
53
|
#
|
54
54
|
# @return [String] tool name
|
55
55
|
#
|
56
|
-
def
|
56
|
+
def name
|
57
57
|
self.class.const_get(:NAME)
|
58
58
|
end
|
59
59
|
|
@@ -68,7 +68,7 @@ module Langchain::Tool
|
|
68
68
|
#
|
69
69
|
# @return [String] tool description
|
70
70
|
#
|
71
|
-
def
|
71
|
+
def description
|
72
72
|
self.class.const_get(:DESCRIPTION)
|
73
73
|
end
|
74
74
|
|
@@ -109,7 +109,7 @@ module Langchain::Tool
|
|
109
109
|
#
|
110
110
|
def self.validate_tools!(tools:)
|
111
111
|
# Check if the tool count is equal to unique tool count
|
112
|
-
if tools.count != tools.map(&:
|
112
|
+
if tools.count != tools.map(&:name).uniq.count
|
113
113
|
raise ArgumentError, "Either tools are not unique or are conflicting with each other"
|
114
114
|
end
|
115
115
|
end
|
@@ -8,7 +8,7 @@ module Langchain::Vectorsearch
|
|
8
8
|
# Gem requirements: gem "pgvector", "~> 0.2"
|
9
9
|
#
|
10
10
|
# Usage:
|
11
|
-
# pgvector = Langchain::Vectorsearch::Pgvector.new(url:, index_name:, llm:,
|
11
|
+
# pgvector = Langchain::Vectorsearch::Pgvector.new(url:, index_name:, llm:, namespace: nil)
|
12
12
|
#
|
13
13
|
|
14
14
|
# The operators supported by the PostgreSQL vector search adapter
|
@@ -90,20 +90,22 @@ module Langchain::Vectorsearch
|
|
90
90
|
end
|
91
91
|
|
92
92
|
# Create default schema
|
93
|
-
# @return [PG::Result] The response from the database
|
94
93
|
def create_default_schema
|
95
94
|
db.run "CREATE EXTENSION IF NOT EXISTS vector"
|
96
|
-
|
95
|
+
namespace_column = @namespace_column
|
97
96
|
vector_dimension = default_dimension
|
98
97
|
db.create_table? table_name.to_sym do
|
99
98
|
primary_key :id
|
100
99
|
text :content
|
101
100
|
column :vectors, "vector(#{vector_dimension})"
|
102
|
-
text
|
101
|
+
text namespace_column.to_sym, default: nil
|
103
102
|
end
|
104
103
|
end
|
105
104
|
|
106
|
-
#
|
105
|
+
# Destroy default schema
|
106
|
+
def destroy_default_schema
|
107
|
+
db.drop_table? table_name.to_sym
|
108
|
+
end
|
107
109
|
|
108
110
|
# Search for similar texts in the index
|
109
111
|
# @param query [String] The text to search for
|
data/lib/langchain/version.rb
CHANGED
data/lib/langchain.rb
CHANGED
@@ -3,8 +3,25 @@
|
|
3
3
|
require "logger"
|
4
4
|
require "pathname"
|
5
5
|
require "colorize"
|
6
|
-
|
7
|
-
|
6
|
+
require "zeitwerk"
|
7
|
+
loader = Zeitwerk::Loader.for_gem
|
8
|
+
loader.ignore("#{__dir__}/langchainrb.rb")
|
9
|
+
loader.inflector.inflect(
|
10
|
+
"ai_message" => "AIMessage",
|
11
|
+
"ai21" => "AI21",
|
12
|
+
"ai21_validator" => "AI21Validator",
|
13
|
+
"csv" => "CSV",
|
14
|
+
"html" => "HTML",
|
15
|
+
"json" => "JSON",
|
16
|
+
"jsonl" => "JSONL",
|
17
|
+
"llm" => "LLM",
|
18
|
+
"openai" => "OpenAI",
|
19
|
+
"openai_validator" => "OpenAIValidator",
|
20
|
+
"pdf" => "PDF",
|
21
|
+
"react_agent" => "ReActAgent",
|
22
|
+
"sql_query_agent" => "SQLQueryAgent"
|
23
|
+
)
|
24
|
+
loader.setup
|
8
25
|
|
9
26
|
# Langchain.rb a is library for building LLM-backed Ruby applications. It is an abstraction layer that sits on top of the emerging AI-related tools that makes it easy for developers to consume and string those services together.
|
10
27
|
#
|
@@ -48,13 +65,6 @@ require_relative "./langchain/version"
|
|
48
65
|
#
|
49
66
|
# Langchain.logger.level = :info
|
50
67
|
module Langchain
|
51
|
-
autoload :Loader, "langchain/loader"
|
52
|
-
autoload :Data, "langchain/data"
|
53
|
-
autoload :Conversation, "langchain/conversation"
|
54
|
-
autoload :ConversationMemory, "langchain/conversation_memory"
|
55
|
-
autoload :DependencyHelper, "langchain/dependency_helper"
|
56
|
-
autoload :ContextualLogger, "langchain/contextual_logger"
|
57
|
-
|
58
68
|
class << self
|
59
69
|
# @return [ContextualLogger]
|
60
70
|
attr_reader :logger
|
@@ -73,95 +83,7 @@ module Langchain
|
|
73
83
|
|
74
84
|
@root = Pathname.new(__dir__)
|
75
85
|
|
76
|
-
module Agent
|
77
|
-
autoload :Base, "langchain/agent/base"
|
78
|
-
autoload :ReActAgent, "langchain/agent/react_agent/react_agent.rb"
|
79
|
-
autoload :SQLQueryAgent, "langchain/agent/sql_query_agent/sql_query_agent.rb"
|
80
|
-
end
|
81
|
-
|
82
|
-
module Chunker
|
83
|
-
autoload :Base, "langchain/chunker/base"
|
84
|
-
autoload :Text, "langchain/chunker/text"
|
85
|
-
autoload :RecursiveText, "langchain/chunker/recursive_text"
|
86
|
-
end
|
87
|
-
|
88
|
-
module Tool
|
89
|
-
autoload :Base, "langchain/tool/base"
|
90
|
-
autoload :Calculator, "langchain/tool/calculator"
|
91
|
-
autoload :RubyCodeInterpreter, "langchain/tool/ruby_code_interpreter"
|
92
|
-
autoload :GoogleSearch, "langchain/tool/google_search"
|
93
|
-
autoload :Weather, "langchain/tool/weather"
|
94
|
-
autoload :Wikipedia, "langchain/tool/wikipedia"
|
95
|
-
autoload :Database, "langchain/tool/database"
|
96
|
-
end
|
97
|
-
|
98
|
-
module Processors
|
99
|
-
autoload :Base, "langchain/processors/base"
|
100
|
-
autoload :CSV, "langchain/processors/csv"
|
101
|
-
autoload :Docx, "langchain/processors/docx"
|
102
|
-
autoload :HTML, "langchain/processors/html"
|
103
|
-
autoload :JSON, "langchain/processors/json"
|
104
|
-
autoload :JSONL, "langchain/processors/jsonl"
|
105
|
-
autoload :PDF, "langchain/processors/pdf"
|
106
|
-
autoload :Text, "langchain/processors/text"
|
107
|
-
autoload :Xlsx, "langchain/processors/xlsx"
|
108
|
-
end
|
109
|
-
|
110
|
-
module Utils
|
111
|
-
module TokenLength
|
112
|
-
autoload :BaseValidator, "langchain/utils/token_length/base_validator"
|
113
|
-
autoload :AI21Validator, "langchain/utils/token_length/ai21_validator"
|
114
|
-
autoload :CohereValidator, "langchain/utils/token_length/cohere_validator"
|
115
|
-
autoload :GooglePalmValidator, "langchain/utils/token_length/google_palm_validator"
|
116
|
-
autoload :OpenAIValidator, "langchain/utils/token_length/openai_validator"
|
117
|
-
autoload :TokenLimitExceeded, "langchain/utils/token_length/token_limit_exceeded"
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
module Vectorsearch
|
122
|
-
autoload :Base, "langchain/vectorsearch/base"
|
123
|
-
autoload :Chroma, "langchain/vectorsearch/chroma"
|
124
|
-
autoload :Hnswlib, "langchain/vectorsearch/hnswlib"
|
125
|
-
autoload :Milvus, "langchain/vectorsearch/milvus"
|
126
|
-
autoload :Pinecone, "langchain/vectorsearch/pinecone"
|
127
|
-
autoload :Pgvector, "langchain/vectorsearch/pgvector"
|
128
|
-
autoload :Qdrant, "langchain/vectorsearch/qdrant"
|
129
|
-
autoload :Weaviate, "langchain/vectorsearch/weaviate"
|
130
|
-
end
|
131
|
-
|
132
|
-
module LLM
|
133
|
-
autoload :AI21, "langchain/llm/ai21"
|
134
|
-
autoload :Anthropic, "langchain/llm/anthropic"
|
135
|
-
autoload :Base, "langchain/llm/base"
|
136
|
-
autoload :Cohere, "langchain/llm/cohere"
|
137
|
-
autoload :GooglePalm, "langchain/llm/google_palm"
|
138
|
-
autoload :HuggingFace, "langchain/llm/hugging_face"
|
139
|
-
autoload :LlamaCpp, "langchain/llm/llama_cpp"
|
140
|
-
autoload :OpenAI, "langchain/llm/openai"
|
141
|
-
autoload :Replicate, "langchain/llm/replicate"
|
142
|
-
end
|
143
|
-
|
144
|
-
module Prompt
|
145
|
-
require_relative "langchain/prompt/loading"
|
146
|
-
|
147
|
-
autoload :Base, "langchain/prompt/base"
|
148
|
-
autoload :PromptTemplate, "langchain/prompt/prompt_template"
|
149
|
-
autoload :FewShotPromptTemplate, "langchain/prompt/few_shot_prompt_template"
|
150
|
-
end
|
151
|
-
|
152
|
-
module ActiveRecord
|
153
|
-
autoload :Hooks, "langchain/active_record/hooks"
|
154
|
-
end
|
155
|
-
|
156
|
-
module OutputParsers
|
157
|
-
autoload :Base, "langchain/output_parsers/base"
|
158
|
-
autoload :StructuredOutputParser, "langchain/output_parsers/structured"
|
159
|
-
autoload :OutputFixingParser, "langchain/output_parsers/fix"
|
160
|
-
end
|
161
|
-
|
162
86
|
module Errors
|
163
87
|
class BaseError < StandardError; end
|
164
88
|
end
|
165
89
|
end
|
166
|
-
|
167
|
-
require "langchain/railtie" if defined?(Rails)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: langchainrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Bondarev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: baran
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 4.0.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: zeitwerk
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.6.11
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.6.11
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: dotenv-rails
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,30 +112,30 @@ dependencies:
|
|
98
112
|
name: yard
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
|
-
- - "
|
115
|
+
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
117
|
+
version: 0.9.34
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
|
-
- - "
|
122
|
+
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
124
|
+
version: 0.9.34
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: rdiscount
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
|
-
- - "
|
129
|
+
- - "~>"
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
131
|
+
version: 2.2.7
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
|
-
- - "
|
136
|
+
- - "~>"
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
138
|
+
version: 2.2.7
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: ai21
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -280,16 +294,16 @@ dependencies:
|
|
280
294
|
name: llama_cpp
|
281
295
|
requirement: !ruby/object:Gem::Requirement
|
282
296
|
requirements:
|
283
|
-
- - "
|
297
|
+
- - "~>"
|
284
298
|
- !ruby/object:Gem::Version
|
285
|
-
version:
|
299
|
+
version: 0.3.7
|
286
300
|
type: :development
|
287
301
|
prerelease: false
|
288
302
|
version_requirements: !ruby/object:Gem::Requirement
|
289
303
|
requirements:
|
290
|
-
- - "
|
304
|
+
- - "~>"
|
291
305
|
- !ruby/object:Gem::Version
|
292
|
-
version:
|
306
|
+
version: 0.3.7
|
293
307
|
- !ruby/object:Gem::Dependency
|
294
308
|
name: nokogiri
|
295
309
|
requirement: !ruby/object:Gem::Requirement
|
@@ -493,36 +507,18 @@ executables: []
|
|
493
507
|
extensions: []
|
494
508
|
extra_rdoc_files: []
|
495
509
|
files:
|
496
|
-
- ".env.example"
|
497
|
-
- ".rspec"
|
498
|
-
- ".rubocop.yml"
|
499
|
-
- ".tool-versions"
|
500
510
|
- CHANGELOG.md
|
501
|
-
- Gemfile
|
502
|
-
- Gemfile.lock
|
503
511
|
- LICENSE.txt
|
504
512
|
- README.md
|
505
|
-
- Rakefile
|
506
|
-
- examples/conversation_with_openai.rb
|
507
|
-
- examples/create_and_manage_few_shot_prompt_templates.rb
|
508
|
-
- examples/create_and_manage_prompt_templates.rb
|
509
|
-
- examples/create_and_manage_prompt_templates_using_structured_output_parser.rb
|
510
|
-
- examples/llama_cpp.rb
|
511
|
-
- examples/open_ai_function_calls.rb
|
512
|
-
- examples/open_ai_qdrant_function_calls.rb
|
513
|
-
- examples/pdf_store_and_query_with_chroma.rb
|
514
|
-
- examples/store_and_query_with_pinecone.rb
|
515
|
-
- examples/store_and_query_with_qdrant.rb
|
516
|
-
- examples/store_and_query_with_weaviate.rb
|
517
|
-
- lefthook.yml
|
518
513
|
- lib/langchain.rb
|
519
514
|
- lib/langchain/active_record/hooks.rb
|
520
515
|
- lib/langchain/agent/base.rb
|
521
|
-
- lib/langchain/agent/react_agent
|
516
|
+
- lib/langchain/agent/react_agent.rb
|
522
517
|
- lib/langchain/agent/react_agent/react_agent_prompt.yaml
|
523
|
-
- lib/langchain/agent/sql_query_agent
|
518
|
+
- lib/langchain/agent/sql_query_agent.rb
|
524
519
|
- lib/langchain/agent/sql_query_agent/sql_query_agent_answer_prompt.yaml
|
525
520
|
- lib/langchain/agent/sql_query_agent/sql_query_agent_sql_prompt.yaml
|
521
|
+
- lib/langchain/ai_message.rb
|
526
522
|
- lib/langchain/chunker/base.rb
|
527
523
|
- lib/langchain/chunker/recursive_text.rb
|
528
524
|
- lib/langchain/chunker/text.rb
|
@@ -531,6 +527,7 @@ files:
|
|
531
527
|
- lib/langchain/conversation_memory.rb
|
532
528
|
- lib/langchain/data.rb
|
533
529
|
- lib/langchain/dependency_helper.rb
|
530
|
+
- lib/langchain/human_message.rb
|
534
531
|
- lib/langchain/llm/ai21.rb
|
535
532
|
- lib/langchain/llm/anthropic.rb
|
536
533
|
- lib/langchain/llm/base.rb
|
@@ -542,10 +539,11 @@ files:
|
|
542
539
|
- lib/langchain/llm/prompts/summarize_template.yaml
|
543
540
|
- lib/langchain/llm/replicate.rb
|
544
541
|
- lib/langchain/loader.rb
|
542
|
+
- lib/langchain/message.rb
|
545
543
|
- lib/langchain/output_parsers/base.rb
|
546
|
-
- lib/langchain/output_parsers/
|
544
|
+
- lib/langchain/output_parsers/output_fixing_parser.rb
|
547
545
|
- lib/langchain/output_parsers/prompts/naive_fix_prompt.yaml
|
548
|
-
- lib/langchain/output_parsers/
|
546
|
+
- lib/langchain/output_parsers/structured_output_parser.rb
|
549
547
|
- lib/langchain/processors/base.rb
|
550
548
|
- lib/langchain/processors/csv.rb
|
551
549
|
- lib/langchain/processors/docx.rb
|
@@ -555,11 +553,13 @@ files:
|
|
555
553
|
- lib/langchain/processors/pdf.rb
|
556
554
|
- lib/langchain/processors/text.rb
|
557
555
|
- lib/langchain/processors/xlsx.rb
|
556
|
+
- lib/langchain/prompt.rb
|
558
557
|
- lib/langchain/prompt/base.rb
|
559
558
|
- lib/langchain/prompt/few_shot_prompt_template.rb
|
560
559
|
- lib/langchain/prompt/loading.rb
|
561
560
|
- lib/langchain/prompt/prompt_template.rb
|
562
561
|
- lib/langchain/railtie.rb
|
562
|
+
- lib/langchain/system_message.rb
|
563
563
|
- lib/langchain/tool/base.rb
|
564
564
|
- lib/langchain/tool/calculator.rb
|
565
565
|
- lib/langchain/tool/database.rb
|
@@ -583,7 +583,6 @@ files:
|
|
583
583
|
- lib/langchain/vectorsearch/weaviate.rb
|
584
584
|
- lib/langchain/version.rb
|
585
585
|
- lib/langchainrb.rb
|
586
|
-
- sig/langchain.rbs
|
587
586
|
homepage: https://rubygems.org/gems/langchainrb
|
588
587
|
licenses:
|
589
588
|
- MIT
|
data/.env.example
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
AI21_API_KEY=
|
2
|
-
ANTHROPIC_API_KEY=
|
3
|
-
CHROMA_URL=
|
4
|
-
COHERE_API_KEY=
|
5
|
-
GOOGLE_PALM_API_KEY=
|
6
|
-
HUGGING_FACE_API_KEY=
|
7
|
-
LLAMACPP_MODEL_PATH=
|
8
|
-
LLAMACPP_N_THREADS=
|
9
|
-
LLAMACPP_N_GPU_LAYERS=
|
10
|
-
MILVUS_URL=
|
11
|
-
OPENAI_API_KEY=
|
12
|
-
OPEN_WEATHER_API_KEY=
|
13
|
-
PINECONE_API_KEY=
|
14
|
-
PINECONE_ENVIRONMENT=
|
15
|
-
POSTGRES_URL=
|
16
|
-
REPLICATE_API_KEY=
|
17
|
-
QDRANT_API_KEY=
|
18
|
-
QDRANT_URL=
|
19
|
-
SERPAPI_API_KEY=
|
20
|
-
WEAVIATE_API_KEY=
|
21
|
-
WEAVIATE_URL=
|
data/.rspec
DELETED
data/.rubocop.yml
DELETED
data/.tool-versions
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
ruby 3.1.2
|
data/Gemfile
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
# Specify your gem's dependencies in langchain.gemspec
|
6
|
-
gemspec
|
7
|
-
|
8
|
-
gem "rake", "~> 13.0"
|
9
|
-
|
10
|
-
gem "rspec", "~> 3.0"
|
11
|
-
|
12
|
-
gem "standardrb"
|
13
|
-
# Lets add rubocop explicitly here, we are using only standardrb rules in .rubocop.yml
|
14
|
-
gem "rubocop"
|