ValidationError:StuffDocumentsChain __root__

问题描述 投票:0回答:0

我收到此错误

ValidationError: 1 validation error for StuffDocumentsChain __root__ document_variable_name context was not found in llm_chain input_variables: ['chat_history', 'user_query', 'relevant_context'] (type=value_error)
在使用
load_qa_chain
时,我搜索了此错误,但没有找到与此相关的任何内容。谁能告诉我这里缺少什么。

代码:

template = """You are a chatbot having a conversation with a human.

Given the following extracted parts of a long document and a question, create a final answer.

{relevant_context}

{chat_history}
Human: {user_query}
Chatbot:"""

prompt = PromptTemplate(
input_variables=["chat_history", "user_query", "relevant_context"],
template=template
)

memory = ConversationBufferMemory(memory_key="chat_history", input_key="user_query")

llm = OpenAI()
llm_chain = LLMChain(
    llm=llm,
    prompt=prompt,
    memory=memory,
)

chain = load_qa_chain(
    llm, chain_type="stuff", memory=memory, prompt=prompt
)
machine-learning prompt openai-api langchain
© www.soinside.com 2019 - 2024. All rights reserved.