Skip to content

Track Answer Method

The track_answer() method allows you to log individual AI responses when you want to track an answer separately from its corresponding question, or in scenarios with complex, multi-step interactions.

Method Signature

python
def track_answer(
    answer: str,
    conversation_id: Optional[str] = None,
    metadata: Optional[Dict[str, Any]] = None
) -> Dict[str, Any]:

Parameters

ParameterTypeRequiredDescription
answerstrYesThe AI agent's response
conversation_idstrNoUnique identifier for the conversation (auto-generated if not provided)
metadataDict[str, Any]NoAdditional contextual information

Complete Usage Example

python
tracker.track_answer(
    answer="Based on your requirements, I suggest using our Enterprise solution.",
    conversation_id="sales_consultation_789",
    metadata={
        "consultation_stage": "recommendation",
        "product_category": "enterprise_software",
        "customer_segment": "large_business"
    }
)