Skip to content

Commit b02139d

Browse files
authored
chore: pinecone response to DocumentChunkWithScore (#395)
When dealing with Pinecone occurs sporadically situations where `metadata["text"]` contains a datetime object somehow. This raises an Internal Error since Pydantic is unable to create a DocumentChunkWithScore object. We force the typing to str to fix this. Example: ``` {'matches': [{'id': '68_1', 'metadata': {'document_id': '68', 'text': datetime.date(2265, 12, 1)}, 'score': 0.760368824, 'values': []}, ```
1 parent b3459b1 commit b02139d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

datastore/providers/pinecone_datastore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ async def _single_query(query: QueryWithEmbedding) -> QueryResult:
159159
result = DocumentChunkWithScore(
160160
id=result.id,
161161
score=score,
162-
text=metadata["text"] if metadata and "text" in metadata else None,
162+
text=str(metadata["text"]) if metadata and "text" in metadata else "",
163163
metadata=metadata_without_text,
164164
)
165165
query_results.append(result)

0 commit comments

Comments
 (0)