Replies: 1 comment 1 reply
-
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I want to create a system which can query two seperate indexes seperately and include their output in a contextualised query. The plan is that a question would be provided. The first index would get the relevant user docs nodes. Then the second index would be used to get context nodes. Then the query would be formatted as in text_qa_template_str to be finally sent to the LLM for a response.
text_qa_template_str = (
"<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\n"
"User documentation information is"
" below.\n---------------------\n{user_docs_str}\n---------------------\n"
"Context information is"
" below.\n---------------------\n{context_str}\n---------------------\n"
" You are an AI model specialized in providing advice on railway operational technology (OT) cybersecurity.\n"
" Your responses must be based solely on the context information provided to you.\n"
" If the information given is insufficient for you to provide a useful answer, explicitly state that you do not know the answer given the provided context.\n"
" Your goal is to offer precise, relevant, and actionable advice or insights.\n"
" Answer the question clearly and avoid sentences explaining that you have used the provided context'\n"
" <|eot_id|><|start_header_id|>user<|end_header_id|>\n\n"
" {query_str}\n"
"<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"
)
This is my existing code which is partially implemented I don't fully understand how the links would work or if my modules are wrong, please can someone help out to get this working.
docs_path = "../docs2"
domain_documents = SimpleDirectoryReader(docs_path).load_data()
domain_index = VectorStoreIndex.from_documents(domain_documents)#, service_context=svc)
domain_index.storage_context.persist()
domain_engine = domain_index.as_query_engine(llm=llm, text_qa_template=text_qa_template)
domain_retriever = domain_index.as_retriever(llm=llm)
docs_path = "../pdfs"
user_documents = SimpleDirectoryReader(docs_path).load_data()
user_index = VectorStoreIndex.from_documents(user_documents)#, service_context=svc)
user_index.storage_context.persist()
user_engine = user_index.as_query_engine(llm=llm, text_qa_template=text_qa_template)
user_docs_retriever = user_index.as_retriever(llm=llm)
prompt_template = PromptTemplate(text_qa_template_str)
input_component = PromptTemplate("Does the SUC description include a high-level description and depiction of the SUC?")
p = QueryPipeline(verbose=True)
p.add_modules(
{
"input":input_component,
"user_docs_retriever": user_docs_retriever,
"domain_retriever": domain_retriever,
"prompt_template": prompt_template,
"llm":llm,
}
)
p.add_link(...
Beta Was this translation helpful? Give feedback.
All reactions