fix: escape double quotation marks in the vector DB search query (#6506)

This commit is contained in:
Sangmin Ahn 2024-07-23 16:02:25 +09:00 • committed by GitHub
commit 093b8ca475
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 4 deletions

View file

@ -40,7 +40,7 @@ class HitTestingService:
all_documents = RetrievalService.retrieve(retrival_method=retrieval_model['search_method'],
dataset_id=dataset.id,
query=query,
query=cls.escape_query_for_search(query),
top_k=retrieval_model['top_k'],
score_threshold=retrieval_model['score_threshold']
if retrieval_model['score_threshold_enabled'] else None,
@ -104,3 +104,7 @@ class HitTestingService:
if not query or len(query) > 250:
raise ValueError('Query is required and cannot exceed 250 characters')
@staticmethod
def escape_query_for_search(query: str) -> str:
return query.replace('"', '\\"')