使用自定义agent问答,有时模型会给出重复的两次回答,请问是什么原因,如何解决这个问题? #3679
Replies: 1 comment
-
Hey there, @Liwan-Chen! Fancy seeing you back here. Hope you're doing well! 🚀 The issue you're experiencing with your custom question-answering agent providing the same response twice to a single input could be related to the handling of the To resolve this issue, you could consider the following adjustments:
Here's a revised snippet of the async def on_llm_new_token(self, token: str, **kwargs: Any) -> None:
special_tokens = ["Action", "<|observation|>"]
token_processed = False
for stoken in special_tokens:
if stoken in token:
before_action = token.split(stoken)[0]
self.cur_tool.update(
status=Status.running,
llm_token=before_action + "\n",
)
self.queue.put_nowait(dumps(self.cur_tool))
self.out = False
token_processed = True
break
if not token_processed and self.out:
self.cur_tool.update(
status=Status.running,
llm_token=token,
)
self.queue.put_nowait(dumps(self.cur_tool))
elif not token_processed:
# Reset self.out to True here if necessary, depending on your application's logic
pass This adjustment ensures that You can find more details about the Sources
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
All reactions