Skip to content

Commit 949b51c

Browse files
committed
oh mypy
1 parent 4a1ce18 commit 949b51c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/raggy/vectorstores/chroma.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
)
1919

2020
from raggy.documents import Document as RaggyDocument
21+
from raggy.documents import DocumentMetadata
2122
from raggy.settings import settings
2223
from raggy.utilities.asyncutils import run_sync_in_worker_thread
2324
from raggy.utilities.embeddings import create_openai_embeddings
@@ -90,7 +91,10 @@ async def add(self, documents: list[RaggyDocument]) -> list[ChromaDocument]:
9091
ids = [doc.id for doc in unique_documents]
9192
texts = [doc.text for doc in unique_documents]
9293
metadatas = [
93-
doc.metadata.model_dump(exclude_none=True) for doc in unique_documents
94+
doc.metadata.model_dump(exclude_none=True)
95+
if isinstance(doc.metadata, DocumentMetadata)
96+
else None
97+
for doc in unique_documents
9498
]
9599

96100
embeddings = await create_openai_embeddings(texts)
@@ -145,7 +149,9 @@ async def upsert(self, documents: list[RaggyDocument]) -> list[ChromaDocument]:
145149
ids=[document.id for document in documents],
146150
documents=[document.text for document in documents],
147151
metadatas=[
148-
document.metadata.model_dump(exclude_none=True) or None
152+
document.metadata.model_dump(exclude_none=True)
153+
if isinstance(document.metadata, DocumentMetadata)
154+
else None
149155
for document in documents
150156
],
151157
embeddings=await create_openai_embeddings(

0 commit comments

Comments
 (0)