-
Notifications
You must be signed in to change notification settings - Fork 437
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
聊天历史由 MongoDB 中获取 #113
聊天历史由 MongoDB 中获取 #113
Conversation
同时关掉 api 依赖库中的缓存
@@ -45,6 +46,8 @@ export async function initApi() { | |||
apiKey: config.apiKey, | |||
completionParams: { model }, | |||
debug: !config.apiDisableDebug, | |||
messageStore: undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
关闭默认的 LRU 缓存
@@ -45,6 +46,8 @@ export async function initApi() { | |||
apiKey: config.apiKey, | |||
completionParams: { model }, | |||
debug: !config.apiDisableDebug, | |||
messageStore: undefined, | |||
getMessageById, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
覆写获取信息方法
1 重复一次是因为一次是取completion,一次是取prompt,所以我说做一层小缓存是可以在取completion的时候缓存下,再往上取prompt的时候可以不走MongoDB,但要考虑自动失效什么的也挺烦先就没搞了 2 往上追溯多少这个是上游api决定的,这里控制,他往上追溯到上下文大于 model总token数 - 最大completion token数的时候就不加了,默认model 4000,最大completion 1000,所以下一条上下文加上时超过3000token的时候就不加了 |
重启服务后上下文在提问中得以保存
同时关掉 api 依赖库中的缓存以减少长时间使用后的内存占用
可能带来的问题是上下文条数很多时多次读取 MongoDB 数据库,会加大数据库压力和增大延迟,可以做的优化是做一层小缓存
只试过 API 走 GPT 3.5,accessToken 方式需要测试