mirror of
https://github.com/hwchase17/langchain
synced 2024-11-08 07:10:35 +00:00
Harrison/hf inf error (#1543)
Co-authored-by: Konstantin Hebenstreit <57603012+KonstantinHebenstreit@users.noreply.github.com>
This commit is contained in:
parent
357d808484
commit
9405af6919
@ -121,12 +121,15 @@ class HuggingFaceEndpoint(LLM, BaseModel):
|
||||
)
|
||||
except requests.exceptions.RequestException as e: # This is the correct syntax
|
||||
raise ValueError(f"Error raised by inference endpoint: {e}")
|
||||
generated_text = response.json()
|
||||
if "error" in generated_text:
|
||||
raise ValueError(
|
||||
f"Error raised by inference API: {generated_text['error']}"
|
||||
)
|
||||
if self.task == "text-generation":
|
||||
# Text generation return includes the starter text.
|
||||
generated_text = response.json()
|
||||
text = generated_text[0]["generated_text"][len(prompt) :]
|
||||
elif self.task == "text2text-generation":
|
||||
generated_text = response.json()
|
||||
text = generated_text[0]["generated_text"]
|
||||
else:
|
||||
raise ValueError(
|
||||
|
Loading…
Reference in New Issue
Block a user