Add error handling for errors in the JSON response from HuggingFaceInferenceAPIEmbeddings embed_documents call #29791
brian-ogrady
announced in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked
Feature request
When using a custom HuggingFace API Endpoint there can be an error in the JSON response. I propose added two checks when calling the
embed_documents
method of theHuggingFaceInferenceAPIEmbeddings
class:JSONDecodeError
Motivation
While working with the

HuggingFaceInferenceAPIEmbeddings
class, I sometimes receive a nebulous errorValueError: could not convert string to float: 'e'
This results because the
embed_documents
method, which is called during the execution of theadd_documents
method of a vector store, can return a JSON response like the following:{'error': 'Input validation error:
inputscannot be empty', 'error_type': 'Validation'}
Proposal (If applicable)
The initial
ValueError
raised fromadd_documents
is misleading because it makes the underlying error returned in the JSON response. I propose surfacing this error by adding a check duringembed_documents
to return the JSON error in a Pythonic manner.Beta Was this translation helpful? Give feedback.
All reactions