Class: SolidAgent::Generators::AgentGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/solid_agent/agent/agent_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_agent_fileObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/generators/solid_agent/agent/agent_generator.rb', line 33

def create_agent_file
  @parent_class = options[:parent]
  @include_context = options[:context]
  @context_name = options[:context_name]
  @contextual = options[:contextual]
  @include_tools = options[:tools]
  @include_streaming = options[:streaming]
  @actions = options[:actions]

  template "agent.rb.erb", "app/agents/#{file_name}_agent.rb"
end

#create_tools_directoryObject



54
55
56
57
58
# File 'lib/generators/solid_agent/agent/agent_generator.rb', line 54

def create_tools_directory
  return unless @include_tools

  empty_directory "app/views/#{file_name}_agent/tools"
end

#create_view_directoryObject



45
46
47
48
49
50
51
52
# File 'lib/generators/solid_agent/agent/agent_generator.rb', line 45

def create_view_directory
  empty_directory "app/views/#{file_name}_agent"

  @actions.each do |action|
    template "action.text.erb", "app/views/#{file_name}_agent/#{action}.text.erb",
      action_name: action
  end
end

#show_next_stepsObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/generators/solid_agent/agent/agent_generator.rb', line 60

def show_next_steps
  say ""
  say "Agent created successfully!", :green
  say ""
  say "Files generated:"
  say "  app/agents/#{file_name}_agent.rb"
  say "  app/views/#{file_name}_agent/"
  @actions.each do |action|
    say "  app/views/#{file_name}_agent/#{action}.text.erb"
  end
  say "  app/views/#{file_name}_agent/tools/" if @include_tools
  say ""

  if @include_tools
    say "To add tools, run:", :yellow
    say "  rails g solid_agent:tool search #{class_name}Agent --parameters query:string:required --description \"Search for content\""
    say ""
  end

  say "Example usage:", :yellow
  say "  #{class_name}Agent.with(content: \"Hello\").#{@actions.first}.generate_now"
  say ""
end