intelli_agent 0.1.2 → 0.1.4

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 +27 -21
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5215cbeeb5f66df2815f4259cad370a962e2fc9cb8df39c55af6b1b73531f47b
4
- data.tar.gz: 9d41844c690e1ceb733d099ce73fffaba9efbe53d233abcd91963202ac9ea2fe
3
+ metadata.gz: cb2113329a8f68d1433d8d54846c73eb620818041f617f5140afd00247c53dec
4
+ data.tar.gz: ff64fce4f52a30f3d1289925f92ab30767d4e1ee54f75f96e702f32ae4e5354c
5
5
  SHA512:
6
- metadata.gz: d26c18ba4f481df7f2d1fc6517dc4195e1f59de1ff130795cf94e75d7c721456464566ee743740cd68728f9e62aea4feb655d5da5a020e16016b10341f03ff9d
7
- data.tar.gz: 35aedfcd5871657e690e7bb0dbfc4cf208b766872ed882d18ca6c22f9103b0fc94e70b3889f964908012e09ae0b6472357c29714fbc6e0fda7f6b59fbe8aaf64
6
+ metadata.gz: 784acf6fd048f8f521ebcb4dad4381b48db1e79a32b424d98c790b8abf74ddbf1f3a6b69ae2dffe67dd68a731dda295aa7df627689ba5672837d2be4fe0a0b0e
7
+ data.tar.gz: 4ead6219753043957a4728b8808b57a0829a4954671f06895002ffc47c1087e61124a9c1d37a7328fa203e0a1ad5541570247513f79b8b477518ba704bd4f44d
@@ -16,11 +16,7 @@ module IntelliAgent::OpenAI
16
16
 
17
17
  response = OpenAI::Client.new.chat(parameters:)
18
18
 
19
- if response_format.nil?
20
- response.dig('choices', 0, 'message', 'content').strip
21
- else
22
- response
23
- end
19
+ response.dig('choices', 0, 'message', 'content').strip
24
20
  end
25
21
 
26
22
  def self.vision(prompt:, image_url:, model: :advanced, response_format: nil, max_tokens: MAX_TOKENS)
@@ -32,12 +28,8 @@ module IntelliAgent::OpenAI
32
28
  parameters[:response_format] = { type: 'json_object' } if response_format.eql?(:json)
33
29
 
34
30
  response = OpenAI::Client.new.chat(parameters:)
35
-
36
- if response_format.nil?
37
- response.dig('choices', 0, 'message', 'content').strip
38
- else
39
- response
40
- end
31
+
32
+ response.dig('choices', 0, 'message', 'content').strip
41
33
  end
42
34
 
43
35
  def self.single_chat(system:, user:, model: :basic, response_format: nil, max_tokens: MAX_TOKENS)
@@ -51,25 +43,21 @@ module IntelliAgent::OpenAI
51
43
  parameters[:response_format] = { type: 'json_object' } if response_format.eql?(:json)
52
44
 
53
45
  response = OpenAI::Client.new.chat(parameters:)
54
- if response_format.nil?
55
- response.dig('choices', 0, 'message', 'content').strip
56
- else
57
- response
58
- end
46
+
47
+ response.dig('choices', 0, 'message', 'content').strip
59
48
  end
60
49
 
61
50
  def self.chat(messages:, model: :basic, response_format: nil, max_tokens: MAX_TOKENS)
62
51
  model = select_model(model)
63
52
 
53
+ messages = determine_message_format(messages).eql?(:short_format) ? convert_message_to_standard_format(messages) : messages
54
+
64
55
  parameters = { model:, messages:, max_tokens: }
65
56
  parameters[:response_format] = { type: 'json_object' } if response_format.eql?(:json)
66
57
 
67
58
  response = OpenAI::Client.new.chat(parameters:)
68
- if response_format.nil?
69
- response.dig('choices', 0, 'message', 'content').strip
70
- else
71
- response
72
- end
59
+
60
+ response.dig('choices', 0, 'message', 'content').strip
73
61
  end
74
62
 
75
63
  def self.models = OpenAI::Client.new.models.list
@@ -84,4 +72,22 @@ module IntelliAgent::OpenAI
84
72
  model
85
73
  end
86
74
  end
75
+
76
+ def self.determine_message_format(messages)
77
+ case messages
78
+ in [{ role: String, content: String }, *]
79
+ :standard_format
80
+ in [{ system: String }, { user: String }, *]
81
+ :short_format
82
+ else
83
+ :unknown_format
84
+ end
85
+ end
86
+
87
+ def self.convert_message_to_standard_format(messages)
88
+ messages.map do |msg|
89
+ role, content = msg.first
90
+ { role: role.to_s, content: content }
91
+ end
92
+ end
87
93
  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.1.2
4
+ version: 0.1.4
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-27 00:00:00.000000000 Z
11
+ date: 2027-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-openai