Skip to content

Commit

Permalink
fix: black linter issues!
Browse files Browse the repository at this point in the history
  • Loading branch information
amindadgar committed Dec 17, 2024
1 parent 97c36c0 commit ff7bc97
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bot/retrievers/custom_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _build_node_list_from_query_result(
score: float | None = None
if query_result.similarities is not None:
score = query_result.similarities[ind]

if score is not None and score >= RETRIEVER_THRESHOLD:
# This is the part we updated
node_new = Node.from_dict(node.to_dict())
Expand Down
2 changes: 1 addition & 1 deletion utils/globals.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# the theshold to skip nodes of being included in an answer
RETRIEVER_THRESHOLD = .4
RETRIEVER_THRESHOLD = 0.4
12 changes: 9 additions & 3 deletions utils/query_engine/dual_qdrant_retrieval_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ def _process_basic_query(self, query_str: str) -> Response:

def _process_summary_query(self, query_str: str) -> Response:
summary_nodes = self.summary_retriever.retrieve(query_str)
summary_nodes_filtered = [node for node in summary_nodes if node.score >= RETRIEVER_THRESHOLD]
summary_nodes_filtered = [
node for node in summary_nodes if node.score >= RETRIEVER_THRESHOLD
]
utils = QdrantEngineUtils(
metadata_date_key=self.metadata_date_key,
metadata_date_format=self.metadata_date_format,
Expand All @@ -211,9 +213,13 @@ def _process_summary_query(self, query_str: str) -> Response:
)
raw_nodes = retriever.retrieve(query_str)

raw_nodes_filtered = [node for node in raw_nodes if node.score >= RETRIEVER_THRESHOLD]
raw_nodes_filtered = [
node for node in raw_nodes if node.score >= RETRIEVER_THRESHOLD
]

context_str = utils.combine_nodes_for_prompt(summary_nodes_filtered, raw_nodes_filtered)
context_str = utils.combine_nodes_for_prompt(
summary_nodes_filtered, raw_nodes_filtered
)
prompt = self.qa_prompt.format(context_str=context_str, query_str=query_str)
response = self.llm.complete(prompt)

Expand Down
8 changes: 6 additions & 2 deletions utils/query_engine/level_based_platform_query_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ def custom_query(self, query_str: str):
similar_nodes = retriever.query_db(
query=query_str, filters=self._filters, date_interval=self._d
)
similar_nodes_filtered = [node for node in similar_nodes if node.score >= RETRIEVER_THRESHOLD]
similar_nodes_filtered = [
node for node in similar_nodes if node.score >= RETRIEVER_THRESHOLD
]

context_str = self._prepare_context_str(similar_nodes_filtered, summary_nodes=None)
context_str = self._prepare_context_str(
similar_nodes_filtered, summary_nodes=None
)
fmt_qa_prompt = qa_prompt.format(context_str=context_str, query_str=query_str)
response = self.llm.complete(fmt_qa_prompt)
logging.debug(f"fmt_qa_prompt:\n{fmt_qa_prompt}")
Expand Down

0 comments on commit ff7bc97

Please sign in to comment.