langchain
8a7c95e5 - Retryable exception for empty OpenAI embedding. (#7070)

Commit
2 years ago
Retryable exception for empty OpenAI embedding. (#7070) Description: The OpenAI "embeddings" API intermittently falls into a failure state where an embedding is returned as [ Nan ], rather than the expected 1536 floats. This patch checks for that state (specifically, for an embedding of length 1) and if it occurs, throws an ApiError, which will cause the chunk to be retried. Issue: I have been unable to find an official langchain issue for this problem, but it is discussed (by another user) at https://stackoverflow.com/questions/76469415/getting-embeddings-of-length-1-from-langchain-openaiembeddings Maintainer: @dev2049 Testing: Since this is an intermittent OpenAI issue, I have not provided a unit or integration test. The provided code has, though, been run successfully over several million tokens. --------- Co-authored-by: William Webber <william@williamwebber.com> Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
Parents
Loading