agentlab.agents.generic_agent.generic_agent_prompt

Prompt builder for GenericAgent

It is based on the dynamic_prompting module from the agentlab package.

Classes

Criticise([visible])

GenericPromptFlags(obs, action[, use_plan, ...])

A class to represent various flags used to control features in an application.

MainPrompt(action_set, obs_history, actions, ...)

Memory([visible])

Plan(previous_plan, plan_step[, visible])

class agentlab.agents.generic_agent.generic_agent_prompt.Criticise(visible: bool = True)

Bases: PromptElement

class agentlab.agents.generic_agent.generic_agent_prompt.GenericPromptFlags(obs: ObsFlags, action: ActionFlags, use_plan: bool = False, use_criticise: bool = False, use_thinking: bool = False, use_memory: bool = False, use_concrete_example: bool = True, use_abstract_example: bool = False, use_hints: bool = False, enable_chat: bool = False, max_prompt_tokens: int = None, be_cautious: bool = True, extra_instructions: str | None = None, add_missparsed_messages: bool = True, max_trunc_itr: int = 20, flag_group: str = None)

Bases: Flags

A class to represent various flags used to control features in an application.

use_plan

Ask the LLM to provide a plan.

Type:

bool

use_criticise

Ask the LLM to first draft and criticise the action before producing it.

Type:

bool

use_thinking

Enable a chain of thoughts.

Type:

bool

use_concrete_example

Use a concrete example of the answer in the prompt for a generic task.

Type:

bool

use_abstract_example

Use an abstract example of the answer in the prompt.

Type:

bool

use_hints

Add some human-engineered hints to the prompt.

Type:

bool

enable_chat

Enable chat mode, where the agent can interact with the user.

Type:

bool

max_prompt_tokens

Maximum number of tokens allowed in the prompt.

Type:

int

be_cautious

Instruct the agent to be cautious about its actions.

Type:

bool

extra_instructions

Extra instructions to provide to the agent.

Type:

Optional[str]

add_missparsed_messages

When retrying, add the missparsed messages to the prompt.

Type:

bool

flag_group

Group of flags used.

Type:

Optional[str]

action: ActionFlags
add_missparsed_messages: bool = True
be_cautious: bool = True
enable_chat: bool = False
extra_instructions: str | None = None
flag_group: str = None
max_prompt_tokens: int = None
max_trunc_itr: int = 20
obs: ObsFlags
use_abstract_example: bool = False
use_concrete_example: bool = True
use_criticise: bool = False
use_hints: bool = False
use_memory: bool = False
use_plan: bool = False
use_thinking: bool = False
class agentlab.agents.generic_agent.generic_agent_prompt.MainPrompt(action_set: AbstractActionSet, obs_history: list[dict], actions: list[str], memories: list[str], thoughts: list[str], previous_plan: str, step: int, flags: GenericPromptFlags)

Bases: Shrinkable

shrink()

Implement shrinking of this prompt element.

You need to recursively call all shrinkable elements that are part of this prompt. You can also implement a shriking startegy for this prompt. Shrinking is can be called multiple times to progressively shrink the prompt until it fits max_tokens. Default max shrink iterations is 20.

class agentlab.agents.generic_agent.generic_agent_prompt.Memory(visible: bool = True)

Bases: PromptElement

class agentlab.agents.generic_agent.generic_agent_prompt.Plan(previous_plan, plan_step, visible: bool = True)

Bases: PromptElement