Skip to content

Commit

Permalink
fix: filter out documents with empty content in get_documents function (
Browse files Browse the repository at this point in the history
  • Loading branch information
elisalimli committed Apr 18, 2024
1 parent ee07e96 commit 32bde47
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions service/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ async def get_documents(
*, vector_service: BaseVectorDatabase, payload: RequestPayload
) -> list[BaseDocumentChunk]:
chunks = await vector_service.query(input=payload.input, top_k=5)
# filter out documents with empty content
chunks = [chunk for chunk in chunks if chunk.content.strip()]
if not len(chunks):
logger.error(f"No documents found for query: {payload.input}")
return []
Expand Down

0 comments on commit 32bde47

Please sign in to comment.