langchainrb 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +7 -1
- data/README.md +2 -1
- data/lib/agent/chain_of_thought_agent/chain_of_thought_agent.rb +1 -1
- data/lib/langchain.rb +1 -0
- data/lib/tool/base.rb +2 -1
- data/lib/tool/serp_api.rb +4 -1
- data/lib/tool/wikipedia.rb +23 -0
- data/lib/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e751a38f6a248db9aabfac3f1b9bc547f61304dd366be999005941045a5adcd6
|
4
|
+
data.tar.gz: 56db69c0a578bdf198bfc12cb53e92f0e1d15654a1dfa29715d5d7833550da33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdd3060863a967b48a6123ea379d9a98632730a726b8da9924bb0061511b8bf88fa05f36c49ac4b8f136472e9aa204c4bd09929d31e0f2c0700ad16361a1a8cf
|
7
|
+
data.tar.gz: 88f04804d10f51d639b8643bd683b8a420920fc4ad2d26ef6c45f4fac034ec3f8b54787de51c4799f4a074029ad5649efca6e950b29fef62b96ce9452e5ec8cc
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
langchainrb (0.3.
|
4
|
+
langchainrb (0.3.2)
|
5
5
|
cohere-ruby (~> 0.9.3)
|
6
6
|
eqn (~> 1.6.5)
|
7
7
|
google_search_results (~> 2.0.0)
|
@@ -10,6 +10,7 @@ PATH
|
|
10
10
|
qdrant-ruby (~> 0.9.0)
|
11
11
|
ruby-openai (~> 4.0.0)
|
12
12
|
weaviate-ruby (~> 0.8.0)
|
13
|
+
wikipedia-client (~> 1.17.0)
|
13
14
|
|
14
15
|
GEM
|
15
16
|
remote: https://rubygems.org/
|
@@ -32,6 +33,8 @@ GEM
|
|
32
33
|
i18n (>= 1.6, < 2)
|
33
34
|
minitest (>= 5.1)
|
34
35
|
tzinfo (~> 2.0)
|
36
|
+
addressable (2.8.4)
|
37
|
+
public_suffix (>= 2.0.2, < 6.0)
|
35
38
|
builder (3.2.4)
|
36
39
|
byebug (11.1.3)
|
37
40
|
coderay (1.1.3)
|
@@ -150,6 +153,7 @@ GEM
|
|
150
153
|
pry-byebug (3.10.1)
|
151
154
|
byebug (~> 11.0)
|
152
155
|
pry (>= 0.13, < 0.15)
|
156
|
+
public_suffix (5.0.1)
|
153
157
|
qdrant-ruby (0.9.2)
|
154
158
|
faraday (~> 1)
|
155
159
|
faraday_middleware (~> 1)
|
@@ -196,6 +200,8 @@ GEM
|
|
196
200
|
faraday (~> 1)
|
197
201
|
faraday_middleware (~> 1)
|
198
202
|
graphlient (~> 0.6.0)
|
203
|
+
wikipedia-client (1.17.0)
|
204
|
+
addressable (~> 2.7)
|
199
205
|
zeitwerk (2.6.8)
|
200
206
|
|
201
207
|
PLATFORMS
|
data/README.md
CHANGED
@@ -224,8 +224,9 @@ agent.run(question: "How many full soccer fields would be needed to cover the di
|
|
224
224
|
|
225
225
|
| Name | Description | Requirements |
|
226
226
|
| -------- | :------------------: | :------------------: |
|
227
|
-
| "search" | A wrapper around Google Search | `ENV["SERP_API_KEY"]` (https://serpapi.com/manage-api-key)
|
228
227
|
| "calculator" | Useful for getting the result of a math expression | |
|
228
|
+
| "search" | A wrapper around Google Search | `ENV["SERPAPI_API_KEY"]` (https://serpapi.com/manage-api-key)
|
229
|
+
| "wikipedia" | Calls Wikipedia API to retrieve the summary | |
|
229
230
|
|
230
231
|
## Development
|
231
232
|
|
@@ -101,7 +101,7 @@ module Agent
|
|
101
101
|
# @return [PromptTemplate] PromptTemplate instance
|
102
102
|
def prompt_template
|
103
103
|
@template ||= Prompt.load_from_path(
|
104
|
-
file_path: "
|
104
|
+
file_path: Pathname.new(__dir__).join("chain_of_thought_agent_prompt.json")
|
105
105
|
)
|
106
106
|
end
|
107
107
|
end
|
data/lib/langchain.rb
CHANGED
data/lib/tool/base.rb
CHANGED
data/lib/tool/serp_api.rb
CHANGED
@@ -4,6 +4,9 @@ require "google_search_results"
|
|
4
4
|
|
5
5
|
module Tool
|
6
6
|
class SerpApi < Base
|
7
|
+
# Wrapper around SerpAPI
|
8
|
+
# Set ENV["SERPAPI_API_KEY"] to use it
|
9
|
+
|
7
10
|
DESCRIPTION = "A wrapper around Google Search. " +
|
8
11
|
"Useful for when you need to answer questions about current events. " +
|
9
12
|
"Always one of the first options when you need to find information on internet. " +
|
@@ -28,7 +31,7 @@ module Tool
|
|
28
31
|
def self.execute_search(input:)
|
29
32
|
GoogleSearch.new(
|
30
33
|
q: input,
|
31
|
-
serp_api_key: ENV["
|
34
|
+
serp_api_key: ENV["SERPAPI_API_KEY"]
|
32
35
|
)
|
33
36
|
.get_hash
|
34
37
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'wikipedia'
|
4
|
+
|
5
|
+
module Tool
|
6
|
+
class Wikipedia < Base
|
7
|
+
# Tool that adds the capability to search using the Wikipedia API
|
8
|
+
|
9
|
+
DESCRIPTION = "A wrapper around Wikipedia. " +
|
10
|
+
"Useful for when you need to answer general questions about " +
|
11
|
+
"people, places, companies, facts, historical events, or other subjects. " +
|
12
|
+
"Input should be a search query."
|
13
|
+
|
14
|
+
# Executes Wikipedia API search and returns the answer
|
15
|
+
# @param input [String] search query
|
16
|
+
# @return [String] Answer
|
17
|
+
def self.execute(input:)
|
18
|
+
page = ::Wikipedia.find(input)
|
19
|
+
# It would be nice to figure out a way to provide page.content but the LLM token limit is an issue
|
20
|
+
page.summary
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/version.rb
CHANGED
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.3.
|
4
|
+
version: 0.3.2
|
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-05-
|
11
|
+
date: 2023-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry-byebug
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: 0.8.0
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: wikipedia-client
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 1.17.0
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 1.17.0
|
153
167
|
description: Build ML/AI-powered applications with Ruby's LangChain
|
154
168
|
email:
|
155
169
|
- andrei.bondarev13@gmail.com
|
@@ -184,6 +198,7 @@ files:
|
|
184
198
|
- lib/tool/base.rb
|
185
199
|
- lib/tool/calculator.rb
|
186
200
|
- lib/tool/serp_api.rb
|
201
|
+
- lib/tool/wikipedia.rb
|
187
202
|
- lib/vectorsearch/base.rb
|
188
203
|
- lib/vectorsearch/milvus.rb
|
189
204
|
- lib/vectorsearch/pinecone.rb
|