Skip to content

Commit

Permalink
feat: use retriever instead of query engine in data source tool
Browse files Browse the repository at this point in the history
  • Loading branch information
okradze committed Oct 31, 2023
1 parent 408702a commit 0d85256
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions apps/server/datasources/file/file_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,19 @@ def query(self, query_str):
llm=llm, chunk_size=self.chunk_size
)

query_engine = self.index.as_query_engine(
response_mode=self.response_mode,
service_context=service_context,
similarity_top_k=self.similarity_top_k
if self.index_type == IndexType.VECTOR_STORE.value
else None,
verbose=True,
retriever = self.index.as_retriever(
service_context=service_context, verbose=True
)

result = query_engine.query(query_str)
return result.response
# query_engine = self.index.as_query_engine(
# response_mode=self.response_mode,
# service_context=service_context,
# similarity_top_k=self.similarity_top_k
# if self.index_type == IndexType.VECTOR_STORE.value
# else None,
# verbose=True,
# )

nodes = retriever.retrieve(query_str)
content = "\n".join([node.text for node in nodes])
return content

0 comments on commit 0d85256

Please sign in to comment.