Camel.agents.critic agent
CriticAgent
A class for the critic agent that assists in selecting an option.
Parameters:
- system_message (Union[BaseMessage, str], optional): The system message for the chat agent. (default: :obj:
None
) model (Union[BaseModelBackend, Tuple[str, str], str, ModelType, Tuple[ModelPlatformType, ModelType], List[BaseModelBackend], List[str], List[ModelType], List[Tuple[str, str]], List[Tuple[ModelPlatformType, ModelType]]], optional): The model backend(s) to use. Can be a single instance, a specification (string, enum, tuple), or a list of instances or specifications to be managed byModelManager
. If a list of specifications (notBaseModelBackend
instances) is provided, they will be instantiated usingModelFactory
. (default: :obj:ModelPlatformType.DEFAULT
withModelType.DEFAULT
) - message_window_size (int, optional): The maximum number of previous messages to include in the context window. If
None
, no windowing is performed. (default: :obj:6
) - retry_attempts (int, optional): The number of retry attempts if the critic fails to return a valid option. (default: :obj:
2
) - verbose (bool, optional): Whether to print the critic’s messages.
- logger_color (Any): The color of the menu options displayed to the user. (default: :obj:
Fore.MAGENTA
)
init
flatten_options
Flattens the options to the critic.
Parameters:
- messages (Sequence[BaseMessage]): A list of
BaseMessage
objects.
Returns:
str: A string containing the flattened options to the critic.
get_option
Gets the option selected by the critic.
Parameters:
- input_message (BaseMessage): A
BaseMessage
object representing the input message.
Returns:
str: The option selected by the critic.
parse_critic
Parses the critic’s message and extracts the choice.
Parameters:
- critic_msg (BaseMessage): A
BaseMessage
object representing the critic’s response.
Returns:
Optional[str]: The critic’s choice as a string, or None if the message could not be parsed.
reduce_step
Performs one step of the conversation by flattening options to the critic, getting the option, and parsing the choice.
Parameters:
- input_messages (Sequence[BaseMessage]): A list of BaseMessage objects.
Returns:
ChatAgentResponse: A ChatAgentResponse
object includes the
critic’s choice.
clone
Creates a new instance of :obj:CriticAgent
with the same
configuration as the current instance.
Parameters:
- with_memory (bool): Whether to copy the memory (conversation history) to the new agent. If True, the new agent will have the same conversation history. If False, the new agent will have a fresh memory with only the system message. (default: :obj:
False
)
Returns:
CriticAgent: A new instance of :obj:CriticAgent
with the same
configuration.