The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
Harrison/hf inf error (#1543)
Harrison Chase9405af6919a2
diff --git a/langchain/llms/huggingface_endpoint.py b/langchain/llms/huggingface_endpoint.pyindex 1e776f7efe..027ff91760 100644--- a/langchain/llms/huggingface_endpoint.py+++ b/langchain/llms/huggingface_endpoint.py@@ -121,12 +121,15 @@ class HuggingFaceEndpoint(LLM, BaseModel):)except requests.exceptions.RequestException as e: # This is the correct syntaxraise 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(