Skip to content

Commit 972920c

Browse files
committed
HOTFIX: /voice-search now handles QueryResponseError correctly
1 parent afa88e8 commit 972920c

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

core_backend/app/llm_call/process_output.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ async def generate_llm_query_response(
5454
Requires "search_results" and "original_language" in the response.
5555
"""
5656
if isinstance(response, QueryResponseError):
57+
logger.warning("LLM generation skipped due to QueryResponseError.")
5758
return response
5859

5960
if response.search_results is None:
@@ -136,7 +137,8 @@ async def _check_align_score(
136137
Only runs if the generate_llm_response flag is set to True.
137138
Requires "llm_response" and "search_results" in the response.
138139
"""
139-
if isinstance(response, QueryResponseError) or response.llm_response is None:
140+
if isinstance(response, QueryResponseError):
141+
logger.warning("Alignment score check skipped due to QueryResponseError.")
140142
return response
141143

142144
if response.search_results is not None:
@@ -148,7 +150,10 @@ async def _check_align_score(
148150
if response.llm_response is not None:
149151
claim = response.llm_response
150152
else:
151-
logger.warning(("No llm_response found in the response."))
153+
logger.warning(
154+
"No llm_response found in the response "
155+
"(should have been caught with QueryResponseError)."
156+
)
152157
return response
153158

154159
align_score_data = AlignScoreData(evidence=evidence, claim=claim)
@@ -237,10 +242,12 @@ async def wrapper(
237242
if not query_refined.generate_tts:
238243
return response
239244

240-
if not isinstance(response, QueryAudioResponse):
241-
logger.warning(
242-
f"Converting response of type {type(response)} to AudioResponse."
243-
)
245+
if isinstance(response, QueryResponseError):
246+
logger.warning("TTS generation skipped due to QueryResponseError.")
247+
return response
248+
249+
if isinstance(response, QueryResponse):
250+
logger.info("Converting response type QueryResponse to AudioResponse.")
244251
response = QueryAudioResponse(
245252
query_id=response.query_id,
246253
session_id=response.session_id,
@@ -271,20 +278,19 @@ async def _generate_tts_response(
271278
Requires valid `llm_response` and alignment score in the response.
272279
"""
273280

274-
if isinstance(response, QueryResponseError):
275-
logger.warning("TTS generation skipped due to QueryResponseError.")
276-
return response
277-
278281
if response.llm_response is None:
279-
logger.warning("TTS generation skipped due to missing LLM response.")
282+
logger.warning(
283+
"TTS generation skipped due to missing LLM response "
284+
"(should have been caught with QueryResponseError)."
285+
)
280286
return response
281287

282-
try:
283-
if query_refined.original_language is None:
284-
error_msg = "Language must be provided to generate speech."
285-
logger.error(error_msg)
286-
raise ValueError(error_msg)
288+
if query_refined.original_language is None:
289+
error_msg = "Language must be provided to generate speech."
290+
logger.error(error_msg)
291+
raise ValueError(error_msg)
287292

293+
try:
288294
tts_file_path = await generate_tts_on_gcs(
289295
text=response.llm_response,
290296
language=query_refined.original_language,

0 commit comments

Comments
 (0)