langchain-tutorials
langchain-tutorials copied to clipboard
ValidationError: 1 validation error for LLMChain
I have had this model working and it is great but now im getting different error messages.
ValidationError Traceback (most recent call last) Cell In[72], line 2 1 llm = OpenAI(temperature=0, openai_api_key=OPENAI_API_KEY) ----> 2 chain = load_qa_chain(llm, chain_type="stuff")
File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/langchain/chains/question_answering/init.py:218, in load_qa_chain(llm, chain_type, verbose, callback_manager, **kwargs) 213 if chain_type not in loader_mapping: 214 raise ValueError( 215 f"Got unsupported chain type: {chain_type}. " 216 f"Should be one of {loader_mapping.keys()}" 217 ) --> 218 return loader_mapping[chain_type]( 219 llm, verbose=verbose, callback_manager=callback_manager, **kwargs 220 )
File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/langchain/chains/question_answering/init.py:63, in _load_stuff_chain(llm, prompt, document_variable_name, verbose, callback_manager, **kwargs) 54 def _load_stuff_chain( 55 llm: BaseLanguageModel, 56 prompt: Optional[BasePromptTemplate] = None, (...) 60 **kwargs: Any, 61 ) -> StuffDocumentsChain: 62 _prompt = prompt or stuff_prompt.PROMPT_SELECTOR.get_prompt(llm) ---> 63 llm_chain = LLMChain( 64 llm=llm, prompt=prompt, verbose=verbose, callback_manager=callback_manager 65 ) 66 # TODO: document prompt 67 return StuffDocumentsChain( 68 llm_chain=llm_chain, 69 document_variable_name=document_variable_name, (...) 72 **kwargs, 73 )
File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pydantic/main.py:342, in pydantic.main.BaseModel.init()
ValidationError: 1 validation error for LLMChain prompt none is not an allowed value (type=type_error.none.not_allowed)
ChatGPT4 response:
The error message indicates a ValidationError due to an invalid value for the prompt argument in the LLMChain constructor. Specifically, the error message states that None is not an allowed value for prompt. This error can occur if the prompt argument is not properly specified when creating an instance of the LLMChain class.
To fix this error, the prompt argument should be properly specified when creating an instance of the LLMChain class. This can be done by providing a valid value for the prompt argument that is not None. Additionally, the error message suggests that the value None is not an allowed value for the prompt argument, so it is important to consult the documentation or source code of the LLMChain class to determine what values are valid for the prompt argument.
hello bbuxton0823 how did u solve above
This solved a somewhat related problem for me:
!pip install pydantic==1.9.0