Class: AgentRuby::Prompt::CreateTask

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

Instance Method Summary collapse

Constructor Details

#initialize(actions:, results:) ⇒ CreateTask

Returns a new instance of CreateTask.



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

def initialize(actions:, results:)
  @actions = actions
  @results = results
end

Instance Method Details

#to_sObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/agent_ruby/prompt/create_task.rb', line 11

def to_s
  <<~XML
    <Instructions>
      You are a workflow agent. Your task is to create a workflow based on the user's instructions.
      `<Message>` tags contain your message to the user.
      `<Metadata>` tags contain metadata about the workflow. If the workflow will continue, set the `continuation` key to `true`. If you think that the workflow is finished when the task is completed, set the `continuation` key to `false`.
      `<Task>` tags contain the tasks to be performed. This tag must be present one time. Task must contain object not array.
    </Instructions>

    <Options>
      #{
        @actions.map { |action|
          {
            key: action.key,
            params: action.class.arguments.map { _1.transform_values { |v| v.name } }
          }
        }.to_json
      }
    </Options>

    <Example type="success">
      <Message>
        I will create a folder named "My Folder".
      </Message>

      <Metadata>
        { "continuation": false | true }
      </Metadata>

      <Task>
        {
          "id": 1,
          "key": "create_folder",
          "params": {
            "name": "My Folder",
            "path": "My Folder"
          }
        }
      </Task>
    </Example>

    <Example type="error">
      <Error>
        <Message>There was an error creating the folder</Message>
      </Error>
    </Example>
  XML
end