Skip to content

Commit

Permalink
updated search to use index parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesWesch committed Oct 31, 2023
1 parent 29e9343 commit ccef8c8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions src/intelligence_layer/connectors/document_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,16 @@ def list_documents(self, namespace: str, collection: str) -> Any:
response.raise_for_status()
return response.json()

def search(
def index_search(
self,
namespace: str,
collection: str,
index: str,
query: str,
max_results: int,
min_score: float,
) -> Any:
url = f"{self._base_document_index_url}/collections/{namespace}/{collection}/search"
url = f"{self._base_document_index_url}/collections/{namespace}/{collection}/indexes/{index}/search"
data = {
"query": [{"modality": "text", "text": query}],
"max_results": max_results,
Expand All @@ -111,3 +112,15 @@ def search(
response = requests.post(url, data=json.dumps(data), headers=self.headers)
response.raise_for_status()
return response.json()

def asymmetric_search(
self,
namespace: str,
collection: str,
query: str,
max_results: int,
min_score: float,
) -> Any:
return self.index_search(namespace, collection, "asymmetric", query, max_results, min_score)


Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(
self._threshold = threshold

def get_relevant_documents_with_scores(self, query: str) -> Sequence[SearchResult]:
response = self._document_index.search(
response = self._document_index.asymmetric_search(
self._namespace, self._collection, query, self._k, self._threshold
)
relevant_chunks = [
Expand Down

0 comments on commit ccef8c8

Please sign in to comment.