前后端都有openAI的配置,但都没有生效
qyazhou opened this issue · 13 comments
只需要后端配置就可以了,启动命令要添加参数 --conf config.yaml
,指定配置文件路径,不然的话只会使用默认配置,不会读取配置文件
后端已经配置好了,但是调用OPENAI的接口还是有问题,请问图上那个错误的原因是什么呢?图上的config.yaml里面的配置地方对了吗?
服务端启动的命令发出来看看,一定要添加 --conf
参数
服务端启动命令:go run main.go --conf config.yaml
那可能的原因就是 API Key 有问题了,再检查下 key 吧
另外,客户端代码中 constant.dart 中 setting 开头的那几个常量一定不要修改啊,这个问题跟他们没关系
把 organization 配置去掉试试
跟这个没关系,Flutter 在新版的 Chrome 中 SSE 的支持有点问题,可能给这个有关系,再试试改服务端配置文件的 enable-websocket: true
在数据库表 quota 中,手动为当前登录的用户分配一定数量的智慧果就可以了。
下面是 涉及的表
- users:用户表
- quota:用户智慧果额度表,quota 为用为用户分配的总智慧果数量,rest 为剩余数量,period_end_at 为有效期截止时间
加上了配额,现在还是获取不到chatgpt的回答,token没有问题,在其他代码里面是可以访问的。目前报的错误是:
服务端log信息如下:
on=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MjU4ODg2NTUsImlhdCI6MTcxMDMzNjU5NSwiaWQiOjF9.sXcAnn0g4ggG4VtNsVH541mKigvBPSEGsyCn9oljDAk&client-version=1.0.13&platform-version=unknown&platform=unknown&language=zh","code":0,"ip":"","lang":"zh","elapse":619,"ver":"1.0.13","plat":"unknown"},"message":"request","datetime":"2024-03-13T22:31:04+09:00"}
{"module":"main","level_name":"DEBUG","level":8,"context":{"method":"GET","url":"/v1/users/stat/free-chat-counts/v2%40model%7Copenai%3Agpt-3.5-turbo","plat-ver":"unknown","code":200,"elapse":1,"ip":"","lang":"zh","ver":"1.0.13","plat":"unknown"},"message":"request","datetime":"2024-03-13T22:31:04+09:00"}
{"module":"main","level_name":"DEBUG","level":8,"context":{"ver":"1.0.13","plat":"unknown","plat-ver":"unknown","url":"/v1/rooms/1","ip":"","lang":"zh","method":"GET","code":200,"elapse":0},"message":"request","datetime":"2024-03-13T22:31:19+09:00"}
{"module":"main","level_name":"DEBUG","level":8,"context":{"method":"GET","url":"/v1/rooms/1","elapse":0,"ip":"","lang":"zh","plat-ver":"unknown","code":200,"ver":"1.0.13","plat":"unknown"},"message":"request","datetime":"2024-03-13T22:31:19+09:00"}
{"module":"main","level_name":"DEBUG","level":8,"context":{"ip":"","lang":"zh","elapse":2,"url":"/v1/examples/openai%3Agpt-3.5-turbo","code":200,"ver":"1.0.13","plat":"unknown","plat-ver":"unknown","method":"GET"},"message":"request","datetime":"2024-03-13T22:31:19+09:00"}
{"module":"main","level_name":"ERROR","level":4,"context":{"#line":463,"#package":"aiplatform-backend/server/controllers","#file":"D:/code/AI/aiPlatForm-Backend/server/controllers/openai.go","user_id":1,"retry_times":0},"message":"聊天请求失败,模型 gpt-3.5-turbo: error, status code: 401, message: Incorrect API key provided: authToken. You can find your API key at https://platform.openai.com/account/api-keys.","datetime":"2024-03-13T22:31:20+09:00"}
{"module":"main","level_name":"INFO","level":7,"context":{"user_id":1,"client":{"version":"1.0.13","platform":"unknown","platform_version":"unknown","language":"zh","ip":""},"room_id":1,"elapse":0.232866},"message":"接收到聊天请求,模型 gpt-3.5-turbo, 上下文消息数量 1, 输入 token 数 量 19,总计 token 数量 0","datetime":"2024-03-13T22:31:20+09:00"}
{"module":"main","level_name":"DEBUG","level":8,"context":{"method":"GET","code":0,"elapse":419,"ver":"1.0.13","plat":"unknown","plat-ver":"unknown","url":"/v1/chat/completions?ws=true&authorization=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MjU4ODg2NTUsImlhdCI6MTcxMDMzNjU5NSwiaWQiOjF9.sXcAnn0g4ggG4VtNsVH541mKigvBPSEGsyCn9oljDAk&client-version=1.0.13&platform-version=unknown&platform=unknown&language=zh","ip":"","lang":"zh"},"message":"request","datetime":"2024-03-13T22:31:20+09:00"}
{"module":"main","level_name":"DEBUG","level":8,"context":{"code":200,"elapse":0,"ip":"","lang":"zh","ver":"1.0.13","plat":"unknown","plat-ver":"unknown","method":"GET","url":"/v1/users/stat/free-chat-counts/v2%40model%7Copenai%3Agpt-3.5-turbo"},"message":"request","datetime":"2024-03-13T22:31:20+09:00"}
大神,试了N遍了,后端还是报这个错误,能帮忙看看吗?
{"module":"main","level_name":"DEBUG","level":8,"context":{"elapse":0,"ip":"","lang":"zh","ver":"1.0.13","plat":"unknown","method":"GET","url":"/v1/users/stat/free-chat-counts/gpt-3.5-turbo","code":200,"plat-ver":"unknown"},"message":"request","datetime":"2024-03-15T00:31:13+09:00"}
{"module":"main","level_name":"DEBUG","level":8,"context":{"code":200,"ip":"","ver":"1.0.13","plat-ver":"unknown","method":"GET","url":"/v1/rooms/1","elapse":0,"lang":"zh","plat":"unknown"},"message":"request","datetime":"2024-03-15T00:31:49+09:00"}
{"module":"main","level_name":"DEBUG","level":8,"context":{"ip":"","plat-ver":"unknown","method":"GET","elapse":0,"lang":"zh","ver":"1.0.13","plat":"unknown","url":"/v1/rooms/1","code":200},"message":"request","datetime":"2024-03-15T00:31:49+09:00"}
{"module":"main","level_name":"DEBUG","level":8,"context":{"method":"GET","elapse":3,"lang":"zh","plat":"unknown","plat-ver":"unknown","url":"/v1/examples/openai%3Agpt-3.5-turbo","code":200,"ip":"","ver":"1.0.13"},"message":"request","datetime":"2024-03-15T00:31:50+09:00"}
{"module":"main","level_name":"ERROR","level":4,"context":{"user_id":2,"retry_times":0,"#file":"D:/code/AI/hiAI-Backend/aidea-server/server/controllers/openai.go","#line":461,"#package":"github.com/mylxsw/aidea-server/server/controllers"},"message":"聊天请求失败,模型 gpt-3.5-turbo: error, status code: 401, message: Incorrect API key provided: authToken. You can find your API key at https://platform.openai.com/account/api-keys.","datetime":"2024-03-15T00:31:50+09:00"}
{"module":"main","level_name":"INFO","level":7,"context":{"user_id":2,"client":{"version":"1.0.13","platform":"unknown","platform_version":"unknown","language":"zh","ip":""},"room_id":1,"elapse":0.28922},"message":"接收到聊天请求,模型 gpt-3.5-turbo, 上下文消息数量 1, 输入 token 数量 24,总计 token 数量 0","datetime":"2024-03-15T00:31:50+09:00"}
{"module":"main","level_name":"DEBUG","level":8,"context":{"elapse":489,"ip":"","plat":"unknown","plat-ver":"unknown","method":"GET","code":0,"ver":"1.0.13","url":"/v1/chat/completions?ws=true&authorization=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MjU5ODE1OTEsImlhdCI6MTcxMDQyOTUzMSwiaWQiOjJ9.esXH9CjC9cJ-0Cg09WoTh37flclsKL--MnKVJlhU4rQ&client-version=1.0.13&platform-version=unknown&platform=unknown&language=zh","lang":"zh"},"message":"request","datetime":"2024-03-15T00:31:50+09:00"}
{"module":"main","level_name":"DEBUG","level":8,"context":{"url":"/v1/users/stat/free-chat-counts/v2%40model%7Copenai%3Agpt-3.5-turbo","code":200,"ip":"","lang":"zh","ver":"1.0.13","plat-ver":"unknown","method":"GET","elapse":1,"plat":"unknown"},"message":"request","datetime":"2024-03-15T00:31:50+09:00"}