Class: OmniAgent::Generators::AgentGenerator

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

Instance Method Summary collapse

Instance Method Details

#create_agent_structureObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/generators/omni_agent/agent/agent_generator.rb', line 17

def create_agent_structure
  FileUtils.mkdir_p(agent_directory)

  create_file(agent_file_path, <<~RUBY)
    class #{class_name} < OmniAgent::Agent
      use_model #{generated_model_expression}
    end
  RUBY

  create_file(prompt_file_path, <<~ERB)
    You are #{class_name}, a helpful assistant with access to local tools.
  ERB
end

#create_tools_if_requestedObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/generators/omni_agent/agent/agent_generator.rb', line 31

def create_tools_if_requested
  return unless with_tools_requested?

  FileUtils.mkdir_p(tools_directory)

  scaffold_names = requested_tool_names
  scaffold_names.each do |tool_name|
    create_file(tool_file_path(tool_name), tool_template(tool_name))
  end
end