@@ -114,7 +114,8 @@ async def _identify_language(
114114 litellm_model = LITELLM_MODEL_LANGUAGE_DETECT ,
115115 metadata = metadata ,
116116 system_message = LANGUAGE_ID_PROMPT ,
117- user_message = query_refined .query_text ,
117+ # Always use the original query text for language and script detection
118+ user_message = query_refined .query_text_original ,
118119 )
119120
120121 cleaned_json_str = remove_json_markdown (text = json_str )
@@ -256,9 +257,10 @@ async def wrapper(
256257 The appropriate response object.
257258 """
258259
259- query_refined , response = await _translate_question (
260- query_refined = query_refined , response = response
261- )
260+ if not query_refined .chat_query_params :
261+ query_refined , response = await _translate_question (
262+ query_refined = query_refined , response = response
263+ )
262264 response = await func (query_refined , response , * args , ** kwargs )
263265
264266 return response
@@ -492,9 +494,11 @@ async def wrapper(
492494 The appropriate response object.
493495 """
494496
495- query_refined , response = await _paraphrase_question (
496- query_refined = query_refined , response = response
497- )
497+ if not query_refined .chat_query_params :
498+ query_refined , response = await _paraphrase_question (
499+ query_refined = query_refined , response = response
500+ )
501+
498502 response = await func (query_refined , response , * args , ** kwargs )
499503
500504 return response
0 commit comments