Skip to content

Commit

Permalink
WIP: start and end index for retriever SearchResult
Browse files Browse the repository at this point in the history
  • Loading branch information
NickyHavoc committed Apr 5, 2024
1 parent c48e0be commit 8614af3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ class DocumentChunk(BaseModel):
Attributes:
text: Chunk of the document that matched the search query.
metadata: Any metadata added to the document.
start: Start index of the chunk within the document
end: End index of the chunk within the document
"""

text: str
metadata: Any = None
start: int
end: int


ID = TypeVar("ID")
Expand Down
2 changes: 2 additions & 0 deletions tests/use_cases/search/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ def test_search(
assert [to_document(r.document_chunk) for r in result.results] == [
in_memory_retriever_documents[2]
]
assert result.results[0].document_chunk.start == 0
assert result.results[0].document_chunk.end == len(in_memory_retriever_documents[2].text) - 1

0 comments on commit 8614af3

Please sign in to comment.