|
18 | 18 | )
|
19 | 19 |
|
20 | 20 | from raggy.documents import Document as RaggyDocument
|
| 21 | +from raggy.documents import DocumentMetadata |
21 | 22 | from raggy.settings import settings
|
22 | 23 | from raggy.utilities.asyncutils import run_sync_in_worker_thread
|
23 | 24 | from raggy.utilities.embeddings import create_openai_embeddings
|
@@ -90,7 +91,10 @@ async def add(self, documents: list[RaggyDocument]) -> list[ChromaDocument]:
|
90 | 91 | ids = [doc.id for doc in unique_documents]
|
91 | 92 | texts = [doc.text for doc in unique_documents]
|
92 | 93 | 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 |
94 | 98 | ]
|
95 | 99 |
|
96 | 100 | embeddings = await create_openai_embeddings(texts)
|
@@ -145,7 +149,9 @@ async def upsert(self, documents: list[RaggyDocument]) -> list[ChromaDocument]:
|
145 | 149 | ids=[document.id for document in documents],
|
146 | 150 | documents=[document.text for document in documents],
|
147 | 151 | 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 |
149 | 155 | for document in documents
|
150 | 156 | ],
|
151 | 157 | embeddings=await create_openai_embeddings(
|
|
0 commit comments