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

Inherits:
Agents::Tool
  • Object
show all
Includes:
Mixins::Logger
Defined in:
lib/composable_agents/ai_agents/tools/create_artifact_tool.rb

Overview

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

Instance Method Summary collapse

Methods included from Mixins::Logger

debug?

Constructor Details

#initialize(agent) ⇒ CreateArtifactTool

Constructor

Parameters:



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

def initialize(agent)
  super()
  @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