import asyncio

from app.core.settings import get_settings
from app.modules.agents.application.llm_client import LLMClient


async def test_llm():
    settings = get_settings()
    client = LLMClient(settings)

    print("Provider for quynh:", client.get_provider_for_agent("quynh"))

    # Test text completion
    messages = [
        {"role": "system", "content": "You are QS Engineer Quỳnh. Output JSON only."},
        {
            "role": "user",
            "content": "Bóc tách bản vẽ NVH - DAI THANG (Nhà văn hóa thôn Đại Thắng). Xuất JSON với items, drawing_code, drawing_title.",
        },
    ]
    try:
        resp = await client.create_chat_completion(messages, agent_code="quynh")
        print("Response:", resp)
    except Exception as e:
        print("LLM Call Error:", type(e), e)


if __name__ == "__main__":
    asyncio.run(test_llm())
