Spaces:
Sleeping
Sleeping
| 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", | |
| ) | |
| 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) | |
| 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 | |