Open
Description
Description
When CohereAPIError happens, error is not propagated to Jupyter AI, langchain is stuck in the loop
Reproduce
- Choose Cohere model, use bad API key
- Attempt to send a chat message
- Note that there is no response from Jupyternaut, note terminal error messages and server getting stuck in a loop
Current conversation:
Human: test
AI:
Retrying langchain.llms.cohere.completion_with_retry.<locals>._completion_with_retry in 4.0 seconds as it raised CohereAPIError: invalid api token.
Retrying langchain.llms.cohere.completion_with_retry.<locals>._completion_with_retry in 4.0 seconds as it raised CohereAPIError: invalid api token.
Retrying langchain.llms.cohere.completion_with_retry.<locals>._completion_with_retry in 4.0 seconds as it raised CohereAPIError: invalid api token.
Expected behavior
Usual behavior: error is propagated to Jupyter AI, caught by ChatHandler, Jupyternaut sends error stack trace to user.
Tried implementing a workaround without success:
- handling exception via
try-except cohere.CohereAPIError
block toCohereProvider._acall()
- handling exception via
try-except cohere.CohereAPIError
inBaseProvider._generate_in_executor()
andBaseProvider._call_in_executor()