diff --git a/langchain/llms/base.py b/langchain/llms/base.py index 9fbf983e..2e92c15d 100644 --- a/langchain/llms/base.py +++ b/langchain/llms/base.py @@ -287,6 +287,12 @@ class BaseLLM(BaseLanguageModel, ABC): self, prompt: str, stop: Optional[List[str]] = None, callbacks: Callbacks = None ) -> str: """Check Cache and run the LLM on the given prompt and input.""" + if not isinstance(prompt, str): + raise ValueError( + "Argument `prompt` is expected to be a string. Instead found " + f"{type(prompt)}. If you want to run the LLM on multiple prompts, use " + "`generate` instead." + ) return ( self.generate([prompt], stop=stop, callbacks=callbacks) .generations[0][0]