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
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
module ActiveAgent
|
|
2
|
-
module Sanitizers
|
|
3
|
-
extend ActiveSupport::Concern
|
|
4
|
-
|
|
5
|
-
SECRETS_KEYS = %w[access_token api_key]
|
|
6
|
-
|
|
7
|
-
class_methods do
|
|
8
|
-
# @return [Hash] The current sanitizers.
|
|
9
|
-
def sanitizers
|
|
10
|
-
@sanitizers ||= begin
|
|
11
|
-
sanitizers = {}
|
|
12
|
-
|
|
13
|
-
config.each do |provider, credentials|
|
|
14
|
-
credentials.slice(*SECRETS_KEYS).compact.each do |name, secret|
|
|
15
|
-
next if secret.blank?
|
|
16
|
-
|
|
17
|
-
sanitizers[secret] = "<#{provider.upcase}_#{name.upcase}>"
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
sanitizers
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# return [void]
|
|
26
|
-
def sanitizers_reset!
|
|
27
|
-
@sanitizers = nil
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# @return [String] The sanitized string with sensitive data replaced by placeholders.
|
|
31
|
-
def sanitize_credentials(string)
|
|
32
|
-
sanitizers.each do |secret, placeholder|
|
|
33
|
-
string = string.gsub(secret, placeholder)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
string
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module ActiveAgent
|
|
4
|
-
module Streaming
|
|
5
|
-
extend ActiveSupport::Concern
|
|
6
|
-
|
|
7
|
-
class StreamChunk < Data.define(:delta, :stop)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
attr_accessor :stream_chunk
|
|
11
|
-
|
|
12
|
-
included do
|
|
13
|
-
include ActiveSupport::Callbacks
|
|
14
|
-
define_callbacks :stream, skip_after_callbacks_if_terminated: true
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
module ClassMethods
|
|
18
|
-
# Defines a callback for handling streaming responses during generation
|
|
19
|
-
def on_stream(*names, &blk)
|
|
20
|
-
_insert_callbacks(names, blk) do |name, options|
|
|
21
|
-
set_callback(:stream, :before, name, options)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# Helper method to run stream callbacks
|
|
27
|
-
def run_stream_callbacks(message, delta = nil, stop = false)
|
|
28
|
-
@stream_chunk = StreamChunk.new(delta, stop)
|
|
29
|
-
run_callbacks(:stream) do
|
|
30
|
-
yield(message, delta, stop) if block_given?
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
# # frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# require_relative "test_helper"
|
|
4
|
-
# require "active_support/test_case"
|
|
5
|
-
# require "rails-dom-testing"
|
|
6
|
-
|
|
7
|
-
# module ActiveAgent
|
|
8
|
-
# class NonInferrableAgentError < ::StandardError
|
|
9
|
-
# def initialize(name)
|
|
10
|
-
# super("Unable to determine the agent to test from #{name}. " \
|
|
11
|
-
# "You'll need to specify it using tests YourAgent in your " \
|
|
12
|
-
# "test case definition")
|
|
13
|
-
# end
|
|
14
|
-
# end
|
|
15
|
-
|
|
16
|
-
# class TestCase < ActiveSupport::TestCase
|
|
17
|
-
# module ClearTestDeliveries
|
|
18
|
-
# extend ActiveSupport::Concern
|
|
19
|
-
|
|
20
|
-
# included do
|
|
21
|
-
# setup :clear_test_generations
|
|
22
|
-
# teardown :clear_test_generations
|
|
23
|
-
# end
|
|
24
|
-
|
|
25
|
-
# private
|
|
26
|
-
|
|
27
|
-
# def clear_test_generations
|
|
28
|
-
# if ActiveAgent::Base.generation_method == :test
|
|
29
|
-
# ActiveAgent::Base.generations.clear
|
|
30
|
-
# end
|
|
31
|
-
# end
|
|
32
|
-
# end
|
|
33
|
-
|
|
34
|
-
# module Behavior
|
|
35
|
-
# extend ActiveSupport::Concern
|
|
36
|
-
|
|
37
|
-
# include ActiveSupport::Testing::ConstantLookup
|
|
38
|
-
# include TestHelper
|
|
39
|
-
# include Rails::Dom::Testing::Assertions::SelectorAssertions
|
|
40
|
-
# include Rails::Dom::Testing::Assertions::DomAssertions
|
|
41
|
-
|
|
42
|
-
# included do
|
|
43
|
-
# class_attribute :_agent_class
|
|
44
|
-
# setup :initialize_test_generations
|
|
45
|
-
# setup :set_expected_prompt
|
|
46
|
-
# teardown :restore_test_generations
|
|
47
|
-
# ActiveSupport.run_load_hooks(:active_agent_test_case, self)
|
|
48
|
-
# end
|
|
49
|
-
|
|
50
|
-
# module ClassMethods
|
|
51
|
-
# def tests(agent)
|
|
52
|
-
# case agent
|
|
53
|
-
# when String, Symbol
|
|
54
|
-
# self._agent_class = agent.to_s.camelize.constantize
|
|
55
|
-
# when Module
|
|
56
|
-
# self._agent_class = agent
|
|
57
|
-
# else
|
|
58
|
-
# raise NonInferrableAgentError.new(agent)
|
|
59
|
-
# end
|
|
60
|
-
# end
|
|
61
|
-
|
|
62
|
-
# def agent_class
|
|
63
|
-
# if agent = _agent_class
|
|
64
|
-
# agent
|
|
65
|
-
# else
|
|
66
|
-
# tests determine_default_agent(name)
|
|
67
|
-
# end
|
|
68
|
-
# end
|
|
69
|
-
|
|
70
|
-
# def determine_default_agent(name)
|
|
71
|
-
# agent = determine_constant_from_test_name(name) do |constant|
|
|
72
|
-
# Class === constant && constant < ActiveAgent::Base
|
|
73
|
-
# end
|
|
74
|
-
# raise NonInferrableAgentError.new(name) if agent.nil?
|
|
75
|
-
# agent
|
|
76
|
-
# end
|
|
77
|
-
# end
|
|
78
|
-
|
|
79
|
-
# # Reads the fixture file for the given agent.
|
|
80
|
-
# #
|
|
81
|
-
# # This is useful when testing agents by being able to write the body of
|
|
82
|
-
# # an promt inside a fixture. See the testing guide for a concrete example:
|
|
83
|
-
# # https://guides.rubyonrails.org/testing.html#revenge-of-the-fixtures
|
|
84
|
-
# def read_fixture(action)
|
|
85
|
-
# IO.readlines(File.join(Rails.root, "test", "fixtures", self.class.agent_class.name.underscore, action))
|
|
86
|
-
# end
|
|
87
|
-
|
|
88
|
-
# private
|
|
89
|
-
|
|
90
|
-
# def initialize_test_generations
|
|
91
|
-
# set_generation_method :test
|
|
92
|
-
# @old_perform_generations = ActiveAgent::Base.perform_generations
|
|
93
|
-
# ActiveAgent::Base.perform_generations = true
|
|
94
|
-
# ActiveAgent::Base.generations.clear
|
|
95
|
-
# end
|
|
96
|
-
|
|
97
|
-
# def restore_test_generations
|
|
98
|
-
# restore_generation_method
|
|
99
|
-
# ActiveAgent::Base.perform_generations = @old_perform_generations
|
|
100
|
-
# end
|
|
101
|
-
|
|
102
|
-
# def set_generation_method(method)
|
|
103
|
-
# @old_generation_method = ActiveAgent::Base.generation_method
|
|
104
|
-
# ActiveAgent::Base.generation_method = method
|
|
105
|
-
# end
|
|
106
|
-
|
|
107
|
-
# def restore_generation_method
|
|
108
|
-
# ActiveAgent::Base.generations.clear
|
|
109
|
-
# ActiveAgent::Base.generation_method = @old_generation_method
|
|
110
|
-
# end
|
|
111
|
-
|
|
112
|
-
# def set_expected_prompt
|
|
113
|
-
# @expected = ActiveAgent::ActionPrompt::Prompt.new
|
|
114
|
-
# @expected.content_type ["text", "plain", {"charset" => charset}]
|
|
115
|
-
# @expected.mime_version = "1.0"
|
|
116
|
-
# end
|
|
117
|
-
|
|
118
|
-
# def charset
|
|
119
|
-
# "UTF-8"
|
|
120
|
-
# end
|
|
121
|
-
# end
|
|
122
|
-
|
|
123
|
-
# include Behavior
|
|
124
|
-
# end
|
|
125
|
-
# end
|
data/lib/generators/USAGE
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
Description:
|
|
2
|
-
Sets up ActiveAgent in your Rails application by creating the necessary
|
|
3
|
-
configuration files and application agent class.
|
|
4
|
-
|
|
5
|
-
This generator creates:
|
|
6
|
-
- Configuration file (config/active_agent.yml) unless --skip-config is used
|
|
7
|
-
- Application agent base class (app/agents/application_agent.rb)
|
|
8
|
-
- Layout templates for agent views (via template engine hooks)
|
|
9
|
-
|
|
10
|
-
Options:
|
|
11
|
-
--skip-config Skip the creation of config/active_agent.yml
|
|
12
|
-
--formats=FORMAT Specify formats to generate layouts for (default: text)
|
|
13
|
-
Can be one or more of: text, html, json
|
|
14
|
-
Example: --formats=text html json
|
|
15
|
-
|
|
16
|
-
Examples:
|
|
17
|
-
`bin/rails generate active_agent:install`
|
|
18
|
-
|
|
19
|
-
creates the basic ActiveAgent setup with default text format:
|
|
20
|
-
Config: config/active_agent.yml
|
|
21
|
-
Base Agent: app/agents/application_agent.rb
|
|
22
|
-
Layout: app/views/layouts/agent.text.erb
|
|
23
|
-
|
|
24
|
-
`bin/rails generate active_agent:install --formats=text html json`
|
|
25
|
-
|
|
26
|
-
creates ActiveAgent setup with all format layouts:
|
|
27
|
-
Config: config/active_agent.yml
|
|
28
|
-
Base Agent: app/agents/application_agent.rb
|
|
29
|
-
Layouts: app/views/layouts/agent.text.erb
|
|
30
|
-
app/views/layouts/agent.html.erb
|
|
31
|
-
app/views/layouts/agent.json.erb
|
|
32
|
-
|
|
33
|
-
`bin/rails generate active_agent:install --skip-config`
|
|
34
|
-
|
|
35
|
-
creates ActiveAgent setup without configuration file:
|
|
36
|
-
Base Agent: app/agents/application_agent.rb
|
|
37
|
-
Layout: app/views/layouts/agent.text.erb
|
|
38
|
-
|
|
39
|
-
`bin/rails generate active_agent:install --skip-config --formats=html json`
|
|
40
|
-
|
|
41
|
-
creates ActiveAgent setup without config file but with HTML and JSON layouts:
|
|
42
|
-
Base Agent: app/agents/application_agent.rb
|
|
43
|
-
Layouts: app/views/layouts/agent.html.erb
|
|
44
|
-
app/views/layouts/agent.json.erb
|
|
45
|
-
|
|
46
|
-
After running this generator, you can create individual agents with:
|
|
47
|
-
`bin/rails generate active_agent:agent AGENT_NAME ACTION_NAME`
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
Description:
|
|
2
|
-
Generates a new agent and its views. Passes the agent name, either
|
|
3
|
-
CamelCased or under_scored, and an optional list of actions as arguments.
|
|
4
|
-
|
|
5
|
-
This generates an agent class in app/agents and invokes your template
|
|
6
|
-
engine and test framework generators. If no ApplicationAgent exists,
|
|
7
|
-
it will be created automatically.
|
|
8
|
-
|
|
9
|
-
By default, only text format views are created. You can specify which
|
|
10
|
-
formats to generate using the --formats option:
|
|
11
|
-
- text (.text.erb) - for plain text responses (default)
|
|
12
|
-
- html (.html.erb) - for rich text responses
|
|
13
|
-
- json (.json.erb) - for structured function calling responses
|
|
14
|
-
|
|
15
|
-
Options:
|
|
16
|
-
--formats=FORMAT Specify formats to generate views for (default: text)
|
|
17
|
-
Can be one or more of: text, html, json
|
|
18
|
-
Example: --formats=text html json
|
|
19
|
-
|
|
20
|
-
Examples:
|
|
21
|
-
`bin/rails generate active_agent:agent inventory search`
|
|
22
|
-
|
|
23
|
-
creates an inventory agent class with text format view and test:
|
|
24
|
-
Agent: app/agents/inventory_agent.rb
|
|
25
|
-
View: app/views/inventory_agent/search.text.erb
|
|
26
|
-
Test: test/agents/inventory_agent_test.rb
|
|
27
|
-
|
|
28
|
-
`bin/rails generate active_agent:agent inventory search --formats=html json`
|
|
29
|
-
|
|
30
|
-
creates an inventory agent with html and json views:
|
|
31
|
-
Agent: app/agents/inventory_agent.rb
|
|
32
|
-
Views: app/views/inventory_agent/search.html.erb
|
|
33
|
-
app/views/inventory_agent/search.json.erb
|
|
34
|
-
Test: test/agents/inventory_agent_test.rb
|
|
35
|
-
|
|
36
|
-
`bin/rails generate active_agent:agent inventory search update report --formats=text html json`
|
|
37
|
-
|
|
38
|
-
creates an inventory agent with search, update, and report actions in all formats:
|
|
39
|
-
Agent: app/agents/inventory_agent.rb
|
|
40
|
-
Views: app/views/inventory_agent/search.text.erb
|
|
41
|
-
app/views/inventory_agent/search.html.erb
|
|
42
|
-
app/views/inventory_agent/search.json.erb
|
|
43
|
-
app/views/inventory_agent/update.text.erb
|
|
44
|
-
app/views/inventory_agent/update.html.erb
|
|
45
|
-
app/views/inventory_agent/update.json.erb
|
|
46
|
-
app/views/inventory_agent/report.text.erb
|
|
47
|
-
app/views/inventory_agent/report.html.erb
|
|
48
|
-
app/views/inventory_agent/report.json.erb
|
|
49
|
-
Test: test/agents/inventory_agent_test.rb
|
|
50
|
-
|
|
51
|
-
`bin/rails generate active_agent:agent admin/user create --formats=json`
|
|
52
|
-
|
|
53
|
-
creates a namespaced admin/user agent with only JSON view for API responses:
|
|
54
|
-
Agent: app/agents/admin/user_agent.rb
|
|
55
|
-
View: app/views/admin/user_agent/create.json.erb
|
|
56
|
-
Test: test/agents/admin/user_agent_test.rb
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Erb # :nodoc:
|
|
4
|
-
module Generators # :nodoc:
|
|
5
|
-
class InstallGenerator < ::Rails::Generators::Base # :nodoc:
|
|
6
|
-
source_root File.expand_path("templates", __dir__)
|
|
7
|
-
class_option :formats, type: :array, default: [ "text" ], desc: "Specify formats to generate (text, html, json)"
|
|
8
|
-
|
|
9
|
-
def initialize(*args, **kwargs)
|
|
10
|
-
super(*args, **kwargs)
|
|
11
|
-
|
|
12
|
-
# We must duplicate due to immutable hash
|
|
13
|
-
dup_options = options.dup
|
|
14
|
-
@options = dup_options.merge(template_engine: :erb)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def create_agent_layouts
|
|
18
|
-
if behavior == :invoke
|
|
19
|
-
formats.each do |format|
|
|
20
|
-
layout_path = File.join("app/views/layouts", filename_with_extensions("agent", format))
|
|
21
|
-
template filename_with_extensions(:layout, format), layout_path unless File.exist?(layout_path)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
private
|
|
27
|
-
def formats
|
|
28
|
-
options[:formats].map(&:to_sym)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def file_name
|
|
32
|
-
@_file_name ||= super.sub(/_agent\z/i, "")
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def filename_with_extensions(name, file_format = format)
|
|
36
|
-
[ name, file_format, handler ].compact.join(".")
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def handler
|
|
40
|
-
:erb
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%%= yield %>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%%= yield %>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%%= yield %>
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<%%= {
|
|
2
|
-
type: :function,
|
|
3
|
-
function: {
|
|
4
|
-
name: action_name,
|
|
5
|
-
description: "This action takes no params and gets a random cat image and returns it as a base64 string.",
|
|
6
|
-
parameters: {
|
|
7
|
-
type: :object,
|
|
8
|
-
properties: {
|
|
9
|
-
param_name: {
|
|
10
|
-
type: :string,
|
|
11
|
-
description: "The param_description"
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}.to_json.html_safe %>
|
|
File without changes
|
|
File without changes
|