File size: 1,213 Bytes
395651c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import asyncio
import logging
import os

import pytest
from dotenv import load_dotenv

from app.llm_client import get_llm_client

logging.basicConfig(level=logging.INFO)
load_dotenv()


def _openrouter_configured() -> bool:
    return bool(os.getenv("OPENROUTER_API_KEY_1") or os.getenv("OPENROUTER_API_KEY"))


@pytest.mark.real_agents
@pytest.mark.asyncio
async def test_real_llm():
    if not _openrouter_configured():
        pytest.skip("OPENROUTER_API_KEY_1 or OPENROUTER_API_KEY not set")

    client = get_llm_client()
    if getattr(client, "client", None) is None:
        pytest.skip("LLM client not configured")

    content = await client.chat_completions_create(
        messages=[
            {
                "role": "system",
                "content": (
                    "You are a Geometry Expert. Give a short step-by-step reasoning for the distance "
                    "between midpoints M of AB and N of AD in rectangle ABCD with AB=10 and AD=20."
                ),
            },
            {"role": "user", "content": "Solve briefly."},
        ]
    )
    assert isinstance(content, str) and len(content.strip()) > 20


if __name__ == "__main__":
    asyncio.run(test_real_llm())