diff --git a/pyproject.toml b/pyproject.toml index 6f76319..4a860f2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,7 @@ requires-python = ">=3.8" [project.optional-dependencies] dev = [ "pytest>=7.4.0", + "pytest-asyncio>=0.21.0", "black>=23.7.0", "isort>=5.12.0", "mypy>=1.4.1", @@ -26,10 +27,15 @@ dev = [ requires = ["hatchling"] build-backend = "hatchling.build" +[tool.hatch.build.targets.wheel] +packages = ["."] + [tool.pytest.ini_options] testpaths = ["tests"] python_files = ["test_*.py"] addopts = "-v" +asyncio_mode = "strict" +asyncio_default_fixture_loop_scope = "function" [tool.black] line-length = 100 diff --git a/tests/test_llm.py b/tests/test_llm.py index b24cefb..2ea2583 100644 --- a/tests/test_llm.py +++ b/tests/test_llm.py @@ -1,8 +1,10 @@ """Test LLM API call.""" import asyncio +import pytest from config.config_loader import load_config import httpx +@pytest.mark.asyncio async def test_llm_call(): """Test LLM API call with a simple prompt.""" config = load_config() @@ -19,8 +21,8 @@ async def test_llm_call(): "messages": [ {"role": "user", "content": "Say hello and introduce yourself in one sentence."} ], - "temperature": llm_config["temperature"], - "max_tokens": llm_config["max_tokens"] + "temperature": llm_config.get("temperature", 0.7), + "max_tokens": llm_config.get("max_tokens", 2000) } print("Making API call to Deepseek...") @@ -40,6 +42,15 @@ async def test_llm_call(): print("\nResponse:") print(result["choices"][0]["message"]["content"]) + assert response.status_code == 200 + assert "choices" in result + assert len(result["choices"]) > 0 + assert "message" in result["choices"][0] + assert "content" in result["choices"][0]["message"] + content = result["choices"][0]["message"]["content"] + assert isinstance(content, str) + assert len(content) > 0 + except httpx.HTTPStatusError as e: print(f"HTTP error occurred: {e.response.text}") except Exception as e: