mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
community: Give more context on DeepInfra 500 errors (#25671)
Description: DeepInfra 500 errors have useful information in the text field that isn't being exposed to the user. I updated the error message to fix this. As an example, this code ``` from langchain_community.chat_models import ChatDeepInfra from langchain_core.messages import HumanMessage model = "meta-llama/Meta-Llama-3-70B-Instruct" deepinfra_api_token = "..." model = ChatDeepInfra(model=model, deepinfra_api_token=deepinfra_api_token) messages = [HumanMessage("All work and no play makes Jack a dull boy\n" * 9000)] response = model.invoke(messages) ``` Currently gives this error: ``` langchain_community.chat_models.deepinfra.ChatDeepInfraException: DeepInfra Server: Error 500 ``` This change would give the following error: ``` langchain_community.chat_models.deepinfra.ChatDeepInfraException: DeepInfra Server error status 500: {"error":{"message":"Requested input length 99009 exceeds maximum input length 8192"}} ```
This commit is contained in:
parent
29c873dd69
commit
e499caa9cd
@ -449,7 +449,9 @@ class ChatDeepInfra(BaseChatModel):
|
||||
|
||||
def _handle_status(self, code: int, text: Any) -> None:
|
||||
if code >= 500:
|
||||
raise ChatDeepInfraException(f"DeepInfra Server: Error {code}")
|
||||
raise ChatDeepInfraException(
|
||||
f"DeepInfra Server error status {code}: {text}"
|
||||
)
|
||||
elif code >= 400:
|
||||
raise ValueError(f"DeepInfra received an invalid payload: {text}")
|
||||
elif code != 200:
|
||||
|
Loading…
Reference in New Issue
Block a user