From 6fdf8f67ddc6522dca44aa3bd7b9cb61332763e1 Mon Sep 17 00:00:00 2001 From: Zach Tatman Date: Wed, 18 Mar 2026 23:02:34 -0400 Subject: [PATCH] Update backend/query.py Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- backend/query.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/query.py b/backend/query.py index 815dea4..b434199 100644 --- a/backend/query.py +++ b/backend/query.py @@ -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