intelli_agent 0.2.5 → 0.2.6
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 +4 -4
- data/lib/intelli_agent/openai.rb +28 -11
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae2989e4aa78c7e8021870de24d9455c43921003de84e988f315ca9227fa5994
|
4
|
+
data.tar.gz: 76aa773505ac530d040f8f3a5f36014e1bfa63ff33849aefd1372cbda28accd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb30c67aef8853173dac4552c5c78563498daf495491d8c68b7e9737911d50ea962ead0fd286a474ff6c3cd16558420f46c0a6c2dc8322a0aaf89565bf6d18d3
|
7
|
+
data.tar.gz: 2c5d843ae8b8ef3cb047f49b48f6dd9af950ee43416d7e832cdd173fd9233bbb559687a3770d3cf48aab442188f1826edc9e5e4e54995b2791a02ce9f13d6a9b
|
data/lib/intelli_agent/openai.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
module IntelliAgent::OpenAI
|
2
|
-
|
3
|
-
|
2
|
+
GPT_BASIC_MODEL = ENV.fetch('OPENAI_GPT_BASIC_MODEL', 'gpt-4o-mini')
|
3
|
+
GPT_ADVANCED_MODEL = ENV.fetch('OPENAI_GPT_ADVANCED_MODEL', 'gpt-4o-2024-08-06')
|
4
|
+
|
5
|
+
O1_BASIC_MODEL = ENV.fetch('OPENAI_O1_BASIC_MODEL', 'o1-mini')
|
6
|
+
O1_ADVANCED_MODEL = ENV.fetch('OPENAI_O1_ADVANCED_MODEL', 'o1-preview')
|
7
|
+
|
4
8
|
MAX_TOKENS = ENV.fetch('OPENAI_MAX_TOKENS', 16_383).to_i
|
5
9
|
|
6
10
|
module ResponseExtender
|
@@ -36,7 +40,7 @@ module IntelliAgent::OpenAI
|
|
36
40
|
response
|
37
41
|
end
|
38
42
|
|
39
|
-
def self.vision(prompt:, image_url:, model: :
|
43
|
+
def self.vision(prompt:, image_url:, model: :gpt_advanced, response_format: nil, max_tokens: MAX_TOKENS)
|
40
44
|
model = select_model(model)
|
41
45
|
messages = [{ type: :text, text: prompt },
|
42
46
|
{ type: :image_url, image_url: { url: image_url } }]
|
@@ -51,19 +55,28 @@ module IntelliAgent::OpenAI
|
|
51
55
|
response
|
52
56
|
end
|
53
57
|
|
54
|
-
def self.single_prompt(prompt:, model: :
|
58
|
+
def self.single_prompt(prompt:, model: :gpt_basic, response_format: nil, max_tokens: MAX_TOKENS, tools: nil, function_run_context: self)
|
55
59
|
chat(messages: [{ user: prompt }], model:, response_format:, max_tokens:, tools:, function_run_context:)
|
56
60
|
end
|
57
61
|
|
58
|
-
def self.single_chat(system:, user:, model: :
|
62
|
+
def self.single_chat(system:, user:, model: :gpt_basic, response_format: nil, max_tokens: MAX_TOKENS, tools: nil, function_run_context: nil)
|
59
63
|
chat(messages: [{ system: }, { user: }], model:, response_format:, max_tokens:, tools:, function_run_context:)
|
60
64
|
end
|
61
65
|
|
62
|
-
def self.chat(messages:, model: :
|
66
|
+
def self.chat(messages:, model: :gpt_basic, response_format: nil, max_tokens: MAX_TOKENS, tools: nil, function_run_context: self)
|
63
67
|
model = select_model(model)
|
68
|
+
|
69
|
+
# o1 models doesn't support max_tokens, instead max_completion_tokens
|
70
|
+
is_o1_model = model.start_with?('o1')
|
71
|
+
max_completion_tokens = max_tokens if is_o1_model
|
72
|
+
|
64
73
|
messages = parse_messages(messages)
|
65
74
|
|
66
|
-
parameters = { model:, messages
|
75
|
+
parameters = { model:, messages: }
|
76
|
+
|
77
|
+
parameters[:max_completion_tokens] = max_completion_tokens if is_o1_model
|
78
|
+
parameters[:max_tokens] = max_completion_tokens unless is_o1_model
|
79
|
+
|
67
80
|
parameters[:response_format] = { type: 'json_object' } if response_format.eql?(:json)
|
68
81
|
parameters[:tools] = tools if tools
|
69
82
|
|
@@ -95,10 +108,14 @@ module IntelliAgent::OpenAI
|
|
95
108
|
|
96
109
|
def self.select_model(model)
|
97
110
|
case model
|
98
|
-
when :
|
99
|
-
|
100
|
-
when :
|
101
|
-
|
111
|
+
when :gpt_basic
|
112
|
+
GPT_BASIC_MODEL
|
113
|
+
when :gpt_advanced
|
114
|
+
GPT_ADVANCED_MODEL
|
115
|
+
when :o1_basic
|
116
|
+
O1_BASIC_MODEL
|
117
|
+
when :o1_advanced
|
118
|
+
O1_ADVANCED_MODEL
|
102
119
|
else
|
103
120
|
model
|
104
121
|
end
|
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.
|
4
|
+
version: 0.2.6
|
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-09-
|
11
|
+
date: 2027-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-openai
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
|
-
rubygems_version: 3.5.
|
86
|
+
rubygems_version: 3.5.20
|
87
87
|
signing_key:
|
88
88
|
specification_version: 4
|
89
89
|
summary: A helper layer over Anthropic and OpenAI API
|