Wrap your AI application (target agent) in a wrapper_function that follows the following structure:

Python
from typing import Tuple, List, Dict

def wrapper_function(
    conversation_id: str,
    maihem_agent_message: str,
    conversation_history: Dict 
) -> Tuple[str, List[str]]:
    """Callable wrapper function to wrap your target agent to be tested."""
    # params:
	# - conversation_id: unique conversation ID generated by Maihem, use it to keep track of different conversations
	# - agent_maihem_msg: message from the Maihem Agent
    # - conversation_history: auxiliary dictionary to store conversation history (if needed)
    # 
	# return:
	# - agent_target_message [str] - message from your Target Agent in response to the Maihem Agent message
	# - contexts [List[str]] - list of contexts (required for RAG evaluations), pass empty list if not needed
    
    # Replace with the message from your target agent
    target_agent_message = "Hi, how can I help you?"

    # If target initiates conversation, first maihem_agent_message is None

    # (Optional) add messages to conversation history
    conversation_history[conversation_id].append({"role": "maihem", "content": maihem_agent_message})
    conversation_history[conversation_id].append({"role": "target", "content": target_agent_message})
    
    # List of retrieved contexts for RAG evaluations, pass empty list if not needed
    contexts = ["Context_1", "Context_2"] 
    
    return target_agent_message, contexts
  • When using Maihem in the CLI, save the function in a file called wrapper_function.py
  • When using the Python SDK, simply pass it as a function