langgraph_rb 0.1.8 → 0.1.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6882db2f57746e6a18576eefd6bd26749009361880d1cd858ee91d3d06385abe
4
- data.tar.gz: fa195eb1ed6763a3e0b53803792e92e7dd1dd327c9dd9372d7acf7ab3ea49d8f
3
+ metadata.gz: 299430b38fa98a9d82a902479bfd22256192300a9aa57635f8fc3240bbb662d6
4
+ data.tar.gz: 9dddfa3c24e5425fee43718aa06df70258cc3659ee624a5e5303f7eb59aa8f21
5
5
  SHA512:
6
- metadata.gz: aa652301646c12a2d2ade30faf5d5f463a89190813b9dbccb8c1b8df675bc6e0e8911c3358166224617239f763578b95fe78f27850e11690fc3e7726b85edc4c
7
- data.tar.gz: 1a7fa46cf43d02b0c356c58f5e5aaed84023c5c2cece84eaf49ff084627ac046f1dd170f4e9cf2477ed1981d1ca8b7321ad416c9e4610c854793bdcdbf6b990d
6
+ metadata.gz: 65eb35f3aba912b4aa69513c02561d9a953349a20475ecec254ed078e708cb19c603b13e154cd0145e05a50c55bfdefe006283bfaf0f397c6e53c834fa033954
7
+ data.tar.gz: 03ac84c5bfed8b1bc67ee51517d243a743e09dfb671d3fce75cb3e79af299098253f65d8d73e1df10ec3041a4d995fbec4c3497245299b33b9bf7721878daae3
@@ -3,6 +3,9 @@ require 'pry'
3
3
  require 'pry-byebug'
4
4
  require 'langfuse'
5
5
  require_relative '../lib/langgraph_rb'
6
+ require 'openai'
7
+ require_relative '../lib/langgraph_rb/chat_openai'
8
+
6
9
 
7
10
  url = 'https://us.cloud.langfuse.com'
8
11
 
@@ -13,30 +16,32 @@ Langfuse.configure do |config|
13
16
  config.debug = true # Enable debug logging
14
17
  end
15
18
 
16
- class MovieInfoTool < LangGraphRB::ToolBase
17
- define_function :search_movie, description: "MovieInfoTool: Search for a movie by title" do
18
- property :query, type: "string", description: "The movie title to search for", required: true
19
- end
19
+ module Tool
20
+ class MovieInfoTool < LangGraphRB::ToolBase
21
+ define_function :search_movie, description: "MovieInfoTool: Search for a movie by title" do
22
+ property :query, type: "string", description: "The movie title to search for", required: true
23
+ end
20
24
 
21
- define_function :get_movie_details, description: "MovieInfoTool: Get detailed information about a specific movie" do
22
- property :movie_id, type: "integer", description: "The TMDb ID of the movie", required: true
23
- end
25
+ define_function :get_movie_details, description: "MovieInfoTool: Get detailed information about a specific movie" do
26
+ property :movie_id, type: "integer", description: "The TMDb ID of the movie", required: true
27
+ end
24
28
 
25
- def initialize(api_key: "demo")
26
- @api_key = api_key
27
- end
29
+ def initialize(api_key: "demo")
30
+ @api_key = api_key
31
+ end
28
32
 
29
- def search_movie(query:)
30
- tool_response({ results: [ { id: 603, title: query, year: 1999 } ] })
31
- end
33
+ def search_movie(query:)
34
+ tool_response({ results: [ { id: 603, title: query, year: 1999 } ] })
35
+ end
32
36
 
33
- def get_movie_details(movie_id:)
34
- tool_response({ id: movie_id, title: "The Matrix", overview: "A computer hacker learns the truth of reality." })
37
+ def get_movie_details(movie_id:)
38
+ tool_response({ id: movie_id, title: "The Matrix", overview: "A computer hacker learns the truth of reality." })
39
+ end
35
40
  end
36
41
  end
37
42
 
38
43
  def run_chat_openai_tools
39
- tools = [MovieInfoTool.new(api_key: ENV['TMDB_API_KEY'] || 'demo')]
44
+ tools = [Tool::MovieInfoTool.new(api_key: ENV['TMDB_API_KEY'] || 'demo')]
40
45
 
41
46
  chat = LangGraphRB::ChatOpenAI.new(model: ENV.fetch('OPENAI_MODEL', 'gpt-4o-mini'), temperature: 0)
42
47
  chat = chat.bind_tools(tools)
@@ -158,7 +158,7 @@ module LangGraphRB
158
158
  return {
159
159
  id: call[:id],
160
160
  name: name.to_sym,
161
- class_name: class_name,
161
+ class_name: class_name.gsub('--', '::'),
162
162
  arguments: call[:arguments]
163
163
  }
164
164
  elsif call[:function]
@@ -8,7 +8,7 @@ module LangGraphRB
8
8
  end
9
9
 
10
10
  def define_function(name, description: "", &block)
11
- class_name = self.name
11
+ class_name = self.name.gsub('::', '--')
12
12
  fn_name = "#{class_name}__#{name}".to_sym
13
13
  @__tool_functions ||= {}
14
14
  @__tool_functions[fn_name] = {
@@ -1,3 +1,3 @@
1
1
  module LangGraphRB
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: langgraph_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Toro