self.vector_storage_context = StorageContext.from_defaults(vector_store=SimpleVectorStore(), persist_dir="storage/vector")
<skip>
def _create_query_engine(self, product: str) -> RetrieverQueryEngine:
try:
vector_index = load_index_from_storage(storage_context=self.vector_storage_context, embed_model=Settings.embed_model)
print(vector_index.docstore.get_all_document_hashes())
vector_retriever = VectorIndexRetriever(
index=vector_index,
similarity_top_k=10,
)
vector_query_engine = RetrieverQueryEngine(
retriever=vector_retriever,
response_synthesizer=self.response_synthesizer,
node_postprocessors=[
SimilarityPostprocessor(similarity_cutoff=0.50),
self.cohere_rerank
],
)
vector_query_engine.update_prompts({"response_synthesizer:text_qa_template": self.qa_prompt_tmpl})
embedded_query = Settings.embed_model.get_text_embedding("Why is the sky blue?")
print(embedded_query[:5])
response = vector_query_engine.query(QueryBundle(query_str="Why is the sky blue?", embedding=embedded_query))
print(response)