Class: Botiasloop::Agent
- Inherits:
-
Object
- Object
- Botiasloop::Agent
- Defined in:
- lib/botiasloop/agent.rb
Class Attribute Summary collapse
-
.instance ⇒ Agent
Singleton instance of the agent.
Class Method Summary collapse
-
.chat(message, conversation: nil, verbose_callback: nil) ⇒ Agent
Singleton instance of the agent (alias for instance).
Instance Method Summary collapse
-
#chat(message, conversation: nil, verbose_callback: nil) ⇒ String
Send a message and get a response.
-
#initialize ⇒ Agent
constructor
Initialize the agent.
Constructor Details
#initialize ⇒ Agent
Initialize the agent
25 26 27 |
# File 'lib/botiasloop/agent.rb', line 25 def initialize setup_ruby_llm end |
Class Attribute Details
.instance ⇒ Agent
Returns Singleton instance of the agent.
11 12 13 |
# File 'lib/botiasloop/agent.rb', line 11 def instance @instance ||= new end |
Class Method Details
.chat(message, conversation: nil, verbose_callback: nil) ⇒ Agent
Returns Singleton instance of the agent (alias for instance).
16 17 18 |
# File 'lib/botiasloop/agent.rb', line 16 def chat(, conversation: nil, verbose_callback: nil) instance.chat(, conversation: conversation, verbose_callback: verbose_callback) end |
Instance Method Details
#chat(message, conversation: nil, verbose_callback: nil) ⇒ String
Send a message and get a response
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/botiasloop/agent.rb', line 35 def chat(, conversation: nil, verbose_callback: nil) conversation ||= Conversation.new registry = create_registry provider, model = create_provider_and_model loop = Loop.new(provider, model, registry, max_iterations: Config.instance.max_iterations) loop.run(conversation, , verbose_callback) rescue MaxIterationsExceeded => e e. end |