Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] 请求两次获取主题 #1668

Closed
gtoxlili opened this issue May 21, 2023 · 2 comments
Closed

[Bug] 请求两次获取主题 #1668

gtoxlili opened this issue May 21, 2023 · 2 comments

Comments

@gtoxlili
Copy link
Contributor

最新版在首次对话后会进行两次获取主题的请求,导致tokens浪费
image

@gtoxlili
Copy link
Contributor Author

看了下 是因为 app/client/platforms/openai.ts 中

 let finished = false;

const finish = () => {
          if (!finished) {
            console.log("[OpenAI] request finished");
            options.onFinish(responseText);
            finished = true;
          }
 };

这个 finish 在 onmessage 遇到 [DONE] 与通道被关闭时都会调用,但是两个时机很接近导致 第二次调用时,第一次的调用并没有执行到 finished = true的位置(猜测)导致了这一事件的发生,将 finished = true; 移到 options.onFinish(responseText);前面可以解决问题

@gtoxlili
Copy link
Contributor Author

@Yidadaa hi

jinker pushed a commit to jinker/ChatGPT-Next-Web that referenced this issue Jun 19, 2023
Jeremy-Hibiki pushed a commit to Jeremy-Hibiki/ChatGPT-Next-Web that referenced this issue Sep 5, 2023
Jeremy-Hibiki pushed a commit to Jeremy-Hibiki/ChatGPT-Next-Web that referenced this issue Sep 5, 2023
gaogao1030 pushed a commit to gaogao1030/ChatGPT-Next-Web that referenced this issue May 16, 2024
gaogao1030 pushed a commit to gaogao1030/ChatGPT-Next-Web that referenced this issue May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant