mirror of
				https://github.com/infiniflow/ragflow.git
				synced 2025-11-04 03:39:41 +00:00 
			
		
		
		
	Fix: NameError: free variable 'langfuse_generation' referenced before assignment in enclosing scope (#6451)
### What problem does this PR solve? ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --------- Co-authored-by: lizheng@ssc-hn.com <lizheng@ssc-hn.com>
This commit is contained in:
		
							parent
							
								
									b77ce4e846
								
							
						
					
					
						commit
						200b6f55c6
					
				@ -260,7 +260,7 @@ def chat(dialog, messages, stream=True, **kwargs):
 | 
			
		||||
        gen_conf["max_tokens"] = min(gen_conf["max_tokens"], max_tokens - used_token_count)
 | 
			
		||||
 | 
			
		||||
    def decorate_answer(answer):
 | 
			
		||||
        nonlocal prompt_config, knowledges, kwargs, kbinfos, prompt, retrieval_ts, questions
 | 
			
		||||
        nonlocal prompt_config, knowledges, kwargs, kbinfos, prompt, retrieval_ts, questions, langfuse_tracer
 | 
			
		||||
 | 
			
		||||
        refs = []
 | 
			
		||||
        ans = answer.split("</think>")
 | 
			
		||||
@ -336,7 +336,10 @@ def chat(dialog, messages, stream=True, **kwargs):
 | 
			
		||||
 | 
			
		||||
        langfuse_output = "\n" + re.sub(r"^.*?(### Query:.*)", r"\1", prompt, flags=re.DOTALL)
 | 
			
		||||
        langfuse_output = {"time_elapsed:": re.sub(r"\n", "  \n", langfuse_output), "created_at": time.time()}
 | 
			
		||||
        langfuse_generation.end(output=langfuse_output)
 | 
			
		||||
 | 
			
		||||
        # Add a condition check to call the end method only if langfuse_tracer exists
 | 
			
		||||
        if langfuse_tracer and 'langfuse_generation' in locals():
 | 
			
		||||
            langfuse_generation.end(output=langfuse_output)
 | 
			
		||||
 | 
			
		||||
        return {"answer": think + answer, "reference": refs, "prompt": re.sub(r"\n", "  \n", prompt), "created_at": time.time()}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user