activeagent 0.2.6.1 → 0.2.6.2
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/active_agent/generation_provider/open_ai_provider.rb +16 -16
- data/lib/active_agent/version.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: a6a01ce18be361d8f65724b66a94c0a38a124a9fa26770c38bfa111f7061e030
|
4
|
+
data.tar.gz: a4f23ed1313b5a69d02a44f193721b80551e7ca4cc508cdc2634f1bec95ec1a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a4e60fb3ff2bb2436e753ae1a678cc365a7f2975c6618db4836e36b9b804e889aae2270748a906ab6a35edf1701cc17719a6124c2b16e730e77bddfd5fa68bf
|
7
|
+
data.tar.gz: 8168a8048fbb8a62c5f2c680c729ffd83939d96c434ebb4c9406f301435f16a9e8f33f9cf49d2f1150deccbae58e19f1085d362ab45aba28ca8b588b5218bd28
|
@@ -11,7 +11,7 @@ module ActiveAgent
|
|
11
11
|
def initialize(config)
|
12
12
|
super
|
13
13
|
@api_key = config["api_key"]
|
14
|
-
@model_name = config["model"] || "gpt-4o-mini"
|
14
|
+
@model_name = config["model"] || "gpt-4o-mini"
|
15
15
|
@client = OpenAI::Client.new(access_token: @api_key, log_errors: true)
|
16
16
|
end
|
17
17
|
|
@@ -25,7 +25,7 @@ module ActiveAgent
|
|
25
25
|
|
26
26
|
def chat_prompt(parameters: prompt_parameters)
|
27
27
|
parameters[:stream] = provider_stream if prompt.options[:stream] || config["stream"]
|
28
|
-
|
28
|
+
|
29
29
|
chat_response(@client.chat(parameters: parameters))
|
30
30
|
end
|
31
31
|
|
@@ -34,7 +34,7 @@ module ActiveAgent
|
|
34
34
|
|
35
35
|
embeddings_prompt(parameters: embeddings_parameters)
|
36
36
|
rescue => e
|
37
|
-
raise GenerationProviderError, e.message
|
37
|
+
raise GenerationProviderError, e.message
|
38
38
|
end
|
39
39
|
|
40
40
|
def embeddings_parameters(input: prompt.message.content, model: "text-embedding-3-large")
|
@@ -45,12 +45,12 @@ module ActiveAgent
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def embeddings_response(response)
|
48
|
-
message = Message.new(content:response.dig("data", 0, "embedding"), role: "assistant")
|
48
|
+
message = Message.new(content: response.dig("data", 0, "embedding"), role: "assistant")
|
49
49
|
|
50
50
|
@response = ActiveAgent::GenerationProvider::Response.new(prompt: prompt, message: message, raw_response: response)
|
51
51
|
end
|
52
|
-
|
53
|
-
def embeddings_prompt(parameters:
|
52
|
+
|
53
|
+
def embeddings_prompt(parameters:)
|
54
54
|
embeddings_response(@client.embeddings(parameters: embeddings_parameters))
|
55
55
|
end
|
56
56
|
|
@@ -61,13 +61,13 @@ module ActiveAgent
|
|
61
61
|
# config[:stream] will define a proc found in config. stream would come from an Agent class's generate_with or stream_with method calls
|
62
62
|
agent_stream = prompt.options[:stream]
|
63
63
|
message = ActiveAgent::ActionPrompt::Message.new(content: "", role: :assistant)
|
64
|
-
@response = ActiveAgent::GenerationProvider::Response.new(prompt: prompt, message:
|
65
|
-
|
64
|
+
@response = ActiveAgent::GenerationProvider::Response.new(prompt: prompt, message:)
|
65
|
+
|
66
66
|
proc do |chunk, bytesize|
|
67
67
|
if new_content = chunk.dig("choices", 0, "delta", "content")
|
68
68
|
message.content += new_content
|
69
69
|
agent_stream.call(message) if agent_stream.respond_to?(:call)
|
70
|
-
end
|
70
|
+
end
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
@@ -82,17 +82,17 @@ module ActiveAgent
|
|
82
82
|
|
83
83
|
def provider_messages(messages)
|
84
84
|
messages.map do |message|
|
85
|
-
provider_message {
|
86
|
-
role: message.role,
|
85
|
+
provider_message = {
|
86
|
+
role: message.role,
|
87
87
|
tool_call_id: message.action_id.presence,
|
88
88
|
content: message.content,
|
89
89
|
type: message.content_type,
|
90
90
|
charset: message.charset
|
91
|
-
|
91
|
+
}.compact
|
92
92
|
|
93
|
-
|
94
|
-
|
95
|
-
|
93
|
+
if content_type == "image_url"
|
94
|
+
provider_message[:image_url] = {url: content}
|
95
|
+
end
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
@@ -100,7 +100,7 @@ module ActiveAgent
|
|
100
100
|
return @response if prompt.options[:stream]
|
101
101
|
|
102
102
|
message_json = response.dig("choices", 0, "message")
|
103
|
-
|
103
|
+
|
104
104
|
message = ActiveAgent::ActionPrompt::Message.new(
|
105
105
|
content: message_json["content"],
|
106
106
|
role: message_json["role"],
|
data/lib/active_agent/version.rb
CHANGED