Class: ComposableAgents::AiAgents::Tools::CreateArtifactTool

Inherits:
BaseTool
  • Object
show all
Defined in:
lib/composable_agents/ai_agents/tools/create_artifact_tool.rb

Overview

Tool that is used to create a new artifact's content

Internal collapse

Constructor Details

#initialize(agent, logger: ComposableAgents::Logger.instance) ⇒ CreateArtifactTool

Constructor

Parameters:

  • agent (PromptDrivenAgent)

    The agent that will receive output artifacts

  • logger (::Logger) (defaults to: ComposableAgents::Logger.instance)

    Logger to be used by this tool. Any Ruby-like logger is accepted. Defaults to ComposableAgents::Logger's singleton instance.



21
22
23
24
# File 'lib/composable_agents/ai_agents/tools/create_artifact_tool.rb', line 21

def initialize(agent, logger: ComposableAgents::Logger.instance)
  super(logger:)
  @agent = agent
end

Instance Method Details

#perform(_tool_context, name:, content:) ⇒ String

Perform the tool's action. This is called by ai-agents when the model requires it.

Parameters:

  • _tool_context (Agents::ToolContext)

    The tool context

  • name (String)

    The required artifact's name

  • content (String)

    The required artifact's content

Returns:

  • (String)

    The tool's response



33
34
35
36
# File 'lib/composable_agents/ai_agents/tools/create_artifact_tool.rb', line 33

def perform(_tool_context, name:, content:)
  @agent.save_output_artifact(name.to_sym, content)
  "Artifact `#{name}` created successfully."
end