activeagent 1.0.0.rc1 → 1.0.0
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/CHANGELOG.md +31 -1
- data/lib/active_agent/providers/_base_provider.rb +92 -82
- data/lib/active_agent/providers/anthropic/_types.rb +2 -2
- data/lib/active_agent/providers/anthropic/request.rb +135 -81
- data/lib/active_agent/providers/anthropic/transforms.rb +353 -0
- data/lib/active_agent/providers/anthropic_provider.rb +96 -53
- data/lib/active_agent/providers/common/messages/_types.rb +37 -1
- data/lib/active_agent/providers/common/responses/base.rb +118 -70
- data/lib/active_agent/providers/common/usage.rb +385 -0
- data/lib/active_agent/providers/concerns/instrumentation.rb +263 -0
- data/lib/active_agent/providers/log_subscriber.rb +64 -246
- data/lib/active_agent/providers/mock_provider.rb +23 -23
- data/lib/active_agent/providers/ollama/chat/request.rb +214 -35
- data/lib/active_agent/providers/ollama/chat/transforms.rb +135 -0
- data/lib/active_agent/providers/ollama/embedding/request.rb +160 -47
- data/lib/active_agent/providers/ollama/embedding/transforms.rb +160 -0
- data/lib/active_agent/providers/ollama_provider.rb +0 -1
- data/lib/active_agent/providers/open_ai/_base.rb +3 -2
- data/lib/active_agent/providers/open_ai/chat/_types.rb +13 -1
- data/lib/active_agent/providers/open_ai/chat/request.rb +132 -186
- data/lib/active_agent/providers/open_ai/chat/transforms.rb +364 -0
- data/lib/active_agent/providers/open_ai/chat_provider.rb +57 -36
- data/lib/active_agent/providers/open_ai/embedding/_types.rb +13 -2
- data/lib/active_agent/providers/open_ai/embedding/request.rb +38 -70
- data/lib/active_agent/providers/open_ai/embedding/transforms.rb +88 -0
- data/lib/active_agent/providers/open_ai/responses/_types.rb +1 -7
- data/lib/active_agent/providers/open_ai/responses/request.rb +100 -134
- data/lib/active_agent/providers/open_ai/responses/transforms.rb +228 -0
- data/lib/active_agent/providers/open_ai/responses_provider.rb +77 -30
- data/lib/active_agent/providers/open_ai_provider.rb +0 -3
- data/lib/active_agent/providers/open_router/_types.rb +27 -1
- data/lib/active_agent/providers/open_router/options.rb +49 -1
- data/lib/active_agent/providers/open_router/request.rb +232 -66
- data/lib/active_agent/providers/open_router/requests/_types.rb +0 -1
- data/lib/active_agent/providers/open_router/requests/messages/_types.rb +37 -40
- data/lib/active_agent/providers/open_router/requests/messages/content/file.rb +19 -3
- data/lib/active_agent/providers/open_router/requests/messages/content/files/details.rb +15 -4
- data/lib/active_agent/providers/open_router/requests/plugin.rb +19 -3
- data/lib/active_agent/providers/open_router/requests/plugins/pdf_config.rb +30 -8
- data/lib/active_agent/providers/open_router/requests/prediction.rb +17 -0
- data/lib/active_agent/providers/open_router/requests/provider_preferences/max_price.rb +41 -7
- data/lib/active_agent/providers/open_router/requests/provider_preferences.rb +60 -19
- data/lib/active_agent/providers/open_router/requests/response_format.rb +30 -2
- data/lib/active_agent/providers/open_router/transforms.rb +134 -0
- data/lib/active_agent/providers/open_router_provider.rb +9 -0
- data/lib/active_agent/version.rb +1 -1
- metadata +15 -159
- data/lib/active_agent/generation_provider/open_router/types.rb +0 -505
- data/lib/active_agent/generation_provider/xai_provider.rb +0 -144
- data/lib/active_agent/providers/anthropic/requests/_types.rb +0 -190
- data/lib/active_agent/providers/anthropic/requests/container_params.rb +0 -19
- data/lib/active_agent/providers/anthropic/requests/content/base.rb +0 -21
- data/lib/active_agent/providers/anthropic/requests/content/sources/base.rb +0 -22
- data/lib/active_agent/providers/anthropic/requests/context_management_config.rb +0 -18
- data/lib/active_agent/providers/anthropic/requests/messages/_types.rb +0 -189
- data/lib/active_agent/providers/anthropic/requests/messages/assistant.rb +0 -23
- data/lib/active_agent/providers/anthropic/requests/messages/base.rb +0 -63
- data/lib/active_agent/providers/anthropic/requests/messages/content/_types.rb +0 -143
- data/lib/active_agent/providers/anthropic/requests/messages/content/base.rb +0 -21
- data/lib/active_agent/providers/anthropic/requests/messages/content/document.rb +0 -26
- data/lib/active_agent/providers/anthropic/requests/messages/content/image.rb +0 -23
- data/lib/active_agent/providers/anthropic/requests/messages/content/redacted_thinking.rb +0 -21
- data/lib/active_agent/providers/anthropic/requests/messages/content/search_result.rb +0 -27
- data/lib/active_agent/providers/anthropic/requests/messages/content/sources/_types.rb +0 -171
- data/lib/active_agent/providers/anthropic/requests/messages/content/sources/base.rb +0 -22
- data/lib/active_agent/providers/anthropic/requests/messages/content/sources/document_base64.rb +0 -25
- data/lib/active_agent/providers/anthropic/requests/messages/content/sources/document_file.rb +0 -23
- data/lib/active_agent/providers/anthropic/requests/messages/content/sources/document_text.rb +0 -25
- data/lib/active_agent/providers/anthropic/requests/messages/content/sources/document_url.rb +0 -23
- data/lib/active_agent/providers/anthropic/requests/messages/content/sources/image_base64.rb +0 -27
- data/lib/active_agent/providers/anthropic/requests/messages/content/sources/image_file.rb +0 -23
- data/lib/active_agent/providers/anthropic/requests/messages/content/sources/image_url.rb +0 -23
- data/lib/active_agent/providers/anthropic/requests/messages/content/text.rb +0 -22
- data/lib/active_agent/providers/anthropic/requests/messages/content/thinking.rb +0 -23
- data/lib/active_agent/providers/anthropic/requests/messages/content/tool_result.rb +0 -24
- data/lib/active_agent/providers/anthropic/requests/messages/content/tool_use.rb +0 -28
- data/lib/active_agent/providers/anthropic/requests/messages/user.rb +0 -21
- data/lib/active_agent/providers/anthropic/requests/metadata.rb +0 -18
- data/lib/active_agent/providers/anthropic/requests/response_format.rb +0 -22
- data/lib/active_agent/providers/anthropic/requests/thinking_config/_types.rb +0 -60
- data/lib/active_agent/providers/anthropic/requests/thinking_config/base.rb +0 -20
- data/lib/active_agent/providers/anthropic/requests/thinking_config/disabled.rb +0 -16
- data/lib/active_agent/providers/anthropic/requests/thinking_config/enabled.rb +0 -20
- data/lib/active_agent/providers/anthropic/requests/tool_choice/_types.rb +0 -78
- data/lib/active_agent/providers/anthropic/requests/tool_choice/any.rb +0 -17
- data/lib/active_agent/providers/anthropic/requests/tool_choice/auto.rb +0 -17
- data/lib/active_agent/providers/anthropic/requests/tool_choice/base.rb +0 -20
- data/lib/active_agent/providers/anthropic/requests/tool_choice/none.rb +0 -16
- data/lib/active_agent/providers/anthropic/requests/tool_choice/tool.rb +0 -20
- data/lib/active_agent/providers/ollama/chat/requests/_types.rb +0 -3
- data/lib/active_agent/providers/ollama/chat/requests/messages/_types.rb +0 -116
- data/lib/active_agent/providers/ollama/chat/requests/messages/assistant.rb +0 -19
- data/lib/active_agent/providers/ollama/chat/requests/messages/user.rb +0 -19
- data/lib/active_agent/providers/ollama/embedding/requests/_types.rb +0 -83
- data/lib/active_agent/providers/ollama/embedding/requests/options.rb +0 -104
- data/lib/active_agent/providers/open_ai/chat/requests/_types.rb +0 -229
- data/lib/active_agent/providers/open_ai/chat/requests/audio.rb +0 -24
- data/lib/active_agent/providers/open_ai/chat/requests/messages/_types.rb +0 -123
- data/lib/active_agent/providers/open_ai/chat/requests/messages/assistant.rb +0 -42
- data/lib/active_agent/providers/open_ai/chat/requests/messages/base.rb +0 -78
- data/lib/active_agent/providers/open_ai/chat/requests/messages/content/_types.rb +0 -133
- data/lib/active_agent/providers/open_ai/chat/requests/messages/content/audio.rb +0 -35
- data/lib/active_agent/providers/open_ai/chat/requests/messages/content/base.rb +0 -24
- data/lib/active_agent/providers/open_ai/chat/requests/messages/content/file.rb +0 -26
- data/lib/active_agent/providers/open_ai/chat/requests/messages/content/files/_types.rb +0 -60
- data/lib/active_agent/providers/open_ai/chat/requests/messages/content/files/details.rb +0 -41
- data/lib/active_agent/providers/open_ai/chat/requests/messages/content/image.rb +0 -37
- data/lib/active_agent/providers/open_ai/chat/requests/messages/content/refusal.rb +0 -25
- data/lib/active_agent/providers/open_ai/chat/requests/messages/content/text.rb +0 -25
- data/lib/active_agent/providers/open_ai/chat/requests/messages/developer.rb +0 -25
- data/lib/active_agent/providers/open_ai/chat/requests/messages/function.rb +0 -25
- data/lib/active_agent/providers/open_ai/chat/requests/messages/system.rb +0 -25
- data/lib/active_agent/providers/open_ai/chat/requests/messages/tool.rb +0 -26
- data/lib/active_agent/providers/open_ai/chat/requests/messages/user.rb +0 -32
- data/lib/active_agent/providers/open_ai/chat/requests/prediction.rb +0 -46
- data/lib/active_agent/providers/open_ai/chat/requests/response_format.rb +0 -53
- data/lib/active_agent/providers/open_ai/chat/requests/stream_options.rb +0 -24
- data/lib/active_agent/providers/open_ai/chat/requests/tool_choice.rb +0 -26
- data/lib/active_agent/providers/open_ai/chat/requests/tools/_types.rb +0 -5
- data/lib/active_agent/providers/open_ai/chat/requests/tools/base.rb +0 -22
- data/lib/active_agent/providers/open_ai/chat/requests/tools/custom_tool.rb +0 -41
- data/lib/active_agent/providers/open_ai/chat/requests/tools/function_tool.rb +0 -51
- data/lib/active_agent/providers/open_ai/chat/requests/web_search_options.rb +0 -45
- data/lib/active_agent/providers/open_ai/embedding/requests/_types.rb +0 -49
- data/lib/active_agent/providers/open_ai/responses/requests/_types.rb +0 -231
- data/lib/active_agent/providers/open_ai/responses/requests/conversation.rb +0 -23
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/_types.rb +0 -264
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/assistant_message.rb +0 -22
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/base.rb +0 -89
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/code_interpreter_tool_call.rb +0 -30
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/computer_tool_call.rb +0 -28
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/computer_tool_call_output.rb +0 -33
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/_types.rb +0 -207
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/base.rb +0 -22
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/input_audio.rb +0 -26
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/input_file.rb +0 -28
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/input_image.rb +0 -28
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/input_text.rb +0 -25
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/custom_tool_call.rb +0 -28
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/custom_tool_call_output.rb +0 -27
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/developer_message.rb +0 -20
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/file_search_tool_call.rb +0 -25
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/function_call_output.rb +0 -32
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/function_tool_call.rb +0 -28
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/image_gen_tool_call.rb +0 -27
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/input_message.rb +0 -31
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/item_reference.rb +0 -23
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/local_shell_tool_call.rb +0 -26
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/local_shell_tool_call_output.rb +0 -33
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/mcp_approval_request.rb +0 -30
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/mcp_approval_response.rb +0 -28
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/mcp_list_tools.rb +0 -29
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/mcp_tool_call.rb +0 -35
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/output_message.rb +0 -35
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/reasoning.rb +0 -33
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/system_message.rb +0 -20
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/tool_call_base.rb +0 -27
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/tool_message.rb +0 -23
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/user_message.rb +0 -20
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/web_search_tool_call.rb +0 -24
- data/lib/active_agent/providers/open_ai/responses/requests/prompt_reference.rb +0 -23
- data/lib/active_agent/providers/open_ai/responses/requests/reasoning.rb +0 -23
- data/lib/active_agent/providers/open_ai/responses/requests/stream_options.rb +0 -20
- data/lib/active_agent/providers/open_ai/responses/requests/text/_types.rb +0 -89
- data/lib/active_agent/providers/open_ai/responses/requests/text/base.rb +0 -22
- data/lib/active_agent/providers/open_ai/responses/requests/text/json_object.rb +0 -20
- data/lib/active_agent/providers/open_ai/responses/requests/text/json_schema.rb +0 -48
- data/lib/active_agent/providers/open_ai/responses/requests/text/plain.rb +0 -20
- data/lib/active_agent/providers/open_ai/responses/requests/text.rb +0 -41
- data/lib/active_agent/providers/open_ai/responses/requests/tool_choice.rb +0 -26
- data/lib/active_agent/providers/open_ai/responses/requests/tools/_types.rb +0 -112
- data/lib/active_agent/providers/open_ai/responses/requests/tools/base.rb +0 -25
- data/lib/active_agent/providers/open_ai/responses/requests/tools/code_interpreter_tool.rb +0 -23
- data/lib/active_agent/providers/open_ai/responses/requests/tools/computer_tool.rb +0 -27
- data/lib/active_agent/providers/open_ai/responses/requests/tools/custom_tool.rb +0 -28
- data/lib/active_agent/providers/open_ai/responses/requests/tools/file_search_tool.rb +0 -27
- data/lib/active_agent/providers/open_ai/responses/requests/tools/function_tool.rb +0 -29
- data/lib/active_agent/providers/open_ai/responses/requests/tools/image_generation_tool.rb +0 -37
- data/lib/active_agent/providers/open_ai/responses/requests/tools/local_shell_tool.rb +0 -21
- data/lib/active_agent/providers/open_ai/responses/requests/tools/mcp_tool.rb +0 -41
- data/lib/active_agent/providers/open_ai/responses/requests/tools/web_search_preview_tool.rb +0 -24
- data/lib/active_agent/providers/open_ai/responses/requests/tools/web_search_tool.rb +0 -25
- data/lib/active_agent/providers/open_ai/schema.yml +0 -65937
- data/lib/active_agent/providers/open_router/requests/message.rb +0 -1
- data/lib/active_agent/providers/open_router/requests/messages/assistant.rb +0 -20
- data/lib/active_agent/providers/open_router/requests/messages/user.rb +0 -30
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "tool_call_base"
|
|
4
|
-
|
|
5
|
-
module ActiveAgent
|
|
6
|
-
module Providers
|
|
7
|
-
module OpenAI
|
|
8
|
-
module Responses
|
|
9
|
-
module Requests
|
|
10
|
-
module Inputs
|
|
11
|
-
# Computer tool call - computer use tool
|
|
12
|
-
class ComputerToolCall < ToolCallBase
|
|
13
|
-
attribute :type, :string, as: "computer_call"
|
|
14
|
-
attribute :call_id, :string
|
|
15
|
-
attribute :action # ComputerAction object
|
|
16
|
-
attribute :pending_safety_checks # Always an array of safety check objects
|
|
17
|
-
|
|
18
|
-
validates :type, inclusion: { in: %w[computer_call], allow_nil: false }
|
|
19
|
-
validates :call_id, presence: true
|
|
20
|
-
validates :action, presence: true
|
|
21
|
-
validates :pending_safety_checks, presence: true
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
data/lib/active_agent/providers/open_ai/responses/requests/inputs/computer_tool_call_output.rb
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "base"
|
|
4
|
-
|
|
5
|
-
module ActiveAgent
|
|
6
|
-
module Providers
|
|
7
|
-
module OpenAI
|
|
8
|
-
module Responses
|
|
9
|
-
module Requests
|
|
10
|
-
module Inputs
|
|
11
|
-
# Computer tool call output
|
|
12
|
-
class ComputerToolCallOutput < Base
|
|
13
|
-
attribute :type, :string, as: "computer_call_output"
|
|
14
|
-
attribute :id, :string
|
|
15
|
-
attribute :call_id, :string
|
|
16
|
-
attribute :acknowledged_safety_checks # Always an array of safety check objects
|
|
17
|
-
attribute :output # ComputerScreenshotImage object
|
|
18
|
-
attribute :status, :string
|
|
19
|
-
|
|
20
|
-
validates :type, inclusion: { in: %w[computer_call_output], allow_nil: false }
|
|
21
|
-
validates :call_id, presence: true
|
|
22
|
-
validates :output, presence: true
|
|
23
|
-
validates :status, inclusion: {
|
|
24
|
-
in: %w[in_progress completed incomplete],
|
|
25
|
-
allow_nil: true
|
|
26
|
-
}
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "base"
|
|
4
|
-
require_relative "input_audio"
|
|
5
|
-
require_relative "input_file"
|
|
6
|
-
require_relative "input_image"
|
|
7
|
-
require_relative "input_text"
|
|
8
|
-
|
|
9
|
-
module ActiveAgent
|
|
10
|
-
module Providers
|
|
11
|
-
module OpenAI
|
|
12
|
-
module Responses
|
|
13
|
-
module Requests
|
|
14
|
-
module Inputs
|
|
15
|
-
module Content
|
|
16
|
-
# Type for handling content (string or array of content parts)
|
|
17
|
-
class ContentsType < ActiveModel::Type::Value
|
|
18
|
-
def initialize
|
|
19
|
-
super
|
|
20
|
-
@content_type = ContentType.new
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def cast(value)
|
|
24
|
-
case value
|
|
25
|
-
when String
|
|
26
|
-
# Plain text string - keep as string
|
|
27
|
-
value
|
|
28
|
-
when Array
|
|
29
|
-
# Array of content parts - cast each part
|
|
30
|
-
value.map { |part| @content_type.cast(part) }
|
|
31
|
-
when nil
|
|
32
|
-
nil
|
|
33
|
-
else
|
|
34
|
-
raise ArgumentError, "Cannot cast #{value.class} to Contents (expected String, Array, or nil)"
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def serialize(value)
|
|
39
|
-
case value
|
|
40
|
-
when String
|
|
41
|
-
value
|
|
42
|
-
when Array
|
|
43
|
-
value.map { |part| @content_type.serialize(part) }
|
|
44
|
-
when nil
|
|
45
|
-
nil
|
|
46
|
-
else
|
|
47
|
-
raise ArgumentError, "Cannot serialize #{value.class} as Contents"
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def deserialize(value)
|
|
52
|
-
cast(value)
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
# Type for individual content items
|
|
57
|
-
class ContentType < ActiveModel::Type::Value
|
|
58
|
-
def cast(value)
|
|
59
|
-
case value
|
|
60
|
-
when Base
|
|
61
|
-
value
|
|
62
|
-
when Hash
|
|
63
|
-
hash = value.deep_symbolize_keys
|
|
64
|
-
type = hash[:type]&.to_sym
|
|
65
|
-
|
|
66
|
-
case type
|
|
67
|
-
when :input_text, :output_text
|
|
68
|
-
InputText.new(**hash.except(:annotations, :logprobs, :type))
|
|
69
|
-
when :input_image
|
|
70
|
-
InputImage.new(**hash)
|
|
71
|
-
when :input_file
|
|
72
|
-
InputFile.new(**hash)
|
|
73
|
-
when nil
|
|
74
|
-
# When type is nil, check for specific content keys to infer type
|
|
75
|
-
if hash.key?(:text)
|
|
76
|
-
InputText.new(**hash)
|
|
77
|
-
elsif hash.key?(:image)
|
|
78
|
-
InputImage.new(**hash.merge(image_url: hash.delete(:image)))
|
|
79
|
-
elsif hash.key?(:document)
|
|
80
|
-
cast_document_to_file(hash)
|
|
81
|
-
else
|
|
82
|
-
raise ArgumentError, "Cannot determine content type from hash keys: #{hash.keys.inspect}"
|
|
83
|
-
end
|
|
84
|
-
else
|
|
85
|
-
raise ArgumentError, "Unknown content type: #{type.inspect}"
|
|
86
|
-
end
|
|
87
|
-
when String
|
|
88
|
-
# Plain text string becomes input_text
|
|
89
|
-
InputText.new(text: value)
|
|
90
|
-
when nil
|
|
91
|
-
nil
|
|
92
|
-
else
|
|
93
|
-
raise ArgumentError, "Cannot cast #{value.class} to Content (expected Base, Hash, String, or nil)"
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
def serialize(value)
|
|
98
|
-
case value
|
|
99
|
-
when Base
|
|
100
|
-
value.serialize
|
|
101
|
-
when Hash
|
|
102
|
-
value
|
|
103
|
-
when String
|
|
104
|
-
{ type: "input_text", text: value }
|
|
105
|
-
when nil
|
|
106
|
-
nil
|
|
107
|
-
else
|
|
108
|
-
raise ArgumentError, "Cannot serialize #{value.class} as Content"
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
def deserialize(value)
|
|
113
|
-
cast(value)
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
private
|
|
117
|
-
|
|
118
|
-
def cast_document_to_file(hash)
|
|
119
|
-
document_value = hash.delete(:document)
|
|
120
|
-
|
|
121
|
-
case document_value
|
|
122
|
-
when String
|
|
123
|
-
if uri?(document_value)
|
|
124
|
-
# It's a URI/URL (http/https)
|
|
125
|
-
InputFile.new(**hash.merge(file_url: document_value))
|
|
126
|
-
elsif data_uri?(document_value)
|
|
127
|
-
# It's a data URI (e.g., data:application/pdf;base64,...)
|
|
128
|
-
# NOTE: While the OpenAI docs say filename is optional, it is required with base64 format
|
|
129
|
-
media_type, _data = parse_data_uri(document_value)
|
|
130
|
-
filename = generate_filename_from_media_type(media_type)
|
|
131
|
-
InputFile.new(**hash.merge(file_data: document_value, filename: filename))
|
|
132
|
-
else
|
|
133
|
-
raise ArgumentError, "Cannot determine source type for document value: #{document_value.inspect}"
|
|
134
|
-
end
|
|
135
|
-
else
|
|
136
|
-
raise ArgumentError, "Expected String for document key, got #{document_value.class}"
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
def uri?(value)
|
|
141
|
-
# Check if it looks like a URI (http://, https://, etc.)
|
|
142
|
-
value.match?(%r{\A(https?)://}i)
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
def data_uri?(value)
|
|
146
|
-
# Check if it's a data URI (data:...)
|
|
147
|
-
value.match?(/\Adata:/i)
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
def parse_data_uri(data_uri)
|
|
151
|
-
# Parse data URI format: data:mime/type;base64,encoded_data
|
|
152
|
-
match = data_uri.match(/\Adata:([^;,]+)(;base64)?,(.+)\z/i)
|
|
153
|
-
raise ArgumentError, "Invalid data URI format: #{data_uri[0..50]}..." unless match
|
|
154
|
-
|
|
155
|
-
media_type = match[1]
|
|
156
|
-
is_base64 = !match[2].nil?
|
|
157
|
-
data = match[3]
|
|
158
|
-
|
|
159
|
-
unless is_base64
|
|
160
|
-
raise ArgumentError, "Only base64-encoded data URIs are supported: #{data_uri[0..50]}..."
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
[ media_type, data ]
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
def generate_filename_from_media_type(media_type)
|
|
167
|
-
# Map common media types to file extensions
|
|
168
|
-
extension = case media_type
|
|
169
|
-
when "application/pdf"
|
|
170
|
-
"pdf"
|
|
171
|
-
when "application/msword"
|
|
172
|
-
"doc"
|
|
173
|
-
when "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
|
174
|
-
"docx"
|
|
175
|
-
when "application/vnd.ms-excel"
|
|
176
|
-
"xls"
|
|
177
|
-
when "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
178
|
-
"xlsx"
|
|
179
|
-
when "application/vnd.ms-powerpoint"
|
|
180
|
-
"ppt"
|
|
181
|
-
when "application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
|
182
|
-
"pptx"
|
|
183
|
-
when "text/plain"
|
|
184
|
-
"txt"
|
|
185
|
-
when "text/csv"
|
|
186
|
-
"csv"
|
|
187
|
-
when "text/html"
|
|
188
|
-
"html"
|
|
189
|
-
when "application/json"
|
|
190
|
-
"json"
|
|
191
|
-
when "application/xml", "text/xml"
|
|
192
|
-
"xml"
|
|
193
|
-
else
|
|
194
|
-
# Try to extract extension from media type (e.g., "application/xyz" -> "xyz")
|
|
195
|
-
media_type.split("/").last.split("+").first
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
"document.#{extension}"
|
|
199
|
-
end
|
|
200
|
-
end
|
|
201
|
-
end
|
|
202
|
-
end
|
|
203
|
-
end
|
|
204
|
-
end
|
|
205
|
-
end
|
|
206
|
-
end
|
|
207
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "active_agent/providers/common/model"
|
|
4
|
-
|
|
5
|
-
module ActiveAgent
|
|
6
|
-
module Providers
|
|
7
|
-
module OpenAI
|
|
8
|
-
module Responses
|
|
9
|
-
module Requests
|
|
10
|
-
module Inputs
|
|
11
|
-
module Content
|
|
12
|
-
# Base class for content parts
|
|
13
|
-
class Base < Common::BaseModel
|
|
14
|
-
attribute :type, :string
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "base"
|
|
4
|
-
|
|
5
|
-
module ActiveAgent
|
|
6
|
-
module Providers
|
|
7
|
-
module OpenAI
|
|
8
|
-
module Responses
|
|
9
|
-
module Requests
|
|
10
|
-
module Inputs
|
|
11
|
-
module Content
|
|
12
|
-
# Audio content part
|
|
13
|
-
class InputAudio < Base
|
|
14
|
-
attribute :type, :string, as: "input_audio"
|
|
15
|
-
attribute :input_audio # Object containing audio properties
|
|
16
|
-
|
|
17
|
-
validates :type, presence: true
|
|
18
|
-
validates :input_audio, presence: true
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "base"
|
|
4
|
-
|
|
5
|
-
module ActiveAgent
|
|
6
|
-
module Providers
|
|
7
|
-
module OpenAI
|
|
8
|
-
module Responses
|
|
9
|
-
module Requests
|
|
10
|
-
module Inputs
|
|
11
|
-
module Content
|
|
12
|
-
# File content part
|
|
13
|
-
class InputFile < Base
|
|
14
|
-
attribute :type, :string, as: "input_file"
|
|
15
|
-
attribute :file_data, :string # Optional: content of file to send
|
|
16
|
-
attribute :file_id, :string # Optional: ID of file to send
|
|
17
|
-
attribute :file_url, :string # Optional: URL of file to send
|
|
18
|
-
attribute :filename, :string # Optional: name of file
|
|
19
|
-
|
|
20
|
-
validates :type, presence: true
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "base"
|
|
4
|
-
|
|
5
|
-
module ActiveAgent
|
|
6
|
-
module Providers
|
|
7
|
-
module OpenAI
|
|
8
|
-
module Responses
|
|
9
|
-
module Requests
|
|
10
|
-
module Inputs
|
|
11
|
-
module Content
|
|
12
|
-
# Image content part
|
|
13
|
-
class InputImage < Base
|
|
14
|
-
attribute :type, :string, as: "input_image"
|
|
15
|
-
attribute :detail, :string, default: "auto" # One of: high, low, auto
|
|
16
|
-
attribute :file_id, :string # Optional: ID of file to send
|
|
17
|
-
attribute :image_url, :string # Optional: URL or base64 data URL
|
|
18
|
-
|
|
19
|
-
validates :type, presence: true
|
|
20
|
-
validates :detail, presence: true
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "base"
|
|
4
|
-
|
|
5
|
-
module ActiveAgent
|
|
6
|
-
module Providers
|
|
7
|
-
module OpenAI
|
|
8
|
-
module Responses
|
|
9
|
-
module Requests
|
|
10
|
-
module Inputs
|
|
11
|
-
module Content
|
|
12
|
-
# Text content part
|
|
13
|
-
class InputText < Base
|
|
14
|
-
attribute :type, :string, as: "input_text"
|
|
15
|
-
attribute :text, :string
|
|
16
|
-
|
|
17
|
-
validates :text, presence: true
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "tool_call_base"
|
|
4
|
-
|
|
5
|
-
module ActiveAgent
|
|
6
|
-
module Providers
|
|
7
|
-
module OpenAI
|
|
8
|
-
module Responses
|
|
9
|
-
module Requests
|
|
10
|
-
module Inputs
|
|
11
|
-
# Custom tool call - call to custom tool
|
|
12
|
-
class CustomToolCall < ToolCallBase
|
|
13
|
-
attribute :type, :string, as: "custom_tool_call"
|
|
14
|
-
attribute :call_id, :string
|
|
15
|
-
attribute :name, :string
|
|
16
|
-
attribute :input, :string # JSON input
|
|
17
|
-
|
|
18
|
-
validates :type, inclusion: { in: %w[custom_tool_call], allow_nil: false }
|
|
19
|
-
validates :call_id, presence: true
|
|
20
|
-
validates :name, presence: true
|
|
21
|
-
validates :input, presence: true
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
data/lib/active_agent/providers/open_ai/responses/requests/inputs/custom_tool_call_output.rb
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "base"
|
|
4
|
-
|
|
5
|
-
module ActiveAgent
|
|
6
|
-
module Providers
|
|
7
|
-
module OpenAI
|
|
8
|
-
module Responses
|
|
9
|
-
module Requests
|
|
10
|
-
module Inputs
|
|
11
|
-
# Custom tool call output
|
|
12
|
-
class CustomToolCallOutput < Base
|
|
13
|
-
attribute :type, :string, as: "custom_tool_call_output"
|
|
14
|
-
attribute :id, :string
|
|
15
|
-
attribute :call_id, :string
|
|
16
|
-
attribute :output # Always an array of content, serialized to string if single item
|
|
17
|
-
|
|
18
|
-
validates :type, inclusion: { in: %w[custom_tool_call_output], allow_nil: false }
|
|
19
|
-
validates :call_id, presence: true
|
|
20
|
-
validates :output, presence: true
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "input_message"
|
|
4
|
-
|
|
5
|
-
module ActiveAgent
|
|
6
|
-
module Providers
|
|
7
|
-
module OpenAI
|
|
8
|
-
module Responses
|
|
9
|
-
module Requests
|
|
10
|
-
module Inputs
|
|
11
|
-
# Developer message input (higher priority than system)
|
|
12
|
-
class DeveloperMessage < InputMessage
|
|
13
|
-
attribute :role, :string, as: "developer"
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "tool_call_base"
|
|
4
|
-
|
|
5
|
-
module ActiveAgent
|
|
6
|
-
module Providers
|
|
7
|
-
module OpenAI
|
|
8
|
-
module Responses
|
|
9
|
-
module Requests
|
|
10
|
-
module Inputs
|
|
11
|
-
# File search tool call - results from file search
|
|
12
|
-
class FileSearchToolCall < ToolCallBase
|
|
13
|
-
attribute :type, :string, as: "file_search_call"
|
|
14
|
-
attribute :queries # Always an array of strings
|
|
15
|
-
attribute :results # Always an array of result objects, can be empty
|
|
16
|
-
|
|
17
|
-
validates :type, inclusion: { in: %w[file_search_call], allow_nil: false }
|
|
18
|
-
validates :queries, presence: true
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "base"
|
|
4
|
-
|
|
5
|
-
module ActiveAgent
|
|
6
|
-
module Providers
|
|
7
|
-
module OpenAI
|
|
8
|
-
module Responses
|
|
9
|
-
module Requests
|
|
10
|
-
module Inputs
|
|
11
|
-
# Function call output for function tool calls
|
|
12
|
-
class FunctionCallOutput < Base
|
|
13
|
-
attribute :type, :string, as: "function_call_output"
|
|
14
|
-
attribute :id, :string
|
|
15
|
-
attribute :call_id, :string
|
|
16
|
-
attribute :output # Always an array of content, serialized to string if single item
|
|
17
|
-
attribute :status, :string
|
|
18
|
-
|
|
19
|
-
validates :type, inclusion: { in: %w[function_call_output], allow_nil: false }
|
|
20
|
-
validates :call_id, presence: true
|
|
21
|
-
validates :output, presence: true
|
|
22
|
-
validates :status, inclusion: {
|
|
23
|
-
in: %w[in_progress completed incomplete],
|
|
24
|
-
allow_nil: true
|
|
25
|
-
}
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "tool_call_base"
|
|
4
|
-
|
|
5
|
-
module ActiveAgent
|
|
6
|
-
module Providers
|
|
7
|
-
module OpenAI
|
|
8
|
-
module Responses
|
|
9
|
-
module Requests
|
|
10
|
-
module Inputs
|
|
11
|
-
# Function tool call - function calling
|
|
12
|
-
class FunctionToolCall < ToolCallBase
|
|
13
|
-
attribute :type, :string, as: "function_call"
|
|
14
|
-
attribute :call_id, :string
|
|
15
|
-
attribute :name, :string
|
|
16
|
-
attribute :arguments, :string # JSON string
|
|
17
|
-
|
|
18
|
-
validates :type, inclusion: { in: %w[function_call], allow_nil: false }
|
|
19
|
-
validates :call_id, presence: true
|
|
20
|
-
validates :name, presence: true
|
|
21
|
-
validates :arguments, presence: true
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "tool_call_base"
|
|
4
|
-
|
|
5
|
-
module ActiveAgent
|
|
6
|
-
module Providers
|
|
7
|
-
module OpenAI
|
|
8
|
-
module Responses
|
|
9
|
-
module Requests
|
|
10
|
-
module Inputs
|
|
11
|
-
# Image generation tool call
|
|
12
|
-
class ImageGenToolCall < ToolCallBase
|
|
13
|
-
attribute :type, :string, as: "image_generation_call"
|
|
14
|
-
attribute :result, :string # Base64 encoded image or null
|
|
15
|
-
|
|
16
|
-
validates :type, inclusion: { in: %w[image_generation_call], allow_nil: false }
|
|
17
|
-
validates :status, inclusion: {
|
|
18
|
-
in: %w[in_progress completed generating failed],
|
|
19
|
-
allow_nil: false
|
|
20
|
-
}
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "base"
|
|
4
|
-
|
|
5
|
-
module ActiveAgent
|
|
6
|
-
module Providers
|
|
7
|
-
module OpenAI
|
|
8
|
-
module Responses
|
|
9
|
-
module Requests
|
|
10
|
-
module Inputs
|
|
11
|
-
# Base class for user, system, and developer message inputs
|
|
12
|
-
class InputMessage < Base
|
|
13
|
-
attribute :status, :string
|
|
14
|
-
attribute :type, :string, default: "message" # Optional
|
|
15
|
-
|
|
16
|
-
validates :role, inclusion: {
|
|
17
|
-
in: %w[user system developer],
|
|
18
|
-
allow_nil: false
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
validates :status, inclusion: {
|
|
22
|
-
in: %w[in_progress completed incomplete],
|
|
23
|
-
allow_nil: true
|
|
24
|
-
}
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "base"
|
|
4
|
-
|
|
5
|
-
module ActiveAgent
|
|
6
|
-
module Providers
|
|
7
|
-
module OpenAI
|
|
8
|
-
module Responses
|
|
9
|
-
module Requests
|
|
10
|
-
module Inputs
|
|
11
|
-
# Item reference for referencing other items
|
|
12
|
-
class ItemReference < Base
|
|
13
|
-
attribute :type, :string, as: "item_reference"
|
|
14
|
-
attribute :id, :string
|
|
15
|
-
|
|
16
|
-
validates :id, presence: true
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "tool_call_base"
|
|
4
|
-
|
|
5
|
-
module ActiveAgent
|
|
6
|
-
module Providers
|
|
7
|
-
module OpenAI
|
|
8
|
-
module Responses
|
|
9
|
-
module Requests
|
|
10
|
-
module Inputs
|
|
11
|
-
# Local shell tool call - runs command on local shell
|
|
12
|
-
class LocalShellToolCall < ToolCallBase
|
|
13
|
-
attribute :type, :string, as: "local_shell_call"
|
|
14
|
-
attribute :call_id, :string
|
|
15
|
-
attribute :action # LocalShellExecAction object
|
|
16
|
-
|
|
17
|
-
validates :type, inclusion: { in: %w[local_shell_call], allow_nil: false }
|
|
18
|
-
validates :call_id, presence: true
|
|
19
|
-
validates :action, presence: true
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|