langchainrb 0.3.0 → 0.3.2

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: e751a38f6a248db9aabfac3f1b9bc547f61304dd366be999005941045a5adcd6
4
+ data.tar.gz: 56db69c0a578bdf198bfc12cb53e92f0e1d15654a1dfa29715d5d7833550da33
5
5
  SHA512:
6
- metadata.gz: 2eb42e6ea5ee796bd7b78addd9c3cc75449ca84a680c0b50668eb678e14cb4991fe38577a323acbd628b30b3753a2197da8a34ef908dac15402277e078a8c287
7
- data.tar.gz: 1a1d51903ef37908b2f0f5a2ded0542a04f5e812ff4c2fa37b67dbaa80636d50a70d7cf8bf05bfceedbe21a016d6dcb6e98a9fa3e25981feb05f4a4cec2ca52f
6
+ metadata.gz: bdd3060863a967b48a6123ea379d9a98632730a726b8da9924bb0061511b8bf88fa05f36c49ac4b8f136472e9aa204c4bd09929d31e0f2c0700ad16361a1a8cf
7
+ data.tar.gz: 88f04804d10f51d639b8643bd683b8a420920fc4ad2d26ef6c45f4fac034ec3f8b54787de51c4799f4a074029ad5649efca6e950b29fef62b96ce9452e5ec8cc
data/CHANGELOG.md CHANGED
@@ -1,4 +1,13 @@
1
1
  ## [Unreleased]
2
+
3
+ ## [0.3.2] - 2023-05-15
4
+ - Agents
5
+ - Fix Chain of Thought prompt loader
6
+
7
+ ## [0.3.1] - 2023-05-12
8
+ - Tools
9
+ - Introducing `Tool::Wikipedia`, a tool that looks up Wikipedia entries
10
+
2
11
  ## [0.3.0] - 2023-05-12
3
12
 
4
13
  - 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.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: "lib/agent/chain_of_thought_agent/chain_of_thought_agent_prompt.json"
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
@@ -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/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.2"
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.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-12 00:00:00.000000000 Z
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