Class: SolidAgent::Generators::AgentGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- SolidAgent::Generators::AgentGenerator
- Defined in:
- lib/generators/solid_agent/agent/agent_generator.rb
Instance Method Summary collapse
- #create_agent_file ⇒ Object
- #create_tools_directory ⇒ Object
- #create_view_directory ⇒ Object
- #show_next_steps ⇒ Object
Instance Method Details
#create_agent_file ⇒ Object
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 = [:parent] @include_context = [:context] @context_name = [:context_name] @contextual = [:contextual] @include_tools = [:tools] @include_streaming = [:streaming] @actions = [:actions] template "agent.rb.erb", "app/agents/#{file_name}_agent.rb" end |
#create_tools_directory ⇒ Object
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_directory ⇒ Object
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_steps ⇒ Object
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 |