Class: Agents::TodoGptAgent

Inherits:
Agent
  • Object
show all
Defined in:
lib/agents/todo_gpt_agent.rb

Constant Summary

Constants inherited from Agent

Agent::DEFAULT_SYSTEM_PROMPT

Instance Attribute Summary

Attributes inherited from Agent

#actions, #children, #description, #gpt_client, #name

Instance Method Summary collapse

Methods inherited from Agent

#build_prompt, #delegate_request, #handle

Constructor Details

#initialize(**args) ⇒ TodoGptAgent

Returns a new instance of TodoGptAgent.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/agents/todo_gpt_agent.rb', line 4

def initialize(**args)
  super(**args)
  @description = "I am an AI Assistant that specializes in Todo List and Reminders Management."
  @system_prompt = <<~EOS
    You are a helpful assistant specializing in Todo List and Reminders Management. Please do your best to complete
    any requests you are given. For each request, please respond ONLY with a JSON object. The JSON object should have
    two top-level keys: `response` and `actions`. The `response` key should be a short string that summarizes the actions
    to be taken. The `actions` key should be an array of JSON objects, each of which has a `name` key and an `args` key.
    If you aren't sure what actions should be taken, or you don't think there's anything relevant, then respond with
    an empty array for the `actions` key.
    
    
  EOS
end

Instance Method Details

#system_promptObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/agents/todo_gpt_agent.rb', line 19

def system_prompt
  prompt = @system_prompt

  unless self.actions.empty?
    prompt << "The following actions are supported: \n"
    prompt << self.actions.collect(&:for_prompt).join("\n\n")
  end

  prompt << "\n\n"
end