Hi we are building an AI-powered coaching and upskilling product using OpenAI’s API GPT4, and our AI coach is not responding in some cases when a user types in something. Have you encountered that or do you how to fix this? Thanks!
Be tolerant of whatever the API (doesn’t) throw at you the first time. Example…
# Create a thread for the API call
api_thread = threading.Thread(target=classifier_api_call, args=(result, api_parameters))
api_thread.start()
api_thread.join(timeout=4) # Set the timeout for the API call
if api_thread.is_alive():
# If the API call is still running after the timeout, terminate it
log_print("API call timeout, retrying...")
api_thread.join(timeout=4) # Retry with another timeout
if api_thread.is_alive():
You can also be classy and watch the time between generator deltas when streaming to find a subscription failure.