Class: AgentRuby::Prompt::Summarize

Inherits:
Object
  • Object
show all
Defined in:
lib/agent_ruby/prompt/summarize.rb

Instance Method Summary collapse

Constructor Details

#initialize(results:) ⇒ Summarize

Returns a new instance of Summarize.



6
7
8
# File 'lib/agent_ruby/prompt/summarize.rb', line 6

def initialize(results:)
  @results = results
end

Instance Method Details

#to_sObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/agent_ruby/prompt/summarize.rb', line 10

def to_s
  <<~XML
    <Instruction>
      <Item>
        The workflow has been executed. Here are the results:
        #{
          @results.map { |r|
            "Task: #{r.action.key}, Params: #{r.action.class.arguments.to_json}, Result: #{r.result}"
          }.join("\n")
        }
        Now, please summarize the results in a single JSON object
      </Item>
    </Instruction>

    <Example type="success">
      <Message>
        I have created a folder named "My Folder" and a post titled "My Post" with content "This is my post" in the folder "My Folder"
      </Message>
    </Example>
  XML
end