activeagent 0.6.3 → 1.0.0.rc1
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 +210 -2
- data/README.md +15 -24
- data/lib/active_agent/base.rb +389 -39
- data/lib/active_agent/concerns/callbacks.rb +251 -0
- data/lib/active_agent/concerns/observers.rb +147 -0
- data/lib/active_agent/concerns/parameterized.rb +292 -0
- data/lib/active_agent/concerns/provider.rb +120 -0
- data/lib/active_agent/concerns/queueing.rb +36 -0
- data/lib/active_agent/concerns/rescue.rb +64 -0
- data/lib/active_agent/concerns/streaming.rb +282 -0
- data/lib/active_agent/concerns/tooling.rb +23 -0
- data/lib/active_agent/concerns/view.rb +150 -0
- data/lib/active_agent/configuration.rb +442 -20
- data/lib/active_agent/generation.rb +141 -47
- data/lib/active_agent/generation_provider/open_router/types.rb +505 -0
- data/lib/active_agent/generation_provider/xai_provider.rb +144 -0
- data/lib/active_agent/providers/_base_provider.rb +410 -0
- data/lib/active_agent/providers/anthropic/_types.rb +63 -0
- data/lib/active_agent/providers/anthropic/options.rb +53 -0
- data/lib/active_agent/providers/anthropic/request.rb +109 -0
- data/lib/active_agent/providers/anthropic/requests/_types.rb +190 -0
- data/lib/active_agent/providers/anthropic/requests/container_params.rb +19 -0
- data/lib/active_agent/providers/anthropic/requests/content/base.rb +21 -0
- data/lib/active_agent/providers/anthropic/requests/content/sources/base.rb +22 -0
- data/lib/active_agent/providers/anthropic/requests/context_management_config.rb +18 -0
- data/lib/active_agent/providers/anthropic/requests/messages/_types.rb +189 -0
- data/lib/active_agent/providers/anthropic/requests/messages/assistant.rb +23 -0
- data/lib/active_agent/providers/anthropic/requests/messages/base.rb +63 -0
- data/lib/active_agent/providers/anthropic/requests/messages/content/_types.rb +143 -0
- data/lib/active_agent/providers/anthropic/requests/messages/content/base.rb +21 -0
- data/lib/active_agent/providers/anthropic/requests/messages/content/document.rb +26 -0
- data/lib/active_agent/providers/anthropic/requests/messages/content/image.rb +23 -0
- data/lib/active_agent/providers/anthropic/requests/messages/content/redacted_thinking.rb +21 -0
- data/lib/active_agent/providers/anthropic/requests/messages/content/search_result.rb +27 -0
- data/lib/active_agent/providers/anthropic/requests/messages/content/sources/_types.rb +171 -0
- data/lib/active_agent/providers/anthropic/requests/messages/content/sources/base.rb +22 -0
- data/lib/active_agent/providers/anthropic/requests/messages/content/sources/document_base64.rb +25 -0
- data/lib/active_agent/providers/anthropic/requests/messages/content/sources/document_file.rb +23 -0
- data/lib/active_agent/providers/anthropic/requests/messages/content/sources/document_text.rb +25 -0
- data/lib/active_agent/providers/anthropic/requests/messages/content/sources/document_url.rb +23 -0
- data/lib/active_agent/providers/anthropic/requests/messages/content/sources/image_base64.rb +27 -0
- data/lib/active_agent/providers/anthropic/requests/messages/content/sources/image_file.rb +23 -0
- data/lib/active_agent/providers/anthropic/requests/messages/content/sources/image_url.rb +23 -0
- data/lib/active_agent/providers/anthropic/requests/messages/content/text.rb +22 -0
- data/lib/active_agent/providers/anthropic/requests/messages/content/thinking.rb +23 -0
- data/lib/active_agent/providers/anthropic/requests/messages/content/tool_result.rb +24 -0
- data/lib/active_agent/providers/anthropic/requests/messages/content/tool_use.rb +28 -0
- data/lib/active_agent/providers/anthropic/requests/messages/user.rb +21 -0
- data/lib/active_agent/providers/anthropic/requests/metadata.rb +18 -0
- data/lib/active_agent/providers/anthropic/requests/response_format.rb +22 -0
- data/lib/active_agent/providers/anthropic/requests/thinking_config/_types.rb +60 -0
- data/lib/active_agent/providers/anthropic/requests/thinking_config/base.rb +20 -0
- data/lib/active_agent/providers/anthropic/requests/thinking_config/disabled.rb +16 -0
- data/lib/active_agent/providers/anthropic/requests/thinking_config/enabled.rb +20 -0
- data/lib/active_agent/providers/anthropic/requests/tool_choice/_types.rb +78 -0
- data/lib/active_agent/providers/anthropic/requests/tool_choice/any.rb +17 -0
- data/lib/active_agent/providers/anthropic/requests/tool_choice/auto.rb +17 -0
- data/lib/active_agent/providers/anthropic/requests/tool_choice/base.rb +20 -0
- data/lib/active_agent/providers/anthropic/requests/tool_choice/none.rb +16 -0
- data/lib/active_agent/providers/anthropic/requests/tool_choice/tool.rb +20 -0
- data/lib/active_agent/providers/anthropic_provider.rb +211 -0
- data/lib/active_agent/providers/common/messages/_types.rb +124 -0
- data/lib/active_agent/providers/common/messages/assistant.rb +57 -0
- data/lib/active_agent/providers/common/messages/base.rb +17 -0
- data/lib/active_agent/providers/common/messages/system.rb +20 -0
- data/lib/active_agent/providers/common/messages/tool.rb +21 -0
- data/lib/active_agent/providers/common/messages/user.rb +20 -0
- data/lib/active_agent/providers/common/model.rb +361 -0
- data/lib/active_agent/providers/common/response.rb +13 -0
- data/lib/active_agent/providers/common/responses/_types.rb +51 -0
- data/lib/active_agent/providers/common/responses/base.rb +151 -0
- data/lib/active_agent/providers/common/responses/embed.rb +33 -0
- data/lib/active_agent/providers/common/responses/format.rb +31 -0
- data/lib/active_agent/providers/common/responses/message.rb +3 -0
- data/lib/active_agent/providers/common/responses/prompt.rb +42 -0
- data/lib/active_agent/providers/concerns/exception_handler.rb +72 -0
- data/lib/active_agent/providers/concerns/previewable.rb +150 -0
- data/lib/active_agent/providers/log_subscriber.rb +360 -0
- data/lib/active_agent/providers/mock/_types.rb +77 -0
- data/lib/active_agent/providers/mock/embedding_request.rb +17 -0
- data/lib/active_agent/providers/mock/messages/_types.rb +103 -0
- data/lib/active_agent/providers/mock/messages/assistant.rb +26 -0
- data/lib/active_agent/providers/mock/messages/base.rb +63 -0
- data/lib/active_agent/providers/mock/messages/user.rb +18 -0
- data/lib/active_agent/providers/mock/options.rb +30 -0
- data/lib/active_agent/providers/mock/request.rb +38 -0
- data/lib/active_agent/providers/mock_provider.rb +311 -0
- data/lib/active_agent/providers/ollama/_types.rb +5 -0
- data/lib/active_agent/providers/ollama/chat/_types.rb +44 -0
- data/lib/active_agent/providers/ollama/chat/request.rb +70 -0
- data/lib/active_agent/providers/ollama/chat/requests/_types.rb +3 -0
- data/lib/active_agent/providers/ollama/chat/requests/messages/_types.rb +116 -0
- data/lib/active_agent/providers/ollama/chat/requests/messages/assistant.rb +19 -0
- data/lib/active_agent/providers/ollama/chat/requests/messages/user.rb +19 -0
- data/lib/active_agent/providers/ollama/embedding/_types.rb +44 -0
- data/lib/active_agent/providers/ollama/embedding/request.rb +77 -0
- data/lib/active_agent/providers/ollama/embedding/requests/_types.rb +83 -0
- data/lib/active_agent/providers/ollama/embedding/requests/options.rb +104 -0
- data/lib/active_agent/providers/ollama/options.rb +27 -0
- data/lib/active_agent/providers/ollama_provider.rb +95 -0
- data/lib/active_agent/providers/open_ai/_base.rb +58 -0
- data/lib/active_agent/providers/open_ai/_types.rb +5 -0
- data/lib/active_agent/providers/open_ai/chat/_types.rb +44 -0
- data/lib/active_agent/providers/open_ai/chat/request.rb +215 -0
- data/lib/active_agent/providers/open_ai/chat/requests/_types.rb +229 -0
- data/lib/active_agent/providers/open_ai/chat/requests/audio.rb +24 -0
- data/lib/active_agent/providers/open_ai/chat/requests/messages/_types.rb +123 -0
- data/lib/active_agent/providers/open_ai/chat/requests/messages/assistant.rb +42 -0
- data/lib/active_agent/providers/open_ai/chat/requests/messages/base.rb +78 -0
- data/lib/active_agent/providers/open_ai/chat/requests/messages/content/_types.rb +133 -0
- data/lib/active_agent/providers/open_ai/chat/requests/messages/content/audio.rb +35 -0
- data/lib/active_agent/providers/open_ai/chat/requests/messages/content/base.rb +24 -0
- data/lib/active_agent/providers/open_ai/chat/requests/messages/content/file.rb +26 -0
- data/lib/active_agent/providers/open_ai/chat/requests/messages/content/files/_types.rb +60 -0
- data/lib/active_agent/providers/open_ai/chat/requests/messages/content/files/details.rb +41 -0
- data/lib/active_agent/providers/open_ai/chat/requests/messages/content/image.rb +37 -0
- data/lib/active_agent/providers/open_ai/chat/requests/messages/content/refusal.rb +25 -0
- data/lib/active_agent/providers/open_ai/chat/requests/messages/content/text.rb +25 -0
- data/lib/active_agent/providers/open_ai/chat/requests/messages/developer.rb +25 -0
- data/lib/active_agent/providers/open_ai/chat/requests/messages/function.rb +25 -0
- data/lib/active_agent/providers/open_ai/chat/requests/messages/system.rb +25 -0
- data/lib/active_agent/providers/open_ai/chat/requests/messages/tool.rb +26 -0
- data/lib/active_agent/providers/open_ai/chat/requests/messages/user.rb +32 -0
- data/lib/active_agent/providers/open_ai/chat/requests/prediction.rb +46 -0
- data/lib/active_agent/providers/open_ai/chat/requests/response_format.rb +53 -0
- data/lib/active_agent/providers/open_ai/chat/requests/stream_options.rb +24 -0
- data/lib/active_agent/providers/open_ai/chat/requests/tool_choice.rb +26 -0
- data/lib/active_agent/providers/open_ai/chat/requests/tools/_types.rb +5 -0
- data/lib/active_agent/providers/open_ai/chat/requests/tools/base.rb +22 -0
- data/lib/active_agent/providers/open_ai/chat/requests/tools/custom_tool.rb +41 -0
- data/lib/active_agent/providers/open_ai/chat/requests/tools/function_tool.rb +51 -0
- data/lib/active_agent/providers/open_ai/chat/requests/web_search_options.rb +45 -0
- data/lib/active_agent/providers/open_ai/chat_provider.rb +198 -0
- data/lib/active_agent/providers/open_ai/embedding/_types.rb +45 -0
- data/lib/active_agent/providers/open_ai/embedding/request.rb +85 -0
- data/lib/active_agent/providers/open_ai/embedding/requests/_types.rb +49 -0
- data/lib/active_agent/providers/open_ai/options.rb +74 -0
- data/lib/active_agent/providers/open_ai/responses/_types.rb +50 -0
- data/lib/active_agent/providers/open_ai/responses/request.rb +163 -0
- data/lib/active_agent/providers/open_ai/responses/requests/_types.rb +231 -0
- data/lib/active_agent/providers/open_ai/responses/requests/conversation.rb +23 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/_types.rb +264 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/assistant_message.rb +22 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/base.rb +89 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/code_interpreter_tool_call.rb +30 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/computer_tool_call.rb +28 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/computer_tool_call_output.rb +33 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/_types.rb +207 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/base.rb +22 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/input_audio.rb +26 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/input_file.rb +28 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/input_image.rb +28 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/content/input_text.rb +25 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/custom_tool_call.rb +28 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/custom_tool_call_output.rb +27 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/developer_message.rb +20 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/file_search_tool_call.rb +25 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/function_call_output.rb +32 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/function_tool_call.rb +28 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/image_gen_tool_call.rb +27 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/input_message.rb +31 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/item_reference.rb +23 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/local_shell_tool_call.rb +26 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/local_shell_tool_call_output.rb +33 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/mcp_approval_request.rb +30 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/mcp_approval_response.rb +28 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/mcp_list_tools.rb +29 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/mcp_tool_call.rb +35 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/output_message.rb +35 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/reasoning.rb +33 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/system_message.rb +20 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/tool_call_base.rb +27 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/tool_message.rb +23 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/user_message.rb +20 -0
- data/lib/active_agent/providers/open_ai/responses/requests/inputs/web_search_tool_call.rb +24 -0
- data/lib/active_agent/providers/open_ai/responses/requests/prompt_reference.rb +23 -0
- data/lib/active_agent/providers/open_ai/responses/requests/reasoning.rb +23 -0
- data/lib/active_agent/providers/open_ai/responses/requests/stream_options.rb +20 -0
- data/lib/active_agent/providers/open_ai/responses/requests/text/_types.rb +89 -0
- data/lib/active_agent/providers/open_ai/responses/requests/text/base.rb +22 -0
- data/lib/active_agent/providers/open_ai/responses/requests/text/json_object.rb +20 -0
- data/lib/active_agent/providers/open_ai/responses/requests/text/json_schema.rb +48 -0
- data/lib/active_agent/providers/open_ai/responses/requests/text/plain.rb +20 -0
- data/lib/active_agent/providers/open_ai/responses/requests/text.rb +41 -0
- data/lib/active_agent/providers/open_ai/responses/requests/tool_choice.rb +26 -0
- data/lib/active_agent/providers/open_ai/responses/requests/tools/_types.rb +112 -0
- data/lib/active_agent/providers/open_ai/responses/requests/tools/base.rb +25 -0
- data/lib/active_agent/providers/open_ai/responses/requests/tools/code_interpreter_tool.rb +23 -0
- data/lib/active_agent/providers/open_ai/responses/requests/tools/computer_tool.rb +27 -0
- data/lib/active_agent/providers/open_ai/responses/requests/tools/custom_tool.rb +28 -0
- data/lib/active_agent/providers/open_ai/responses/requests/tools/file_search_tool.rb +27 -0
- data/lib/active_agent/providers/open_ai/responses/requests/tools/function_tool.rb +29 -0
- data/lib/active_agent/providers/open_ai/responses/requests/tools/image_generation_tool.rb +37 -0
- data/lib/active_agent/providers/open_ai/responses/requests/tools/local_shell_tool.rb +21 -0
- data/lib/active_agent/providers/open_ai/responses/requests/tools/mcp_tool.rb +41 -0
- data/lib/active_agent/providers/open_ai/responses/requests/tools/web_search_preview_tool.rb +24 -0
- data/lib/active_agent/providers/open_ai/responses/requests/tools/web_search_tool.rb +25 -0
- data/lib/active_agent/providers/open_ai/responses_provider.rb +153 -0
- data/lib/active_agent/providers/open_ai/schema.yml +65937 -0
- data/lib/active_agent/providers/open_ai_provider.rb +97 -0
- data/lib/active_agent/providers/open_router/_types.rb +45 -0
- data/lib/active_agent/providers/open_router/options.rb +93 -0
- data/lib/active_agent/providers/open_router/request.rb +83 -0
- data/lib/active_agent/providers/open_router/requests/_types.rb +198 -0
- data/lib/active_agent/providers/open_router/requests/message.rb +1 -0
- data/lib/active_agent/providers/open_router/requests/messages/_types.rb +59 -0
- data/lib/active_agent/providers/open_router/requests/messages/assistant.rb +20 -0
- data/lib/active_agent/providers/open_router/requests/messages/content/_types.rb +97 -0
- data/lib/active_agent/providers/open_router/requests/messages/content/file.rb +27 -0
- data/lib/active_agent/providers/open_router/requests/messages/content/files/_types.rb +61 -0
- data/lib/active_agent/providers/open_router/requests/messages/content/files/details.rb +26 -0
- data/lib/active_agent/providers/open_router/requests/messages/user.rb +30 -0
- data/lib/active_agent/providers/open_router/requests/plugin.rb +25 -0
- data/lib/active_agent/providers/open_router/requests/plugins/_types.rb +46 -0
- data/lib/active_agent/providers/open_router/requests/plugins/pdf_config.rb +29 -0
- data/lib/active_agent/providers/open_router/requests/prediction.rb +17 -0
- data/lib/active_agent/providers/open_router/requests/provider_preferences/_types.rb +44 -0
- data/lib/active_agent/providers/open_router/requests/provider_preferences/max_price.rb +30 -0
- data/lib/active_agent/providers/open_router/requests/provider_preferences.rb +64 -0
- data/lib/active_agent/providers/open_router/requests/response_format.rb +49 -0
- data/lib/active_agent/providers/open_router_provider.rb +53 -0
- data/lib/active_agent/providers/openai_provider.rb +2 -0
- data/lib/active_agent/providers/openrouter_provider.rb +2 -0
- data/lib/active_agent/railtie.rb +8 -6
- data/lib/active_agent/schema_generator.rb +333 -166
- data/lib/active_agent/version.rb +1 -1
- data/lib/active_agent.rb +112 -36
- data/lib/generators/active_agent/agent/USAGE +78 -0
- data/lib/generators/active_agent/{agent_generator.rb → agent/agent_generator.rb} +14 -4
- data/lib/generators/active_agent/install/USAGE +25 -0
- data/lib/generators/active_agent/{install_generator.rb → install/install_generator.rb} +1 -19
- data/lib/generators/active_agent/templates/agent.rb.tt +7 -3
- data/lib/generators/active_agent/templates/application_agent.rb.tt +0 -2
- data/lib/generators/erb/agent_generator.rb +31 -16
- data/lib/generators/erb/templates/instructions.md.erb.tt +3 -0
- data/lib/generators/erb/templates/instructions.md.tt +3 -0
- data/lib/generators/erb/templates/instructions.text.tt +1 -0
- data/lib/generators/erb/templates/message.md.erb.tt +5 -0
- data/lib/generators/erb/templates/schema.json.tt +10 -0
- data/lib/generators/test_unit/agent_generator.rb +1 -1
- data/lib/generators/test_unit/templates/functional_test.rb.tt +4 -2
- metadata +320 -65
- data/lib/active_agent/action_prompt/action.rb +0 -13
- data/lib/active_agent/action_prompt/base.rb +0 -623
- data/lib/active_agent/action_prompt/message.rb +0 -126
- data/lib/active_agent/action_prompt/prompt.rb +0 -136
- data/lib/active_agent/action_prompt.rb +0 -19
- data/lib/active_agent/callbacks.rb +0 -33
- data/lib/active_agent/generation_provider/anthropic_provider.rb +0 -163
- data/lib/active_agent/generation_provider/base.rb +0 -55
- data/lib/active_agent/generation_provider/base_adapter.rb +0 -19
- data/lib/active_agent/generation_provider/error_handling.rb +0 -167
- data/lib/active_agent/generation_provider/log_subscriber.rb +0 -92
- data/lib/active_agent/generation_provider/message_formatting.rb +0 -107
- data/lib/active_agent/generation_provider/ollama_provider.rb +0 -66
- data/lib/active_agent/generation_provider/open_ai_provider.rb +0 -279
- data/lib/active_agent/generation_provider/open_router_provider.rb +0 -385
- data/lib/active_agent/generation_provider/parameter_builder.rb +0 -119
- data/lib/active_agent/generation_provider/response.rb +0 -75
- data/lib/active_agent/generation_provider/responses_adapter.rb +0 -44
- data/lib/active_agent/generation_provider/stream_processing.rb +0 -58
- data/lib/active_agent/generation_provider/tool_management.rb +0 -142
- data/lib/active_agent/generation_provider.rb +0 -67
- data/lib/active_agent/log_subscriber.rb +0 -44
- data/lib/active_agent/parameterized.rb +0 -75
- data/lib/active_agent/prompt_helper.rb +0 -19
- data/lib/active_agent/queued_generation.rb +0 -12
- data/lib/active_agent/rescuable.rb +0 -34
- data/lib/active_agent/sanitizers.rb +0 -40
- data/lib/active_agent/streaming.rb +0 -34
- data/lib/active_agent/test_case.rb +0 -125
- data/lib/generators/USAGE +0 -47
- data/lib/generators/active_agent/USAGE +0 -56
- data/lib/generators/erb/install_generator.rb +0 -44
- data/lib/generators/erb/templates/layout.html.erb.tt +0 -1
- data/lib/generators/erb/templates/layout.json.erb.tt +0 -1
- data/lib/generators/erb/templates/layout.text.erb.tt +0 -1
- data/lib/generators/erb/templates/view.html.erb.tt +0 -5
- data/lib/generators/erb/templates/view.json.erb.tt +0 -16
- /data/lib/active_agent/{preview.rb → concerns/preview.rb} +0 -0
- /data/lib/generators/erb/templates/{view.text.erb.tt → message.text.erb.tt} +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
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 Tools
|
|
11
|
+
# Image generation tool
|
|
12
|
+
class ImageGenerationTool < Base
|
|
13
|
+
attribute :type, :string, as: "image_generation"
|
|
14
|
+
attribute :background, :string, default: "auto" # Optional: "transparent", "opaque", or "auto"
|
|
15
|
+
attribute :input_fidelity, :string, default: "low" # Optional: "high" or "low"
|
|
16
|
+
attribute :input_image_mask # Optional: hash with image_url and/or file_id
|
|
17
|
+
attribute :model, :string, default: "gpt-image-1" # Optional: model to use
|
|
18
|
+
attribute :moderation, :string, default: "auto" # Optional: moderation level
|
|
19
|
+
attribute :output_compression, :integer, default: 100 # Optional: compression level
|
|
20
|
+
attribute :output_format, :string, default: "png" # Optional: "png", "webp", or "jpeg"
|
|
21
|
+
attribute :partial_images, :integer, default: 0 # Optional: 0-3
|
|
22
|
+
attribute :quality, :string, default: "auto" # Optional: "low", "medium", "high", or "auto"
|
|
23
|
+
attribute :size, :string, default: "auto" # Optional: "1024x1024", "1024x1536", "1536x1024", or "auto"
|
|
24
|
+
|
|
25
|
+
validates :background, inclusion: { in: %w[transparent opaque auto] }, allow_nil: true
|
|
26
|
+
validates :input_fidelity, inclusion: { in: %w[high low] }, allow_nil: true
|
|
27
|
+
validates :output_format, inclusion: { in: %w[png webp jpeg] }, allow_nil: true
|
|
28
|
+
validates :partial_images, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 3 }, allow_nil: true
|
|
29
|
+
validates :quality, inclusion: { in: %w[low medium high auto] }, allow_nil: true
|
|
30
|
+
validates :size, inclusion: { in: %w[1024x1024 1024x1536 1536x1024 auto] }, allow_nil: true
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
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 Tools
|
|
11
|
+
# Local shell tool
|
|
12
|
+
class LocalShellTool < Base
|
|
13
|
+
attribute :type, :string, as: "local_shell"
|
|
14
|
+
attribute :local_shell # Hash with optional configuration
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
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 Tools
|
|
11
|
+
# MCP (Model Context Protocol) tool
|
|
12
|
+
class McpTool < Base
|
|
13
|
+
attribute :type, :string, as: "mcp"
|
|
14
|
+
attribute :server_label, :string # Required: label for this MCP server
|
|
15
|
+
attribute :allowed_tools # Optional: array of tool names or filter object
|
|
16
|
+
attribute :authorization, :string # Optional: OAuth access token
|
|
17
|
+
attribute :connector_id, :string # Optional: service connector ID (e.g., "connector_googledrive")
|
|
18
|
+
attribute :headers # Optional: hash of HTTP headers
|
|
19
|
+
attribute :require_approval # Optional: string ("always"/"never") or object with approval filters
|
|
20
|
+
attribute :server_description, :string # Optional: description of the MCP server
|
|
21
|
+
attribute :server_url, :string # Optional: URL for the MCP server
|
|
22
|
+
|
|
23
|
+
validates :server_label, presence: true
|
|
24
|
+
|
|
25
|
+
# Either server_url or connector_id must be provided
|
|
26
|
+
validate :validate_server_url_or_connector_id
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def validate_server_url_or_connector_id
|
|
31
|
+
if server_url.blank? && connector_id.blank?
|
|
32
|
+
errors.add(:base, "Either server_url or connector_id must be provided")
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
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 Tools
|
|
11
|
+
# Web search preview tool (older version)
|
|
12
|
+
class WebSearchPreviewTool < Base
|
|
13
|
+
attribute :type, :string, as: "web_search_preview" # Can be "web_search_preview" or "web_search_preview_2025_03_11"
|
|
14
|
+
attribute :search_context_size, :string # Optional: "low", "medium", or "high"
|
|
15
|
+
attribute :user_location # Hash - optional: { type: "approximate", city, country, region, timezone }
|
|
16
|
+
|
|
17
|
+
validates :search_context_size, inclusion: { in: %w[low medium high] }, allow_nil: true
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
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 Tools
|
|
11
|
+
# Built-in web search tool
|
|
12
|
+
class WebSearchTool < Base
|
|
13
|
+
attribute :type, :string, as: "web_search" # Can be "web_search" or "web_search_2025_08_26"
|
|
14
|
+
attribute :filters # Hash - optional: { allowed_domains: [] }
|
|
15
|
+
attribute :search_context_size, :string, default: "medium" # Optional: "low", "medium", or "high"
|
|
16
|
+
attribute :user_location # Hash - optional: { type: "approximate", city, country, region, timezone }
|
|
17
|
+
|
|
18
|
+
validates :search_context_size, inclusion: { in: %w[low medium high] }, allow_nil: true
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
require_relative "_base"
|
|
2
|
+
require_relative "responses/_types"
|
|
3
|
+
|
|
4
|
+
module ActiveAgent
|
|
5
|
+
module Providers
|
|
6
|
+
module OpenAI
|
|
7
|
+
# Handles OpenAI's Responses API with improved streaming and structured function calling.
|
|
8
|
+
#
|
|
9
|
+
# Uses the newer responses endpoint instead of the chat completions endpoint
|
|
10
|
+
# for more reliable streaming and better structured interactions with function calls.
|
|
11
|
+
#
|
|
12
|
+
# @see Base
|
|
13
|
+
# @see https://platform.openai.com/docs/api-reference/responses
|
|
14
|
+
class ResponsesProvider < Base
|
|
15
|
+
# @return [Class]
|
|
16
|
+
def self.options_klass
|
|
17
|
+
Options
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# @return [Responses::RequestType]
|
|
21
|
+
def self.prompt_request_type
|
|
22
|
+
Responses::RequestType.new
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
protected
|
|
26
|
+
|
|
27
|
+
# @return [Object] OpenAI client's responses endpoint
|
|
28
|
+
def api_prompt_executer
|
|
29
|
+
client.responses
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Processes streaming response chunks from the Responses API.
|
|
33
|
+
#
|
|
34
|
+
# Handles event types: response.created, response.output_item.added,
|
|
35
|
+
# response.output_text.delta, response.function_call_arguments.delta,
|
|
36
|
+
# and response.completed. Updates message stack and broadcasts streaming
|
|
37
|
+
# updates to listeners.
|
|
38
|
+
#
|
|
39
|
+
# @param api_response_event [Hash] streaming response chunk with :type key
|
|
40
|
+
# @return [void]
|
|
41
|
+
def process_stream_chunk(api_response_event)
|
|
42
|
+
instrument("stream_chunk_processing.provider.active_agent", chunk_type: api_response_event.type)
|
|
43
|
+
|
|
44
|
+
case api_response_event.type
|
|
45
|
+
# Response Created
|
|
46
|
+
when :"response.created", :"response.in_progress"
|
|
47
|
+
broadcast_stream_open
|
|
48
|
+
|
|
49
|
+
# -> Message Created
|
|
50
|
+
when :"response.output_item.added"
|
|
51
|
+
process_stream_output_item_added(api_response_event)
|
|
52
|
+
|
|
53
|
+
# -> -> Content Part Create
|
|
54
|
+
when :"response.content_part.added"
|
|
55
|
+
|
|
56
|
+
# -> -> -> Content Text Append
|
|
57
|
+
when :"response.output_text.delta"
|
|
58
|
+
message = message_stack.find { _1[:id] == api_response_event[:item_id] }
|
|
59
|
+
message[:content] += api_response_event[:delta]
|
|
60
|
+
broadcast_stream_update(message, api_response_event[:delta])
|
|
61
|
+
|
|
62
|
+
# -> -> -> Content Text Completed [Full Text]
|
|
63
|
+
when :"response.output_text.done"
|
|
64
|
+
message = message_stack.find { _1[:id] == api_response_event[:item_id] }
|
|
65
|
+
message[:content] = api_response_event[:text]
|
|
66
|
+
broadcast_stream_update(message, nil) # Don't double send content
|
|
67
|
+
|
|
68
|
+
# -> -> -> Content Function Call Append
|
|
69
|
+
when :"response.function_call_arguments.delta", :"response.function_call_arguments.done"
|
|
70
|
+
# No-Op: Wait for FC to Land
|
|
71
|
+
|
|
72
|
+
# -> -> Content Part Completed [Full Part]
|
|
73
|
+
when :"response.content_part.done"
|
|
74
|
+
|
|
75
|
+
# -> Message Completed
|
|
76
|
+
when :"response.output_item.done"
|
|
77
|
+
process_stream_output_item_done(api_response_event)
|
|
78
|
+
|
|
79
|
+
# Response Completed
|
|
80
|
+
when :"response.completed"
|
|
81
|
+
# Once we are finished, close out and run tooling callbacks (Recursive)
|
|
82
|
+
process_prompt_finished
|
|
83
|
+
else
|
|
84
|
+
fail "Unexpected Response Chunk Type: #{type}"
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Processes output item added events from streaming response.
|
|
89
|
+
#
|
|
90
|
+
# @param api_response_event [Hash] response chunk with :item key
|
|
91
|
+
# @return [void]
|
|
92
|
+
def process_stream_output_item_added(api_response_event)
|
|
93
|
+
case api_response_event.item.type
|
|
94
|
+
when :message
|
|
95
|
+
# PATCH: API returns an empty array instead of empty string due to a bug in their serialization
|
|
96
|
+
message_stack << { content: "" }.merge(api_response_event.item.to_h.compact_blank)
|
|
97
|
+
when :function_call
|
|
98
|
+
# No-Op: Wait for FC to Land (-> response.output_item.done)
|
|
99
|
+
else
|
|
100
|
+
fail "Unexpected Item Type: #{api_response_event.item.type}"
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Processes output item completion events from streaming response.
|
|
105
|
+
#
|
|
106
|
+
# @param api_response_event [Hash] response chunk with completed :item
|
|
107
|
+
# @return [void]
|
|
108
|
+
def process_stream_output_item_done(api_response_event)
|
|
109
|
+
case api_response_event.item.type
|
|
110
|
+
when :message
|
|
111
|
+
# No-Op: Message Up to Date
|
|
112
|
+
when :function_call
|
|
113
|
+
message_stack << api_response_event.item
|
|
114
|
+
else
|
|
115
|
+
fail "Unexpected Item Type: #{api_response_event.item.type}"
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Executes function calls and creates output messages for conversation continuation.
|
|
120
|
+
#
|
|
121
|
+
# @param api_function_calls [Array<Hash>] function calls with :call_id and :name keys
|
|
122
|
+
# @return [void]
|
|
123
|
+
def process_function_calls(api_function_calls)
|
|
124
|
+
api_function_calls.each do |api_function_call|
|
|
125
|
+
instrument("tool_execution.provider.active_agent", tool_name: api_function_call[:name])
|
|
126
|
+
|
|
127
|
+
message = Responses::Requests::Inputs::FunctionCallOutput.new(
|
|
128
|
+
call_id: api_function_call[:call_id],
|
|
129
|
+
output: process_tool_call_function(api_function_call).to_json
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
message_stack.push(message.serialize)
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# Extracts messages from completed API response.
|
|
137
|
+
#
|
|
138
|
+
# @param api_response [Hash] completed API response
|
|
139
|
+
# @return [Array, nil] output array from response[:output] or nil
|
|
140
|
+
def process_prompt_finished_extract_messages(api_response)
|
|
141
|
+
api_response&.dig(:output)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Extracts function calls from message stack.
|
|
145
|
+
#
|
|
146
|
+
# @return [Array<Hash>] function call objects with type "function_call"
|
|
147
|
+
def process_prompt_finished_extract_function_calls
|
|
148
|
+
message_stack.select { _1[:type] == "function_call" }
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|