ai_validator
Functions
|
Creates a wrapped version of an assistant's generate_reply method that injects |
Module Contents
- ai_validator.make_hooked_reply(run_geom_command, original_reply)[source]
Creates a wrapped version of an assistant’s generate_reply method that injects post-processing logic for GEOM command execution and controlled termination.
This function is intended to be used to monkey-patch an assistant agent’s generate_reply method in AutoGen. When the assistant is called to reply during a chat (via generate_reply(history)), the returned hooked_reply function:
Calls the original generate_reply to get the assistant’s output.
Extracts the CLI command from the reply.
Executes the command using run_geom_command() if it’s not an error.
Appends ‘TERMINATE’ to the reply to signal AutoGen to stop the loop.
- Parameters:
run_geom_command (Callable[[str], None]) – A function that executes a valid GEOM command string.
original_reply (Callable) – The original generate_reply method of the assistant.
- Returns:
A wrapped generate_reply function that handles command execution and forces termination signaling.
- Return type:
Callable
- Example Usage:
geom_assistant.generate_reply = make_hooked_reply(run_geom_command, geom_assistant.generate_reply)