langchainrb 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +7 -1
- data/README.md +2 -1
- data/lib/langchain.rb +1 -0
- data/lib/llm/cohere.rb +1 -1
- 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: a179004be8e547124fe81922b2cf7190d34f94f7775c28df7986d17644dffa31
|
4
|
+
data.tar.gz: 0eaf80695379a5038175d561dfa348d4146073b008aeb662b3b523e8bd04d54d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 152fd7a35c9df7e9541b50059a27f5e76d67263ceb4e25dab07224bd80bffe70936ab712ab3345a401b4be5016a4165c8a7a6cf1b4b1673c36275d926d7ce17d
|
7
|
+
data.tar.gz: 848984972f6ab3f1dd4078d303872be1e70ae78a1ceedf2f0b7663f2144d12831c690e1ad48cbd579e779fbe6da8ad6339ee42130716bf4bb137917f5edf3e30
|
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.1)
|
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
|
|
data/lib/langchain.rb
CHANGED
data/lib/llm/cohere.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.1
|
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-13 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
|