thanhsonng / chatgpt-voice

Have a conversation with ChatGPT. Casually 🔈 🤖 ⚡️
https://chatgpt.sonng.dev
164 stars 38 forks source link

Python backend support #12

Closed rzc331 closed 1 year ago

rzc331 commented 1 year ago

Hi,

The front-end you designed looks awesome!

We have built a backend with python Flask, which includes some customized function calling codes with OpenAI API, all in python. However, it doesn't seem to work with the frontend.

We've succeeded in locally running your typescript backend, but once switched to flask backend, even with same port, it always shows Failed to get the response, please try again.

Would you mind briefly guide us how to hook this front-end to Flask? Even a way to traceback error would be much appreciated (right now we have no way to locate the bug)!

thanhsonng commented 1 year ago

Hi,

There are two possibilities in your case. It is either:

I suggest you debug the backend first, try logging your request to OpenAI and the response to see if you have successfully connected to OpenAI using your API credentials.

If that works, then the problem lies in the frontend-backend communication. Open the browser dev tool, see the Network tab to see what data the backend is returning, and continue logging in the backend to see why it is returning that data.

rzc331 commented 1 year ago

Thanks for the prompt response!

Issue identified, it's related to CORS of flask. After using flask_cors the issue was resolved.

Many thanks!