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.
The nodes from the graph are listed below:
{nodes}
Relationships:
{schema}
Some examples of contexts:
{context}
The question is:
{question}"""
prompt = PromptTemplate.from_template(template=TEMPLATE)
chain = (
{"nodes": nodes,
"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 are the ‘nodes’ and ‘schema’ which I also want to supply to design my prompt. The ‘nodes’ and ‘schema’ here are some variables I want to extract and feed into the prompt. How can I pass these variables during the chain.invoke().
Thank you