reframe / tests /test_agent.py
macayaven's picture
feat: initial implementation of the re-frame Cognitive Reframing Assistant, including core functionality, UI components, and localization support. Added .gitignore, configuration files, and initial tests.
27fd523
Raw
History Blame
854 Bytes
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