File tree Expand file tree Collapse file tree 1 file changed +15
-14
lines changed
Expand file tree Collapse file tree 1 file changed +15
-14
lines changed Original file line number Diff line number Diff line change @@ -328,22 +328,23 @@ def _get_llm_response(
328328 Returns:
329329 LLM response dictionary
330330 """
331- # Try to extract actual text content from sources for better language detection
332- text_for_lang_detection = mem_str
331+ # Determine language: prioritize lang from sources (set in fast mode),
332+ # fallback to detecting from mem_str if sources don't have lang
333+ lang = None
334+
335+ # First, try to get lang from sources (fast mode already set this)
333336 if sources :
334- source_texts = []
335337 for source in sources :
336- if hasattr (source , "content" ) and source .content :
337- source_texts .append (source .content )
338- elif isinstance (source , dict ) and source .get ("content" ):
339- source_texts .append (source .get ("content" ))
340-
341- # If we have text content from sources, use it for language detection
342- if source_texts :
343- text_for_lang_detection = " " .join (source_texts )
344-
345- # Use the extracted text for language detection
346- lang = detect_lang (text_for_lang_detection )
338+ if hasattr (source , "lang" ) and source .lang :
339+ lang = source .lang
340+ break
341+ elif isinstance (source , dict ) and source .get ("lang" ):
342+ lang = source .get ("lang" )
343+ break
344+
345+ # Fallback: detect language from mem_str if no lang from sources
346+ if lang is None :
347+ lang = detect_lang (mem_str )
347348
348349 # Select prompt template based on prompt_type
349350 if prompt_type == "doc" :
You can’t perform that action at this time.
0 commit comments