LeomordKaly commited on
Commit
eabe994
·
verified ·
1 Parent(s): 925162d

deploy: phase 3 BYOK backend (Dockerfile.hf, FastAPI on 7860)

Browse files
core/agents/router.py CHANGED
@@ -185,7 +185,27 @@ async def call_llm_stream(
185
  yield token
186
  except Exception as exc:
187
  logger.error("call_llm_stream_failed", error=str(exc))
188
- yield "[Error generating response]"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
 
190
 
191
  def _get_routing_prompt(query: str) -> str:
 
185
  yield token
186
  except Exception as exc:
187
  logger.error("call_llm_stream_failed", error=str(exc))
188
+ # Map common failure modes to actionable user-facing copy. Bare
189
+ # "[Error generating response]" left visitors guessing whether
190
+ # the bug was in the corpus, the prompt, or the LLM provider.
191
+ err_text = str(exc).lower()
192
+ if "429" in err_text or "rate" in err_text or "quota" in err_text:
193
+ yield (
194
+ "Sorry — the demo's shared Groq quota is exhausted for "
195
+ "this hour. Paste your own Groq / OpenAI / Anthropic key "
196
+ "via the 🔑 button at the top of the page for an "
197
+ "unthrottled bucket."
198
+ )
199
+ elif "timeout" in err_text or "connect" in err_text:
200
+ yield (
201
+ "The LLM provider didn't respond in time. Try again in a "
202
+ "few seconds, or paste your own key via the 🔑 button."
203
+ )
204
+ else:
205
+ yield (
206
+ "I couldn't reach the LLM provider this turn. Try again, "
207
+ "or paste your own key via the 🔑 button at the top."
208
+ )
209
 
210
 
211
  def _get_routing_prompt(query: str) -> str:
core/agents/synthesizer.py CHANGED
@@ -352,6 +352,13 @@ def _compute_synthesis_confidence(
352
  def _add_disclaimers(response: str, sensitivity_level: str) -> str:
353
  """Add disclaimers to the response based on sensitivity level.
354
 
 
 
 
 
 
 
 
355
  Args:
356
  response: The generated response text.
357
  sensitivity_level: The sensitivity level of the documents used.
@@ -359,6 +366,8 @@ def _add_disclaimers(response: str, sensitivity_level: str) -> str:
359
  Returns:
360
  Response text with appropriate disclaimers appended.
361
  """
 
 
362
  if sensitivity_level == "high":
363
  disclaimer = (
364
  "\n\n---\n"
 
352
  def _add_disclaimers(response: str, sensitivity_level: str) -> str:
353
  """Add disclaimers to the response based on sensitivity level.
354
 
355
+ In BYOK demo mode the UI already shows a ``sensitivity: <level>``
356
+ badge under every answer, so appending a verbal disclaimer doubles
357
+ the signal and clutters short answers ("Use MFA. -- Note: this
358
+ response references documents with moderate sensitivity..."). The
359
+ badge is the canonical surface for the BYOK demo; the verbal
360
+ disclaimer stays on for production deploys.
361
+
362
  Args:
363
  response: The generated response text.
364
  sensitivity_level: The sensitivity level of the documents used.
 
366
  Returns:
367
  Response text with appropriate disclaimers appended.
368
  """
369
+ if settings.byok_mode:
370
+ return response
371
  if sensitivity_level == "high":
372
  disclaimer = (
373
  "\n\n---\n"