From 4b6fdd7bf0d0eb41d274929aae3ce89985c2c235 Mon Sep 17 00:00:00 2001 From: Shorthills AI <141953346+ShorthillsAI@users.noreply.github.com> Date: Thu, 19 Oct 2023 12:10:37 +0530 Subject: [PATCH] Update modal.py (#11588) feat: Raise KeyError when 'prompt' key is missing in JSON response This commit updates the error handling in the code to raise a KeyError when the 'prompt' key is not found in the JSON response. This change makes the code more explicit about the nature of the error, helping to improve clarity and debugging. @baskaryan, @eyurtsev. --- libs/langchain/langchain/llms/modal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/langchain/langchain/llms/modal.py b/libs/langchain/langchain/llms/modal.py index 9f1f42269d7..c18b1599375 100644 --- a/libs/langchain/langchain/llms/modal.py +++ b/libs/langchain/langchain/llms/modal.py @@ -91,7 +91,7 @@ class Modal(LLM): if prompt in response.json()["prompt"]: response_json = response.json() except KeyError: - raise ValueError("LangChain requires 'prompt' key in response.") + raise KeyError("LangChain requires 'prompt' key in response.") text = response_json["prompt"] if stop is not None: # I believe this is required since the stop tokens