fix: escape double quotation marks in the vector DB search query (#6506)
This commit is contained in:
@@ -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('"', '\\"')
|
||||
|
Reference in New Issue
Block a user