intelli_agent 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/intelli_agent/openai.rb +23 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c76bcdd7573088ad3dcc72e5737a72b4bd352c1568c05d849f01007e409d5a09
|
4
|
+
data.tar.gz: 4c84207e8e0a56741825b4a8d8b37ffd8ac9be22025b17b100bca4c2872b0bf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be84356ca55dcae68905bbd3b6547b764499406429b980c21acf48d2dc175433c47e85a51728f6b73194c0c7907db0e8d004dda6030966f5c84d4aecb040de12
|
7
|
+
data.tar.gz: 254c5b1c8db19b4b75278813f3a7faae286ec9bc7d1930b2b973cc5b7a0c867c88bac74f9ba7d0abd87fa6e0c206617a537c242681335177d5c6abb0aaeec021
|
data/lib/intelli_agent/openai.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# In the future, this became a bus to more than one AI provider
|
2
2
|
module IntelliAgent::OpenAI
|
3
|
-
BASIC_MODEL = 'gpt-4o-mini'
|
4
|
-
ADVANCED_MODEL =
|
3
|
+
BASIC_MODEL = ENV.fetch('OPENAI_BASIC_MODEL', 'gpt-4o-mini')
|
4
|
+
ADVANCED_MODEL = ENV.fetch('OPENAI_ADVANCED_MODEL', 'gpt-4o-2024-08-06')
|
5
5
|
|
6
6
|
def self.embed(input, model: 'text-embedding-3-large')
|
7
7
|
response = OpenAI::Client.new.embeddings(parameters: { input:, model: })
|
@@ -16,7 +16,12 @@ module IntelliAgent::OpenAI
|
|
16
16
|
parameters[:response_format] = { type: 'json_object' } if response_format.eql?(:json)
|
17
17
|
|
18
18
|
response = OpenAI::Client.new.chat(parameters:)
|
19
|
-
|
19
|
+
|
20
|
+
if response_format.nil?
|
21
|
+
response.dig('choices', 0, 'message', 'content').strip
|
22
|
+
else
|
23
|
+
response
|
24
|
+
end
|
20
25
|
end
|
21
26
|
|
22
27
|
def self.vision(prompt:, image_url:, model: :advanced, response_format: nil)
|
@@ -29,7 +34,11 @@ module IntelliAgent::OpenAI
|
|
29
34
|
|
30
35
|
response = OpenAI::Client.new.chat(parameters:)
|
31
36
|
|
32
|
-
|
37
|
+
if response_format.nil?
|
38
|
+
response.dig('choices', 0, 'message', 'content').strip
|
39
|
+
else
|
40
|
+
response
|
41
|
+
end
|
33
42
|
end
|
34
43
|
|
35
44
|
def self.single_chat(system:, user:, model: :basic, response_format: nil)
|
@@ -43,7 +52,11 @@ module IntelliAgent::OpenAI
|
|
43
52
|
parameters[:response_format] = { type: 'json_object' } if response_format.eql?(:json)
|
44
53
|
|
45
54
|
response = OpenAI::Client.new.chat(parameters:)
|
46
|
-
|
55
|
+
if response_format.nil?
|
56
|
+
response.dig('choices', 0, 'message', 'content').strip
|
57
|
+
else
|
58
|
+
response
|
59
|
+
end
|
47
60
|
end
|
48
61
|
|
49
62
|
def self.chat(messages:, model: :basic, response_format: nil)
|
@@ -52,7 +65,11 @@ module IntelliAgent::OpenAI
|
|
52
65
|
parameters[:response_format] = { type: 'json_object' } if response_format.eql?(:json)
|
53
66
|
|
54
67
|
response = OpenAI::Client.new.chat(parameters:)
|
55
|
-
|
68
|
+
if response_format.nil?
|
69
|
+
response.dig('choices', 0, 'message', 'content').strip
|
70
|
+
else
|
71
|
+
response
|
72
|
+
end
|
56
73
|
end
|
57
74
|
|
58
75
|
def self.models = OpenAI::Client.new.models.list
|
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.1.
|
4
|
+
version: 0.1.1
|
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-08-
|
11
|
+
date: 2027-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-openai
|