Во входных данных ChatPromptTemplate отсутствуют переменные {'input', 'agent_scratchpad'}. Ожидается: ['agent_scratchpadPython

Программы на Python
Anonymous
Во входных данных ChatPromptTemplate отсутствуют переменные {'input', 'agent_scratchpad'}. Ожидается: ['agent_scratchpad

Сообщение Anonymous »

Этот код выдает странную ошибку:

Код: Выделить всё

from langchain_core.output_parsers import StrOutputParser
from langchain_core.runnables import RunnableLambda, RunnablePassthrough

def create_weaviate_new_RAG(client, embeddings, llm, class_name_rich, class_properties_rich, class_text_key):

vector_store = Weaviate(client=client,
index_name=class_name_rich,
text_key=class_text_key,
embedding=embeddings,
attributes=class_properties_rich,
#by_text=False,
)

retriever=vector_store.as_retriever(
search_type= "mmr",
search_kwargs={
"k": 4,
"fetch_k": 20,
}
)

prompt = ChatPromptTemplate.from_messages(
[
("system", "You are a helpful assistant who retrieves information from documents"),
("user", "{input}"),
MessagesPlaceholder(variable_name="agent_scratchpad"),
]
)

rag_pipe = (
{"context": retriever, "question": RunnablePassthrough()}
| prompt
| llm
| StrOutputParser()
)

return rag_pipe

rag_pipe = create_weaviate_new_RAG(client, embeddings, llm_chat, class_name, ["chunk_id", "doc_name", "doc_path"], "chunk_text")
text = "what is ai policy?"
rag_pipe.invoke(text)
Выдает следующую ошибку:

Код: Выделить всё

"Input to ChatPromptTemplate is missing variables {'input', 'agent_scratchpad'}.
Expected: ['agent_scratchpad', 'input']
Received: ['context', 'question']"
Я использую openai==1.7.0 и langchain==0.1.0
Это начало появляться только после добавления нового тряпичного кода из langchain.
Как устранить эту ошибку?

Подробнее здесь: https://stackoverflow.com/questions/778 ... scratchpad

Вернуться в «Python»