|
|
|
@@ -1,3 +1,4 @@ |
|
|
|
import json |
|
|
|
import threading |
|
|
|
from typing import Optional |
|
|
|
|
|
|
|
@@ -171,7 +172,7 @@ class RetrievalService: |
|
|
|
vector = Vector(dataset=dataset) |
|
|
|
|
|
|
|
documents = vector.search_by_vector( |
|
|
|
cls.escape_query_for_search(query), |
|
|
|
query, |
|
|
|
search_type="similarity_score_threshold", |
|
|
|
top_k=top_k, |
|
|
|
score_threshold=score_threshold, |
|
|
|
@@ -250,7 +251,7 @@ class RetrievalService: |
|
|
|
|
|
|
|
@staticmethod |
|
|
|
def escape_query_for_search(query: str) -> str: |
|
|
|
return query.replace('"', '\\"') |
|
|
|
return json.dumps(query).strip('"') |
|
|
|
|
|
|
|
@staticmethod |
|
|
|
def format_retrieval_documents(documents: list[Document]) -> list[RetrievalSegments]: |