Skip to content

Commit

Permalink
Correct f-string quote issue impacting older python versions
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMcH committed Jan 22, 2025
1 parent e2db28a commit 490afb0
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -635,15 +635,18 @@ def _construct_query(
raise ValueError(
"search text cannot be None for FULL_TEXT_RANK queries."
)
terms = [f"'{term.replace("'", "\\'")}'" for term in search_text.split()]

search_text = search_text.replace("'", "\\'")
terms = [f"'{term}'" for term in search_text.split()]
query += f""" ORDER BY RANK FullTextScore(c.{self._text_key},
[{", ".join(terms)}])"""
elif query_type == CosmosDBQueryType.VECTOR:
query += " ORDER BY VectorDistance(c[@embeddingKey], @embeddings)"
elif query_type == CosmosDBQueryType.HYBRID:
if search_text is None:
raise ValueError("search text cannot be None for HYBRID queries.")
terms = [f"'{term.replace("'", "\\'")}'" for term in search_text.split()]
search_text = search_text.replace("'", "\\'")
terms = [f"'{term}'" for term in search_text.split()]
query += f""" ORDER BY RANK RRF(FullTextScore(c.{self._text_key},
[{", ".join(terms)}]),
VectorDistance(c.{self._embedding_key}, {embeddings}))"""
Expand Down

0 comments on commit 490afb0

Please sign in to comment.