from adaptive_harmony.core.structured_output import render_schema
instructions = f"""Analyze the support call, reason about the sentiment of the customer, and whether they wanted to escalate to a human.
Your output must comply with the following format, valid JSON output only:
{render_schema(CallAnalysisFormat)}"""
call_content = "Enough of this!! I am mad, I want to speak to a human"
groundtruth_labels = {"sentiment": "angry", "escalation": True}
# label is correct
correct_completion = CallAnalysisFormat(
reason="It is clear that the content indicates anger and an escalation", sentiment="angry", escalation=True
).model_dump_json(indent=2)
# labels are incorrect
incorrect_completion = CallAnalysisFormat(
reason="The customer sounded very happe", sentiment="happy", escalation=False
).model_dump_json(indent=2)
# malformed completion; predicted label does not exist in list of possible labels, escalation is not a bool
malformed_completion = """{
"reason": "this is the reason",
"sentiment": "very-very-happy",
"escalation": "YES"
}"""
correct_thread = StringThread(
turns=[("system", instructions), ("user", call_content), ("assistant", correct_completion)],
metadata=groundtruth_labels,
)
incorrect_thread = StringThread(
turns=[("system", instructions), ("user", call_content), ("assistant", incorrect_completion)],
metadata=groundtruth_labels,
)
malformed_thread = StringThread(
turns=[("system", instructions), ("user", call_content), ("assistant", malformed_completion)],
metadata=groundtruth_labels,
)
print(correct_thread)
print(incorrect_thread)
print(malformed_thread)