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

建议增加上下文长度限制 #1069

Closed
AlanLee1996 opened this issue Mar 31, 2023 · 10 comments
Closed

建议增加上下文长度限制 #1069

AlanLee1996 opened this issue Mar 31, 2023 · 10 comments

Comments

@AlanLee1996
Copy link

现在上下文会一直增加,除非手动清空。建议增加参数设置对话轮数自动清理,或者在ui上增加按钮设置轮数。

@sampr373
Copy link

应该共用关闭上下文开关#378,修改一下样式
可以自己看看相关代码
相关issue #1007 #887(暂时解决方法) #987 #378
讨论了很久了,不需要重复吧
目前为了支持网页 accessToken似乎项目结构修改起来比较恶心,不知道是不是应该在大改结构弃用这一特征后进行。

@weifeng12x
Copy link
Contributor

其实最应该支持的应该是 API 模式,accessToken模式本来就是灰色地带,官方来次重拳出击就没了,但是api 模式基本长期可以运行的。

@techotaku39
Copy link

能否增加max tokens配置项呢,最近经常遇到回复到一半就不说话了,让它继续就说不记得了,一看日志的请求max tokens是1000

@sampr373
Copy link

能否增加max tokens配置项呢,最近经常遇到回复到一半就不说话了,让它继续就说不记得了,一看日志的请求max tokens是1000

max tokens不止这么多吧,你启用了最新的,在配置.env中打开长对话了吗

@techotaku39
Copy link

我用的是docker镜像,没看到文档说可以配置max tokens的环境变量,可以配置吗

@techotaku39
Copy link

是2.10.8的镜像

@techotaku39
Copy link

我把.env中打开长对话后重新打包运行,日志还是显示max tokens是1000,下面是完整日志

2023-04-01 02:16:25 Server is running on port 3002
2023-04-01 02:16:39 sendMessage (32 tokens) {
2023-04-01 02:16:39   max_tokens: 1000,
2023-04-01 02:16:39   model: 'gpt-3.5-turbo',
2023-04-01 02:16:39   temperature: 0.8,
2023-04-01 02:16:39   top_p: 1,
2023-04-01 02:16:39   presence_penalty: 1,
2023-04-01 02:16:39   messages: [
2023-04-01 02:16:39     {
2023-04-01 02:16:39       role: 'system',
2023-04-01 02:16:39       content: "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown."
2023-04-01 02:16:39     },
2023-04-01 02:16:39     { role: 'user', content: '你好', name: undefined }
2023-04-01 02:16:39   ],
2023-04-01 02:16:39   stream: true
2023-04-01 02:16:39 }

@sampr373
Copy link

sampr373 commented Apr 1, 2023

如果是3,提示的sendMessage (32 tokens)计数加上max_tokens(回答的长度,默认是1000)不能超过模型的上下文长度,2048个token。如果你经常需要>1000token的长回答,应该是使用4才有可能

4的话这个不是已经被merge了
#729

@techotaku39
Copy link

好,十分感谢解答。说起来我之前看到GPT3.5的总限制是4096是吗(也就是代码中的maxModelTokens),这里设置1000是为了保障上下文记忆是吗,看到GPT4的32K和8K模型也是maxResponseTokens设为maxModelTokens的1/4

@L1ttleBad
Copy link

L1ttleBad commented Apr 19, 2023

在文件
https://github.com/Chanzhaoyu/chatgpt-web/blob/main/src/views/chat/layout/sider/index.vue
58行前添加

const cur_index = chatStore.history.findIndex(item => item.uuid === chatStore.active)
if (cur_index !== -1) {
  if (chatStore.history[cur_index].title !== 'New Chat')
    handleAdd()
}

可以在每次打开网页时判断是否为New Chat,如果否则打开一个新的聊天,这是变相限制的方法

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

6 participants