intelli_agent 0.2.9 → 0.2.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/intelli_agent/openai.rb +12 -22
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 586990e6d1d8fa1fb890bb9530d7f175f4f403ed309ca111517755ed5e07c2f3
4
- data.tar.gz: 669c3765fd006605eb86b93a31b90aa4e6101a50820e8e3dd9eaeec54f17f2d0
3
+ metadata.gz: e94ab4d8cf68071308ab502086f092fc7424622de20420d00bba18451cd10705
4
+ data.tar.gz: f74579964f8d1a40a7d3f26f64b079ada32d202f2cf6c08f15e615e24ded8ee7
5
5
  SHA512:
6
- metadata.gz: 7af7fe5d68898a89ace33fd71a5eeb519566760900c675782d5620ff29c56013b3e6b92e7074b006668cafa825e5b3ce48db5666b61e5140e14903b54874e739
7
- data.tar.gz: dbb26d71d8187090d151436a8ec2229950b13f93f87c228c42cfaaa77ec98762f75f86e9696f1f9a843b0848cfde92a2ca9cd3afdab613cb51d693193ac17fb8
6
+ metadata.gz: fbc1c8b705f7050b8f9bf18aa8aef380559e38019bde3911f598b4546ac6cdd2d2596b158502509663058cdfa8d052cd4e3dc992973f813739f86bd9336930bc
7
+ data.tar.gz: b82503246fe4365c46fad3528522cd4ee1acf8d7ecb9a72d3c4975acfde835031fc0a6556cb85944fecf3806bcf1de8c75d9b1fa04a03c21d7f8b2398ac989fe
@@ -58,42 +58,32 @@ module IntelliAgent::OpenAI
58
58
  response
59
59
  end
60
60
 
61
- def self.vision(prompt:, image_url:, model: :gpt_advanced, response_format: nil, max_tokens: MAX_TOKENS)
62
- model = select_model(model)
63
- messages = [{ type: :text, text: prompt },
64
- { type: :image_url, image_url: { url: image_url } }]
65
-
66
- parameters = { model: model, messages: [{ role: :user, content: messages }], max_tokens: }
67
- parameters[:response_format] = { type: 'json_object' } if response_format.eql?(:json)
68
-
69
- response = OpenAI::Client.new.chat(parameters:)
70
-
71
- def response.content = dig('choices', 0, 'message', 'content').strip
72
-
73
- response
61
+ def self.vision(prompt:, image_url:, model: :gpt_advanced, response_format: nil, max_tokens: MAX_TOKENS, store: true, metadata: nil, tools: nil, auto_run_functions: false, function_context: nil)
62
+ message_content = [{ type: :text, text: prompt }, { type: :image_url, image_url: { url: image_url } }]
63
+ chat(messages: [{ role: :user, content: message_content }], model:, response_format:, max_tokens:, store:, tools:, auto_run_functions:, function_context:)
74
64
  end
75
65
 
76
- def self.single_prompt(prompt:, model: :gpt_basic, response_format: nil, max_tokens: MAX_TOKENS, store: true, tools: nil, auto_run_functions: false, function_context: nil)
66
+ def self.single_prompt(prompt:, model: :gpt_basic, response_format: nil, max_tokens: MAX_TOKENS, store: true, metadata: nil, tools: nil, auto_run_functions: false, function_context: nil)
77
67
  chat(messages: [{ user: prompt }], model:, response_format:, max_tokens:, store:, tools:, auto_run_functions:, function_context:)
78
68
  end
79
69
 
80
- def self.single_chat(system:, user:, model: :gpt_basic, response_format: nil, max_tokens: MAX_TOKENS, store: true, tools: nil, auto_run_functions: false, function_context: nil)
70
+ def self.single_chat(system:, user:, model: :gpt_basic, response_format: nil, max_tokens: MAX_TOKENS, store: true, metadata: nil, tools: nil, auto_run_functions: false, function_context: nil)
81
71
  chat(messages: [{ system: }, { user: }], model:, response_format:, max_tokens:, store:, tools:, auto_run_functions:, function_context:)
82
72
  end
83
73
 
84
- def self.chat(messages:, model: :gpt_basic, response_format: nil, max_tokens: MAX_TOKENS, store: true, tools: nil, auto_run_functions: false, function_context: nil)
74
+ def self.chat(messages:, model: :gpt_basic, response_format: nil, max_tokens: MAX_TOKENS, store: true, metadata: nil, tools: nil, auto_run_functions: false, function_context: nil)
85
75
  model = select_model(model)
86
-
87
- # o1 models doesn't support max_tokens, instead max_completion_tokens
88
76
  is_o1_model = model.start_with?('o1')
89
- max_completion_tokens = max_tokens if is_o1_model
90
77
 
91
78
  messages = parse_messages(messages)
92
79
 
93
80
  parameters = { model:, messages:, store: }
81
+ parameters[:metadata] = metadata if metadata
82
+
94
83
 
95
- parameters[:max_completion_tokens] = max_completion_tokens if is_o1_model
96
- parameters[:max_tokens] = max_completion_tokens unless is_o1_model
84
+ # o1 family models doesn't support max_tokens params. Instead, use max_completion_tokens
85
+ parameters[:max_completion_tokens] = max_tokens if is_o1_model
86
+ parameters[:max_tokens] = max_tokens unless is_o1_model
97
87
 
98
88
  parameters[:response_format] = { type: 'json_object' } if response_format.eql?(:json)
99
89
  parameters[:tools] = tools if tools
@@ -133,7 +123,7 @@ module IntelliAgent::OpenAI
133
123
 
134
124
  def self.parse_messages(messages)
135
125
  case messages
136
- in [{ role: String, content: String }, *]
126
+ in [{ role: String | Symbol, content: String | Array }, *]
137
127
  messages
138
128
  else
139
129
  messages.map do |msg|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: intelli_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gedean Dias
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2027-10-03 00:00:00.000000000 Z
11
+ date: 2024-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-openai
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  requirements: []
87
- rubygems_version: 3.5.20
87
+ rubygems_version: 3.5.21
88
88
  signing_key:
89
89
  specification_version: 4
90
90
  summary: A helper layer over Anthropic and OpenAI API