Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Anush008 <[email protected]>
  • Loading branch information
Anush008 committed Dec 24, 2024
1 parent dea6412 commit 75f0edb
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions ragna/source_storages/_qdrant.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import os
import uuid
from collections import defaultdict
from typing import TYPE_CHECKING, Any, Optional, cast
Expand Down Expand Up @@ -43,7 +44,14 @@ def __init__(self) -> None:

from qdrant_client import QdrantClient

self._client = QdrantClient(path=ragna.local_root() / "qdrant")
url = os.getenv("QDRANT_URL")
api_key = os.getenv("QDRANT_API_KEY")
path = path = ragna.local_root() / "qdrant"

# Cannot pass both url and path
self._client = (
QdrantClient(url=url, api_key=api_key) if url else QdrantClient(path=path)
)

def list_corpuses(self) -> list[str]:
return [c.name for c in self._client.get_collections().collections]
Expand Down Expand Up @@ -216,7 +224,11 @@ def retrieve(

query_vector = self._embedding_function([prompt])[0]

search_filter = self._translate_metadata_filter(metadata_filter)
search_filter = (
self._translate_metadata_filter(metadata_filter)
if metadata_filter
else None
)
if isinstance(search_filter, models.FieldCondition):
search_filter = models.Filter(must=[search_filter])

Expand Down

0 comments on commit 75f0edb

Please sign in to comment.