reframe / tests /test_agent.py
macayaven's picture
first-features (#1)
c6ce43e verified
import os
import pytest
from agents import CBTAgent
requires_hf_token = pytest.mark.skipif(
not (os.getenv("HF_TOKEN") or os.getenv("HUGGINGFACEHUB_API_TOKEN")),
reason="HF Inference token not configured",
)
@requires_hf_token
def test_agent_analyze_thought_with_hf():
agent = CBTAgent()
analysis = agent.analyze_thought("I will fail the interview")
assert isinstance(analysis, dict)
codes = [c for c, _ in analysis.get("distortions", [])]
assert "FT" in codes
assert isinstance(analysis.get("reframe", ""), str) and analysis["reframe"]
assert isinstance(analysis.get("similar_situations", []), list)
@requires_hf_token
def test_agent_generate_response_hf():
agent = CBTAgent()
resp = agent.generate_response("I will definitely mess up the interview")
assert isinstance(resp, str) and len(resp) > 0