ox-ai-workers 1.0.2.1 → 1.0.3.1

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: 33177f5c822272383d00d96fadd552db0b966af7ddb2ec494538ca8cace7fadf
4
- data.tar.gz: e3f756943f16fb8be2823f493156e261eb2d4d02a99d9c0373e8a3ed606c8726
3
+ metadata.gz: 63333753af17a6c29abe4896073180e09fd70f13c64f234b347abba88805ca22
4
+ data.tar.gz: 60c2cff72eca13c1ecb23fc9b8b0a26bf3ccdfc2d5da26395ba7db059ede19cc
5
5
  SHA512:
6
- metadata.gz: a64203d85443d9b812c2d36aa0718283fb21fd784043a4d1346ec96a3386bec3766f4ed127d41c1c6f149af7abb4af6241fad089caf72b058037b7bc323b08cb
7
- data.tar.gz: f0e1ec3b3be53fbe00f31dddc6e16e6a3befb7457d307cbc9906160b02e94bc66d8d18ec1c0095c2e6a53c9d48d4f256515da6ac0ea1ae4bb327ab07fb0772a0
6
+ metadata.gz: 9452ff80ce8e7eedd97bd5ee9b3e536d5e8ec596cf81ff7981a092a5d4e7d08eb9cd221735b57d8f5988fa6f27eaef5503f16e40a60aa8af9d45bb44dfa7a2f4
7
+ data.tar.gz: 4927f961c0036849a20ca6365e87aaa035ca618918cf8bbe7261f5052d95e0552e251c3b9e51179af0f677950e78ff489d18bfe2d794c5fa9af2880787702e47
data/lib/ox-ai-workers.rb CHANGED
@@ -61,7 +61,7 @@ module OxAiWorkers
61
61
 
62
62
  class Configuration
63
63
  attr_accessor :max_tokens, :temperature, :wait_for_complete, :access_token_deepseek, :access_token_openai,
64
- :access_token_stability, :access_token_wolfram
64
+ :access_token_stability, :access_token_wolfram, :access_token_anthropic
65
65
 
66
66
  def initialize
67
67
  @max_tokens = DEFAULT_MAX_TOKEN
@@ -72,6 +72,7 @@ module OxAiWorkers
72
72
  @access_token_openai = nil
73
73
  @access_token_stability = nil
74
74
  @access_token_wolfram = nil
75
+ @access_token_anthropic = nil
75
76
 
76
77
  [Array, NilClass, String, Symbol, Hash].each do |c|
77
78
  c.send(:include, OxAiWorkers::PresentCompat) unless c.method_defined?(:present?)
@@ -217,7 +217,7 @@ module OxAiWorkers
217
217
  end
218
218
 
219
219
  if @worker.tool_calls.present?
220
- @queue << { role: :assistant, content: @worker.tool_calls_raw.to_s }
220
+ # @queue << { role: :assistant, content: @worker.tool_calls_raw.to_s }
221
221
  @worker.tool_calls.each do |external_call|
222
222
  tool = ([self] + @tools).select do |t|
223
223
  tool_name = t.respond_to?(:tool_name) ? t.tool_name : t.class.tool_name
@@ -226,13 +226,26 @@ module OxAiWorkers
226
226
  next if tool.nil?
227
227
 
228
228
  @call_id += 1
229
+ # Add tool call message in the correct format
229
230
  out = tool.send(external_call[:name], **external_call[:args])
230
- @queue << { role: :assistant,
231
- content: "Tool call #{external_call[:name]} completed." }
231
+ @queue << {
232
+ role: :assistant,
233
+ tool_calls: [{
234
+ id: "call_#{@call_id}",
235
+ type: 'function',
236
+ function: {
237
+ name: external_call[:name],
238
+ arguments: external_call[:args].to_json
239
+ }
240
+ }]
241
+ }
232
242
  @queue << if out.present?
233
- { role: :tool, content: out, tool_call_id: "call_#{@call_id}" }
243
+ { role: :tool,
244
+ content: out,
245
+ tool_call_id: "call_#{@call_id}" }
234
246
  else
235
- { role: :tool, content: "Tool call #{external_call[:name]} successful.",
247
+ { role: :tool,
248
+ content: "Tool call #{external_call[:name]} successful.",
236
249
  tool_call_id: "call_#{@call_id}" }
237
250
  end
238
251
  end
@@ -267,7 +280,7 @@ module OxAiWorkers
267
280
  type: 'file',
268
281
  file: {
269
282
  filename:,
270
- file_data: Base64.strict_encode64(pdf)
283
+ file_data: "data:application/pdf;base64,#{Base64.strict_encode64(pdf)}"
271
284
  }
272
285
  }
273
286
 
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OxAiWorkers
4
+ module Models
5
+ class AnthropicMax < LLMBase
6
+ def initialize(uri_base: nil, api_key: nil, model: nil, max_tokens: nil, temperature: nil, frequency_penalty: nil)
7
+ @model = model || 'claude-3-7-sonnet-latest'
8
+ @uri_base = uri_base || 'https://api.anthropic.com/v1/'
9
+ @api_key = api_key || OxAiWorkers.configuration.access_token_anthropic
10
+ super(uri_base:, api_key: @api_key, model: @model, max_tokens:, temperature:, frequency_penalty:)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OxAiWorkers
4
- VERSION = '1.0.2.1'
4
+ VERSION = '1.0.3.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ox-ai-workers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2.1
4
+ version: 1.0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Smolev
@@ -157,6 +157,7 @@ files:
157
157
  - lib/oxaiworkers/image_iterator.rb
158
158
  - lib/oxaiworkers/iterator.rb
159
159
  - lib/oxaiworkers/load_i18n.rb
160
+ - lib/oxaiworkers/models/anthropic_max.rb
160
161
  - lib/oxaiworkers/models/deepseek_max.rb
161
162
  - lib/oxaiworkers/models/images_base.rb
162
163
  - lib/oxaiworkers/models/llm_base.rb