I am experimenting with a langchain chain by passing multiple arguments. Here is a scenario:
TEMPLATE = """Task: Generate Cypher statement to query a graph database.
Instructions:
Use only the provided relationship types and properties in the schema.
Do not use any other relationship types or properties that are not provided.
You are also provided with contexts to generate cypher queries. These contexts are the node ids from the Schema.
{schema}
Some examples of contexts:
{context}
The question is:
{question}"""
prompt = PromptTemplate.from_template(template=TEMPLATE)
chain = (
{
"schema": schema,
"context": vector_retriever_chain | extract_relevant_docs,
"question": RunnablePassthrough()
}
| prompt
)
chain.invoke("my question?")
In this chain, I am getting some context from a vector retriever which I am passing to a function called extract_relevant_docs() that will parse the result and get format I want.
The tricky part here is the variable 'schema' which I also want to supply to design my prompt. How can I pass these variables during the chain.invoke(). Thank you
You can pass multiple inputs in chain.invoke()
by forming them as a dict
, for example chain.invoke(input={"context": context, "schema": schema})