langgraph_rb 0.1.9 → 0.1.11

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: 299430b38fa98a9d82a902479bfd22256192300a9aa57635f8fc3240bbb662d6
4
- data.tar.gz: 9dddfa3c24e5425fee43718aa06df70258cc3659ee624a5e5303f7eb59aa8f21
3
+ metadata.gz: 52c0ea2c25f4b4d81c935ed9aef8c0ad801f82c92518bc03aa670b1b2a156059
4
+ data.tar.gz: 1438ed541d67c60d678b3d8fe6791c9731c74b018408b2492365c70864d0615b
5
5
  SHA512:
6
- metadata.gz: 65eb35f3aba912b4aa69513c02561d9a953349a20475ecec254ed078e708cb19c603b13e154cd0145e05a50c55bfdefe006283bfaf0f397c6e53c834fa033954
7
- data.tar.gz: 03ac84c5bfed8b1bc67ee51517d243a743e09dfb671d3fce75cb3e79af299098253f65d8d73e1df10ec3041a4d995fbec4c3497245299b33b9bf7721878daae3
6
+ metadata.gz: 79d9cbd6f37adfd631672422a096d0532bd8a45f74b1dcc6009f2c838adc778544d0282068f3ce858c807ce2576f27340640653529ddb00f81c15c11e5fc8268
7
+ data.tar.gz: 79faa32d6984640c53a22b747e30f60aa0674b638a7666c400df0cedf927f5421d85ec1e87114bfb135ed289a24d6fcad31bce96919f50d418e3dd1490d99e2d
data/Gemfile CHANGED
@@ -2,7 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'openai', '~> 0.24.0'
6
5
 
7
6
  group :development, :test do
8
7
  gem 'rspec', '~> 3.0'
data/Gemfile.lock CHANGED
@@ -1,9 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- langgraph_rb (0.1.4)
4
+ langgraph_rb (0.1.9)
5
5
  json (~> 2.0)
6
- openai (~> 0.24.0)
7
6
 
8
7
  GEM
9
8
  remote: https://rubygems.org/
@@ -12,22 +11,19 @@ GEM
12
11
  byebug (12.0.0)
13
12
  coderay (1.1.3)
14
13
  concurrent-ruby (1.3.5)
15
- connection_pool (2.5.4)
16
14
  diff-lcs (1.6.2)
17
- json (2.13.2)
15
+ json (2.15.1)
18
16
  langfuse (0.1.1)
19
17
  concurrent-ruby (~> 1.2)
20
18
  sorbet-runtime (~> 0.5)
21
19
  language_server-protocol (3.17.0.5)
22
20
  lint_roller (1.1.0)
23
21
  method_source (1.1.0)
24
- openai (0.24.0)
25
- connection_pool
26
22
  parallel (1.27.0)
27
23
  parser (3.3.9.0)
28
24
  ast (~> 2.4.1)
29
25
  racc
30
- prism (1.4.0)
26
+ prism (1.5.1)
31
27
  pry (0.15.2)
32
28
  coderay (~> 1.1)
33
29
  method_source (~> 1.0)
@@ -37,7 +33,7 @@ GEM
37
33
  racc (1.8.1)
38
34
  rainbow (3.1.1)
39
35
  rake (13.3.0)
40
- regexp_parser (2.11.1)
36
+ regexp_parser (2.11.3)
41
37
  rspec (3.13.1)
42
38
  rspec-core (~> 3.13.0)
43
39
  rspec-expectations (~> 3.13.0)
@@ -50,8 +46,8 @@ GEM
50
46
  rspec-mocks (3.13.5)
51
47
  diff-lcs (>= 1.2.0, < 2.0)
52
48
  rspec-support (~> 3.13.0)
53
- rspec-support (3.13.4)
54
- rubocop (1.79.2)
49
+ rspec-support (3.13.6)
50
+ rubocop (1.81.1)
55
51
  json (~> 2.3)
56
52
  language_server-protocol (~> 3.17.0.2)
57
53
  lint_roller (~> 1.1.0)
@@ -59,17 +55,17 @@ GEM
59
55
  parser (>= 3.3.0.2)
60
56
  rainbow (>= 2.2.2, < 4.0)
61
57
  regexp_parser (>= 2.9.3, < 3.0)
62
- rubocop-ast (>= 1.46.0, < 2.0)
58
+ rubocop-ast (>= 1.47.1, < 2.0)
63
59
  ruby-progressbar (~> 1.7)
64
60
  unicode-display_width (>= 2.4.0, < 4.0)
65
- rubocop-ast (1.46.0)
61
+ rubocop-ast (1.47.1)
66
62
  parser (>= 3.3.7.2)
67
63
  prism (~> 1.4)
68
64
  ruby-progressbar (1.13.0)
69
- sorbet-runtime (0.6.12534)
70
- unicode-display_width (3.1.4)
71
- unicode-emoji (~> 4.0, >= 4.0.4)
72
- unicode-emoji (4.0.4)
65
+ sorbet-runtime (0.6.12627)
66
+ unicode-display_width (3.2.0)
67
+ unicode-emoji (~> 4.1)
68
+ unicode-emoji (4.1.0)
73
69
 
74
70
  PLATFORMS
75
71
  arm64-darwin-22
@@ -79,7 +75,6 @@ DEPENDENCIES
79
75
  bundler (~> 2.0)
80
76
  langfuse (~> 0.1)
81
77
  langgraph_rb!
82
- openai (~> 0.24.0)
83
78
  pry (~> 0.14)
84
79
  pry-byebug
85
80
  rake (~> 13.0)
@@ -87,4 +82,4 @@ DEPENDENCIES
87
82
  rubocop (~> 1.0)
88
83
 
89
84
  BUNDLED WITH
90
- 2.6.7
85
+ 2.7.2
data/examples/Gemfile ADDED
@@ -0,0 +1 @@
1
+ gem 'ruby-openai', '~> 8.1.0'
@@ -3,9 +3,10 @@ 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
+ #require 'openai'
7
+ #require_relative '../lib/langgraph_rb/chat_openai'
8
+ require "openai"
9
+ require_relative '../lib/langgraph_rb/chat_ruby_openai'
9
10
 
10
11
  url = 'https://us.cloud.langfuse.com'
11
12
 
@@ -43,7 +44,8 @@ end
43
44
  def run_chat_openai_tools
44
45
  tools = [Tool::MovieInfoTool.new(api_key: ENV['TMDB_API_KEY'] || 'demo')]
45
46
 
46
- chat = LangGraphRB::ChatOpenAI.new(model: ENV.fetch('OPENAI_MODEL', 'gpt-4o-mini'), temperature: 0)
47
+ #chat = LangGraphRB::ChatOpenAI.new(model: ENV.fetch('OPENAI_MODEL', 'gpt-4o-mini'), temperature: 0)
48
+ chat = LangGraphRB::ChatRubyOpenAI.new(model: ENV.fetch('OPENAI_MODEL', 'gpt-4o-mini'), temperature: 0)
47
49
  chat = chat.bind_tools(tools)
48
50
 
49
51
  observers = [LangGraphRB::Observers::LangfuseObserver.new(name: 'chat-openai-tools-example')]
@@ -33,11 +33,12 @@ module LangGraphRB
33
33
  end
34
34
 
35
35
  request_payload = {
36
- model: @model,
37
- temperature: @temperature,
36
+ model: @model,
38
37
  messages: normalize_messages(messages)
39
38
  }
40
39
 
40
+ request_payload[:temperature] = @temperature if @temperature.present?
41
+
41
42
  if tool_schemas && !tool_schemas.empty?
42
43
  request_payload[:tools] = tool_schemas
43
44
  request_payload[:tool_choice] = 'auto'
@@ -47,15 +48,15 @@ module LangGraphRB
47
48
  name: 'OpenAI::ChatCompletion',
48
49
  model: @model,
49
50
  model_parameters: { temperature: @temperature },
50
- input: request_payload[:messages]
51
+ input: request_payload
51
52
  })
52
53
 
53
54
  # ruby-openai 8.1.x: client.chat(parameters: {...}) returns a Hash
54
55
  response = @client.chat(parameters: request_payload)
55
56
 
56
57
  message = extract_message_from_response(response)
57
- tool_calls = message[:tool_calls]
58
- text_content = message[:content]
58
+ tool_calls = message["tool_calls"]
59
+ text_content = message["content"]
59
60
 
60
61
  usage = extract_usage_from_response(response)
61
62
  notify_llm_response({
@@ -68,9 +69,9 @@ module LangGraphRB
68
69
  if tool_calls && !tool_calls.empty?
69
70
  normalized_calls = tool_calls.map do |tc|
70
71
  {
71
- id: tc[:id],
72
- name: tc[:function][:name],
73
- arguments: parse_tool_arguments(tc[:function][:arguments])
72
+ id: tc["id"],
73
+ name: tc["function"]["name"],
74
+ arguments: parse_tool_arguments(tc["function"]["arguments"])
74
75
  }
75
76
  end
76
77
  { tool_calls: normalized_calls }
@@ -78,7 +79,7 @@ module LangGraphRB
78
79
  text_content
79
80
  end
80
81
  rescue => e
81
- notify_llm_error({ error: e.message })
82
+ notify_llm_error({ error: e.response&.dig(:body) || e.message })
82
83
  raise e
83
84
  end
84
85
 
@@ -1,3 +1,3 @@
1
1
  module LangGraphRB
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.11"
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.9
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Toro
@@ -109,6 +109,7 @@ files:
109
109
  - Gemfile.lock
110
110
  - README.md
111
111
  - SUMMARY.md
112
+ - examples/Gemfile
112
113
  - examples/advanced_example.rb
113
114
  - examples/basic_example.rb
114
115
  - examples/chat_openai_tools_example.rb