fix: adjusting test to the new Optional DocumentChunk property
This commit is contained in:
parent
70727332ee
commit
2d2a7d69d3
2 changed files with 36 additions and 4 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
import pathlib
|
import pathlib
|
||||||
|
from typing import List
|
||||||
import cognee
|
import cognee
|
||||||
from cognee.low_level import setup
|
from cognee.low_level import setup
|
||||||
from cognee.tasks.storage import add_data_points
|
from cognee.tasks.storage import add_data_points
|
||||||
|
|
@ -10,6 +10,20 @@ from cognee.modules.chunking.models import DocumentChunk
|
||||||
from cognee.modules.data.processing.document_types import TextDocument
|
from cognee.modules.data.processing.document_types import TextDocument
|
||||||
from cognee.modules.retrieval.exceptions.exceptions import NoDataError
|
from cognee.modules.retrieval.exceptions.exceptions import NoDataError
|
||||||
from cognee.modules.retrieval.chunks_retriever import ChunksRetriever
|
from cognee.modules.retrieval.chunks_retriever import ChunksRetriever
|
||||||
|
from cognee.infrastructure.engine import DataPoint
|
||||||
|
from cognee.modules.data.processing.document_types import Document
|
||||||
|
from cognee.modules.engine.models import Entity
|
||||||
|
|
||||||
|
|
||||||
|
class DocumentChunkWithEntities(DataPoint):
|
||||||
|
text: str
|
||||||
|
chunk_size: int
|
||||||
|
chunk_index: int
|
||||||
|
cut_type: str
|
||||||
|
is_part_of: Document
|
||||||
|
contains: List[Entity] = None
|
||||||
|
|
||||||
|
metadata: dict = {"index_fields": ["text"]}
|
||||||
|
|
||||||
|
|
||||||
class TestChunksRetriever:
|
class TestChunksRetriever:
|
||||||
|
|
@ -179,7 +193,9 @@ class TestChunksRetriever:
|
||||||
await retriever.get_context("Christina Mayer")
|
await retriever.get_context("Christina Mayer")
|
||||||
|
|
||||||
vector_engine = get_vector_engine()
|
vector_engine = get_vector_engine()
|
||||||
await vector_engine.create_collection("DocumentChunk_text", payload_schema=DocumentChunk)
|
await vector_engine.create_collection(
|
||||||
|
"DocumentChunk_text", payload_schema=DocumentChunkWithEntities
|
||||||
|
)
|
||||||
|
|
||||||
context = await retriever.get_context("Christina Mayer")
|
context = await retriever.get_context("Christina Mayer")
|
||||||
assert len(context) == 0, "Found chunks when none should exist"
|
assert len(context) == 0, "Found chunks when none should exist"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import os
|
import os
|
||||||
|
from typing import List
|
||||||
import pytest
|
import pytest
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
import cognee
|
import cognee
|
||||||
from cognee.low_level import setup
|
from cognee.low_level import setup
|
||||||
from cognee.tasks.storage import add_data_points
|
from cognee.tasks.storage import add_data_points
|
||||||
|
|
@ -10,6 +10,20 @@ from cognee.modules.chunking.models import DocumentChunk
|
||||||
from cognee.modules.data.processing.document_types import TextDocument
|
from cognee.modules.data.processing.document_types import TextDocument
|
||||||
from cognee.modules.retrieval.exceptions.exceptions import NoDataError
|
from cognee.modules.retrieval.exceptions.exceptions import NoDataError
|
||||||
from cognee.modules.retrieval.completion_retriever import CompletionRetriever
|
from cognee.modules.retrieval.completion_retriever import CompletionRetriever
|
||||||
|
from cognee.infrastructure.engine import DataPoint
|
||||||
|
from cognee.modules.data.processing.document_types import Document
|
||||||
|
from cognee.modules.engine.models import Entity
|
||||||
|
|
||||||
|
|
||||||
|
class DocumentChunkWithEntities(DataPoint):
|
||||||
|
text: str
|
||||||
|
chunk_size: int
|
||||||
|
chunk_index: int
|
||||||
|
cut_type: str
|
||||||
|
is_part_of: Document
|
||||||
|
contains: List[Entity] = None
|
||||||
|
|
||||||
|
metadata: dict = {"index_fields": ["text"]}
|
||||||
|
|
||||||
|
|
||||||
class TestRAGCompletionRetriever:
|
class TestRAGCompletionRetriever:
|
||||||
|
|
@ -182,7 +196,9 @@ class TestRAGCompletionRetriever:
|
||||||
await retriever.get_context("Christina Mayer")
|
await retriever.get_context("Christina Mayer")
|
||||||
|
|
||||||
vector_engine = get_vector_engine()
|
vector_engine = get_vector_engine()
|
||||||
await vector_engine.create_collection("DocumentChunk_text", payload_schema=DocumentChunk)
|
await vector_engine.create_collection(
|
||||||
|
"DocumentChunk_text", payload_schema=DocumentChunkWithEntities
|
||||||
|
)
|
||||||
|
|
||||||
context = await retriever.get_context("Christina Mayer")
|
context = await retriever.get_context("Christina Mayer")
|
||||||
assert context == "", "Returned context should be empty on an empty graph"
|
assert context == "", "Returned context should be empty on an empty graph"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue