ai_validator ============ .. py:module:: ai_validator Functions --------- .. autoapisummary:: ai_validator.make_hooked_reply Module Contents --------------- .. py:function:: make_hooked_reply(run_geom_command, original_reply) 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: 1. Calls the original `generate_reply` to get the assistant's output. 2. Extracts the CLI command from the reply. 3. Executes the command using `run_geom_command()` if it's not an error. 4. Appends 'TERMINATE' to the reply to signal AutoGen to stop the loop. :param run_geom_command: A function that executes a valid GEOM command string. :type run_geom_command: Callable[[str], None] :param original_reply: The original `generate_reply` method of the assistant. :type original_reply: Callable :returns: A wrapped `generate_reply` function that handles command execution and forces termination signaling. :rtype: Callable Example Usage: geom_assistant.generate_reply = make_hooked_reply(run_geom_command, geom_assistant.generate_reply)