intelli_agent 0.0.2 → 0.0.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.
- checksums.yaml +4 -4
- data/lib/intelli_agent/ai.rb +9 -9
- data/lib/intelli_agent.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55a857044336782f57062c01ab7f1bed094698d47cf5c118d2e883f01c56134d
|
4
|
+
data.tar.gz: '098ef34bea5cfaa036ea484056d37f12cf849914c3593ad951f895e0113a1ff6'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 201c21f58d7c5060ed8ac4a4dfd28349a6a1d0e61569eb9e7130d42572c299394668a7a3dc8b4b3b3af340e9ef77b6bbb4f315c563509434ceafc5fd86011b3b
|
7
|
+
data.tar.gz: f476bd10218da6111030b878793eb908070e3c3cff77f63c6b8082f9ac67486de83d3c7ef732dd5713a87b5633db0170fb90ab8b716aca149104e8c60a5b93ec
|
data/lib/intelli_agent/ai.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# In the future, this became a bus to more than one AI provider
|
2
2
|
module AI
|
3
|
-
BASIC_MODEL = ENV.fetch('OPENAI_BASIC_MODEL')
|
4
|
-
ADVANCED_MODEL = ENV.fetch('OPENAI_ADVANCED_MODEL')
|
3
|
+
BASIC_MODEL = 'gpt-4o-mini' # ENV.fetch('OPENAI_BASIC_MODEL')
|
4
|
+
ADVANCED_MODEL = 'gpt-4o' # ENV.fetch('OPENAI_ADVANCED_MODEL')
|
5
5
|
|
6
|
-
def
|
6
|
+
def embed(input, model: 'text-embedding-3-large')
|
7
7
|
response = OpenAI::Client.new.embeddings(parameters: { input:, model: })
|
8
8
|
response.dig('data', 0, 'embedding')
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
11
|
+
def single_prompt(prompt:, model: AI::BASIC_MODEL, response_format: nil)
|
12
12
|
parameters = { model:, messages: [{ role: 'user', content: prompt }] }
|
13
13
|
|
14
14
|
parameters[:response_format] = { type: 'json_object' } if response_format.eql?(:json)
|
@@ -17,11 +17,11 @@ module AI
|
|
17
17
|
response.dig('choices', 0, 'message', 'content').strip
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
20
|
+
def vision(prompt:, image_url:, model: AI::BASIC_MODEL, response_format: nil)
|
21
21
|
messages = [{ type: :text, text: prompt },
|
22
22
|
{ type: :image_url, image_url: { url: image_url } }]
|
23
23
|
|
24
|
-
parameters = { model:
|
24
|
+
parameters = { model: model, messages: [{ role: :user, content: messages }] }
|
25
25
|
parameters[:response_format] = { type: 'json_object' } if response_format.eql?(:json)
|
26
26
|
|
27
27
|
response = OpenAI::Client.new.chat(parameters:)
|
@@ -29,7 +29,7 @@ module AI
|
|
29
29
|
response.dig('choices', 0, 'message', 'content').strip
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
32
|
+
def single_chat(system:, user:, model: AI::BASIC_MODEL, response_format: nil)
|
33
33
|
parameters = { model:,
|
34
34
|
messages: [
|
35
35
|
{ role: 'system', content: system },
|
@@ -42,7 +42,7 @@ module AI
|
|
42
42
|
response.dig('choices', 0, 'message', 'content').strip
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
45
|
+
def chat(messages, model: AI::BASIC_MODEL, response_format: nil)
|
46
46
|
parameters = { model:, messages: }
|
47
47
|
parameters[:response_format] = { type: 'json_object' } if response_format.eql?(:json)
|
48
48
|
|
@@ -50,7 +50,7 @@ module AI
|
|
50
50
|
response.dig('choices', 0, 'message', 'content').strip
|
51
51
|
end
|
52
52
|
|
53
|
-
def
|
53
|
+
def models
|
54
54
|
OpenAI::Client.new.models.list
|
55
55
|
end
|
56
56
|
end
|
data/lib/intelli_agent.rb
CHANGED