mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-07-04 16:15:09 +08: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)
|
gen_conf["max_tokens"] = min(gen_conf["max_tokens"], max_tokens - used_token_count)
|
||||||
|
|
||||||
def decorate_answer(answer):
|
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 = []
|
refs = []
|
||||||
ans = answer.split("</think>")
|
ans = answer.split("</think>")
|
||||||
@ -336,6 +336,9 @@ def chat(dialog, messages, stream=True, **kwargs):
|
|||||||
|
|
||||||
langfuse_output = "\n" + re.sub(r"^.*?(### Query:.*)", r"\1", prompt, flags=re.DOTALL)
|
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_output = {"time_elapsed:": re.sub(r"\n", " \n", langfuse_output), "created_at": time.time()}
|
||||||
|
|
||||||
|
# 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)
|
langfuse_generation.end(output=langfuse_output)
|
||||||
|
|
||||||
return {"answer": think + answer, "reference": refs, "prompt": re.sub(r"\n", " \n", prompt), "created_at": time.time()}
|
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