Class: Foobara::Agent::DetermineNextCommand

Inherits:
LlmBackedCommand
  • Object
show all
Extended by:
Concerns::SubclassCacheable
Defined in:
foobara-agent-0.0.5/src/foobara/agent/determine_next_command.rb

Class Method Summary collapse

Class Method Details

.for(command_class_names:, agent_id:) ⇒ Object

Allows us to give a more meaningful result type



10
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
# File 'foobara-agent-0.0.5/src/foobara/agent/determine_next_command.rb', line 10

def for(command_class_names:, agent_id:)
  cached_subclass(agent_id) do
    command_name = "Foobara::Agent::#{agent_id}::DetermineNextCommand"
    klass = Util.make_class_p(command_name, self)

    klass.description "Accepts the current goal, which might already be accomplished, " \
                      "and context of the work  " \
                      "so far and returns the name of " \
                      "the next command to run to make progress towards " \
                      "accomplishing the goal. If the goal has already been accomplished then choose the " \
                      "NotifyUserThatCurrentGoalHasBeenAccomplished command."

    klass.inputs do
      goal :string, :required, "The current goal to accomplish. If the goal has already been accomplished " \
                               "by the previous command runs then choose " \
                               "NotifyUserThatCurrentGoalHasBeenAccomplished to stop the loop."
      context Context, :required, "Context of progress so far"
      llm_model :string,
                one_of: Foobara::Ai::AnswerBot::Types::ModelEnum,
                default: "claude-3-7-sonnet-20250219",
                description: "The model to use for the LLM"
    end

    klass.result :string,
                 one_of: command_class_names,
                 description: "Name of the next command to run to make progress " \
                              "towards accomplishing the mission"

    klass
  end
end