chatgpt icon indicating copy to clipboard operation
chatgpt copied to clipboard

最新代码,openai还是报json错误

Open JerryliDe opened this issue 3 years ago • 5 comments

大神,部署最新代码后,却报json body错误。我看json没问题啊 errmsg={ "error": { "message": "We could not parse the JSON body of your request. (HINT: This likely means you aren't using your HTTP library correctly. The OpenAI API expects a JSON payload, but what was sent was not valid JSON. If you have trouble figuring out how to fix this, please send an email to [email protected] and include any relevant code you'd like help with.)", "type": "invalid_request_error", "param": null, "code": null } }

JerryliDe avatar Mar 06 '23 07:03 JerryliDe

我找到问题了, 是php的session目录没有权限,俩php内自己重指定一个有权限的目录即可。

JerryliDe avatar Mar 06 '23 12:03 JerryliDe

@JerryliDe I occur the problem as same as you, such as: curl https://api.openai.com/v1/chat/completions
-H "Content-Type: application/json"
-H "Authorization: Bearer $OPENAI_API_KEY"
-d '{ "model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "Say this is a test!"}], "temperature": 0.7 }'

I use my_api_key instead of $OPENAI_API_KEY, what should I do, please give me some help, thank you very much

Huihh avatar Mar 21 '23 12:03 Huihh

@JerryliDe I occur the problem as same as you, such as: curl https://api.openai.com/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer $OPENAI_API_KEY" -d '{ "model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "Say this is a test!"}], "temperature": 0.7 }'

I use my_api_key instead of $OPENAI_API_KEY, what should I do, please give me some help, thank you very much

@Huihh Please check if your PHP session directory has read and write permissions. You can usually use the phpinfo function to view the current host environment information. Alternatively, you can define your own specified directory within the PHP program to store sessions. For specific code, you can ask chatgpt.

JerryliDe avatar Mar 21 '23 19:03 JerryliDe

Thanks, I have solved it

Huihh avatar Mar 22 '23 03:03 Huihh

2023-12-19 18:57:18.497 WARN 17452 --- [ient-dispatch-1] o.a.h.c.h.p.ResponseProcessCookies : ex-0000000001 Cookie rejected [__cf_bm="Gp75mDz7nrQ9AJnFEr7OHthm7bwkn2g00iKIENZz4ro-1702983438-1-AacZCob9ueFYe39B5PEwJC1z1nF3jtA2aXKsyCFYN5w...", domain:api.openai.com, path:/, expiry:2023-12-19T11:27:18Z] Illegal 'domain' attribute "api.openai.com". Domain of origin: "api.openai-proxy.com" 2023-12-19 18:57:18.499 WARN 17452 --- [ient-dispatch-1] o.a.h.c.h.p.ResponseProcessCookies : ex-0000000001 Cookie rejected [_cfuvid="nX9468YojNhDoB9FCgQBqrTNjKzW6FBm73La.0zbIeY-1702983438017-0-604800000", domain:api.openai.com, path:/, expiry:null] Illegal 'domain' attribute "api.openai.com". Domain of origin: "api.openai-proxy.com" 2023-12-19 18:57:19.853 WARN 17452 --- [ient-dispatch-1] o.a.h.c.h.p.ResponseProcessCookies : ex-0000000001 Cookie rejected [__cf_bm="KPWtptVmN2mVzTJOq7XvhG_JaqvTaktSU95wMgkbjnE-1702983439-1-AcySoM3eRpi8U4JXXodDoumrSHRPn9d7RH+Li8glJSJ...", domain:api.openai.com, path:/, expiry:2023-12-19T11:27:19Z] Illegal 'domain' attribute "api.openai.com". Domain of origin: "api.openai-proxy.com" 2023-12-19 18:57:19.854 WARN 17452 --- [ient-dispatch-1] o.a.h.c.h.p.ResponseProcessCookies : ex-0000000001 Cookie rejected [_cfuvid="rwrzxxF8VT_RQO2zLkiLZR0jnlXcqacTbQutZfF3Pk8-1702983439378-0-604800000", domain:api.openai.com, path:/, expiry:null] Illegal 'domain' attribute "api.openai.com". Domain of origin: "api.openai-proxy.com" 2023-12-19 18:57:19.884 WARN 17452 --- [ient-dispatch-1] com.BDJW.model.ChatModel : 转换异常,{ "error": { "message": "We could not parse the JSON body of your request. (HINT: This likely means you aren't using your HTTP library correctly. The OpenAI API expects a JSON payload, but what was sent was not valid JSON. If you have trouble figuring out how to fix this, please contact us through our help center at help.openai.com.)", "type": "invalid_request_error", "param": null, "code": null } } 不能被转换为json 我使用了这个代理地址访问原先还行现在就爆出了这个错误,请给我一些帮助,谢谢

Joyboyman avatar Dec 19 '23 11:12 Joyboyman