Update backend/query.py

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
Zach Tatman 2026-03-18 23:02:34 -04:00 • committed by GitHub
parent 9d4f96e405
commit 6fdf8f67dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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