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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d43d7b8fab03608be188730dd7e67947e161176ea11ad29a3d6a3b3469045da
4
- data.tar.gz: 2a0cf937f20dcb620fde4fac5bfdd1cbafee92d1212ab61fc25db352c3bce79f
3
+ metadata.gz: a179004be8e547124fe81922b2cf7190d34f94f7775c28df7986d17644dffa31
4
+ data.tar.gz: 0eaf80695379a5038175d561dfa348d4146073b008aeb662b3b523e8bd04d54d
5
5
  SHA512:
6
- metadata.gz: 2eb42e6ea5ee796bd7b78addd9c3cc75449ca84a680c0b50668eb678e14cb4991fe38577a323acbd628b30b3753a2197da8a34ef908dac15402277e078a8c287
7
- data.tar.gz: 1a1d51903ef37908b2f0f5a2ded0542a04f5e812ff4c2fa37b67dbaa80636d50a70d7cf8bf05bfceedbe21a016d6dcb6e98a9fa3e25981feb05f4a4cec2ca52f
6
+ metadata.gz: 152fd7a35c9df7e9541b50059a27f5e76d67263ceb4e25dab07224bd80bffe70936ab712ab3345a401b4be5016a4165c8a7a6cf1b4b1673c36275d926d7ce17d
7
+ data.tar.gz: 848984972f6ab3f1dd4078d303872be1e70ae78a1ceedf2f0b7663f2144d12831c690e1ad48cbd579e779fbe6da8ad6339ee42130716bf4bb137917f5edf3e30
data/CHANGELOG.md CHANGED
@@ -1,4 +1,9 @@
1
1
  ## [Unreleased]
2
+
3
+ ## [0.3.1] - 2023-05-12
4
+ - Tools
5
+ - Introducing `Tool::Wikipedia`, a tool that looks up Wikipedia entries
6
+
2
7
  ## [0.3.0] - 2023-05-12
3
8
 
4
9
  - Agents
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- langchainrb (0.3.0)
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
@@ -33,4 +33,5 @@ module Tool
33
33
  autoload :Base, "tool/base"
34
34
  autoload :Calculator, "tool/calculator"
35
35
  autoload :SerpApi, "tool/serp_api"
36
+ autoload :Wikipedia, "tool/wikipedia"
36
37
  end
data/lib/llm/cohere.rb CHANGED
@@ -34,7 +34,7 @@ module LLM
34
34
  default_params = {
35
35
  prompt: prompt,
36
36
  temperature: DEFAULTS[:temperature],
37
- model: DEFAULTS[:completion_model_name]
37
+ model: "xlarge" #DEFAULTS[:completion_model_name]
38
38
  }
39
39
 
40
40
  if params[:stop_sequences]
data/lib/tool/base.rb CHANGED
@@ -11,7 +11,8 @@ module Tool
11
11
 
12
12
  TOOLS = {
13
13
  "calculator" => "Tool::Calculator",
14
- "search" => "Tool::SerpApi"
14
+ "search" => "Tool::SerpApi",
15
+ "wikipedia" => "Tool::Wikipedia"
15
16
  }
16
17
 
17
18
  # Executes the tool and returns the answer
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["SERP_API_KEY"]
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Langchain
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
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.0
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-12 00:00:00.000000000 Z
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