diff --git a/src/utils/types.py b/src/utils/types.py index 202754a15..b132c02e4 100644 --- a/src/utils/types.py +++ b/src/utils/types.py @@ -154,8 +154,8 @@ class RAGChunk(BaseModel): """Model representing a RAG chunk used in the response.""" content: str = Field(description="The content of the chunk") - source: Optional[str] = Field(None, description="Source document or URL") - score: Optional[float] = Field(None, description="Relevance score") + source: Optional[str] = Field(default=None, description="Source document or URL") + score: Optional[float] = Field(default=None, description="Relevance score") class ReferencedDocument(BaseModel): diff --git a/tests/unit/models/responses/test_rag_chunk.py b/tests/unit/models/responses/test_rag_chunk.py index 53fcdaaa8..d9809eade 100644 --- a/tests/unit/models/responses/test_rag_chunk.py +++ b/tests/unit/models/responses/test_rag_chunk.py @@ -39,16 +39,14 @@ def test_constructor_with_content_and_source(self) -> None: chunk = RAGChunk( content="Container orchestration automates deployment", source="docs/concepts.md", - ) # pyright: ignore[reportCallIssue] + ) assert chunk.content == "Container orchestration automates deployment" assert chunk.source == "docs/concepts.md" assert chunk.score is None def test_constructor_with_content_and_score(self) -> None: """Test RAGChunk constructor with content and score.""" - chunk = RAGChunk( - content="Pod is the smallest deployable unit", score=0.82 - ) # pyright: ignore[reportCallIssue] + chunk = RAGChunk(content="Pod is the smallest deployable unit", score=0.82) assert chunk.content == "Pod is the smallest deployable unit" assert chunk.source is None assert chunk.score == 0.82 @@ -56,26 +54,20 @@ def test_constructor_with_content_and_score(self) -> None: def test_score_range_validation(self) -> None: """Test that RAGChunk accepts valid score ranges.""" # Test minimum score - chunk_min = RAGChunk( - content="Test content", score=0.0 - ) # pyright: ignore[reportCallIssue] + chunk_min = RAGChunk(content="Test content", score=0.0) assert chunk_min.score == 0.0 # Test maximum score - chunk_max = RAGChunk( - content="Test content", score=1.0 - ) # pyright: ignore[reportCallIssue] + chunk_max = RAGChunk(content="Test content", score=1.0) assert chunk_max.score == 1.0 # Test decimal score - chunk_decimal = RAGChunk( - content="Test content", score=0.751 - ) # pyright: ignore[reportCallIssue] + chunk_decimal = RAGChunk(content="Test content", score=0.751) assert chunk_decimal.score == 0.751 def test_empty_content(self) -> None: """Test RAGChunk with empty content.""" - chunk = RAGChunk(content="") # pyright: ignore[reportCallIssue] + chunk = RAGChunk(content="") assert chunk.content == "" assert chunk.source is None assert chunk.score is None @@ -107,7 +99,7 @@ def test_long_source_path(self) -> None: ) chunk = RAGChunk( content="Content from deeply nested document", source=long_source - ) # pyright: ignore[reportCallIssue] + ) assert chunk.source == long_source def test_url_as_source(self) -> None: