Class: Charai::Agent

Inherits:
Object
  • Object
show all
Defined in:
lib/charai/agent.rb

Defined Under Namespace

Classes: HandleMessageError, Message, Sandbox

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_tool:, openai_chat:) ⇒ Agent

Returns a new instance of Agent.



10
11
12
13
14
15
16
# File 'lib/charai/agent.rb', line 10

def initialize(input_tool:, openai_chat:)
  input_tool.on_send_message do |message|
    send_message_to_openai_chat(message)
  end
  @sandbox = Sandbox.new(input_tool)
  @openai_chat = openai_chat
end

Instance Attribute Details

#last_messageObject (readonly)

Returns the value of attribute last_message.



23
24
25
# File 'lib/charai/agent.rb', line 23

def last_message
  @last_message
end

Instance Method Details

#<<(text) ⇒ Object



18
19
20
21
# File 'lib/charai/agent.rb', line 18

def <<(text)
  message = Message.new(text: text)
  send_message_to_openai_chat(message)
end