mirror of
https://github.com/ZTatman/Nadir.git
synced 2026-11-20 20:08:00 +00:00
Update backend/query.py
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
parent
9d4f96e405
commit
6fdf8f67dd
1 changed files with 5 additions and 2 deletions
|
|
@ -65,11 +65,14 @@ def query_entries(user_question: str) -> str:
|
|||
"""
|
||||
|
||||
# ── 4. Send to model and return response ──────────────────────────
|
||||
response = client.chat.completions.create(
|
||||
try:
|
||||
response = client.with_options(timeout=30.0).chat.completions.create(
|
||||
model=model, messages=[{"role": "user", "content": prompt}]
|
||||
)
|
||||
return response.choices[0].message.content
|
||||
except (APITimeoutError, APIConnectionError):
|
||||
return "I couldn't reach the local model right now. Please try again."
|
||||
|
||||
return (response.choices[0].message.content or "").strip()
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Interactive CLI loop for testing
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue