"""LLM service — DeepSeek API""" import logging from openai import AsyncOpenAI from config import settings logger = logging.getLogger("kira.llm") def _get_client() -> AsyncOpenAI: return AsyncOpenAI( api_key=settings.deepseek_api_key, base_url=settings.deepseek_base_url, ) async def get_kira_response(messages: list[dict]) -> str: """Get Kira's response from the LLM.""" try: client = _get_client() resp = await client.chat.completions.create( model=settings.deepseek_model, messages=messages, max_tokens=300, temperature=0.7, ) return resp.choices[0].message.content or "Mhm, I'm here!" except Exception as e: logger.error(f"LLM error: {e}") return "I'm still here with you! Could you say that again?"