minimaxir / simpleaichat

Python package for easily interfacing with chat apps, with robust features and minimal code complexity.
MIT License
3.43k stars 224 forks source link

Calls to ChatGPT may benefit from a timeout #88

Open hedleyroos opened 8 months ago

hedleyroos commented 8 months ago

Calls like https://github.com/minimaxir/simpleaichat/blob/main/simpleaichat/chatgpt.py#L311 may cause us to wait very long for a response. Things go wrong with networks and OpenAI, and the call will only be terminated when the TCP timeout limit is reached and the socket destroyed.

The code already retrieves the OpenAI API key from an env var, so perhaps the same approach can be used for timeouts?