Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ ignore = ["D100", "D101", "D102", "D103", "D104", "D105", "D107", "D203", "D212"
# (Use of `assert` detected) is the only rule that meaningfully
# diverges from the codebase-wide lint config for test files.
"tests/**/*.py" = ["S101"]
# Indexing helpers (index.py) and the langchain shim
# (infrastructure.py) use function-local imports to break
# circular dependency cycles between the bounded context and
# the cross-context domain. PLC0415 is locally suppressed.
"src/bodhi_rag/indexing/**/*.py" = ["PLC0415"]
# Indexing application helpers (`index.py`, `delete.py`) use
# function-local imports to break circular dependency cycles
# between the bounded context and the cross-context domain.
# PLC0415 is locally suppressed only for the application slice.
"src/bodhi_rag/indexing/application/**/*.py" = ["PLC0415"]

[tool.mypy]
python_version = "3.11"
Expand Down
2 changes: 1 addition & 1 deletion src/bodhi_rag/answering/application/synthesize.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from bodhi_rag.domain.entities import RetrievedDocument
from bodhi_rag.ports.llm import LLMMessage, LLMPort
from bodhi_rag.ports.vector_store import RetrievedDocument


SYSTEM_MESSAGE = (
Expand Down
30 changes: 1 addition & 29 deletions src/bodhi_rag/application/facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,13 @@
if TYPE_CHECKING:
from bodhi_rag.answering.application.synthesize import SynthesizeAnswerUseCase
from bodhi_rag.conversation.application.memory import ConversationMemoryUseCase
from bodhi_rag.domain.entities import ConversationTurn
from bodhi_rag.domain.entities import ConversationTurn, RetrievedDocument
from bodhi_rag.domain.value_objects import ConversationId, DocumentId
from bodhi_rag.indexing.application.delete import DeleteDocumentUseCase
from bodhi_rag.indexing.application.index import IndexDocumentUseCase
from bodhi_rag.ports.vector_store import RetrievedDocument
from bodhi_rag.retrieval.application.retrieve import RetrieveQueryUseCase


RESERVED_PROVENANCE_KEYS = frozenset(
{
"source",
"source_path",
"filename",
"file_type",
"page_count",
"author",
"title",
"subject",
},
)


def _merge_document_metadata(
parser_metadata: dict[str, Any],
request_metadata: dict[str, Any],
) -> dict[str, Any]:
merged = dict(parser_metadata)
for key, value in request_metadata.items():
if key in RESERVED_PROVENANCE_KEYS:
merged[f"user_{key}"] = value
continue
merged[key] = value
return merged


def _citation_source_document(retrieved_document: RetrievedDocument) -> str:
filename = retrieved_document.metadata.get("filename")
if isinstance(filename, str) and filename:
Expand Down
13 changes: 0 additions & 13 deletions src/bodhi_rag/indexing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
__all__ = [
"IndexDocumentsRequest",
"IndexDocumentsResponse",
"IndexingSettings",
"load_documents_from_directory",
"load_documents_from_file",
]

_EXPORTS = {
Expand All @@ -22,23 +19,13 @@
"bodhi_rag.application.models",
"IndexDocumentsResponse",
),
"IndexingSettings": ("bodhi_rag.indexing.settings", "IndexingSettings"),
"load_documents_from_directory": (
"bodhi_rag.indexing.infrastructure",
"load_documents_from_directory",
),
"load_documents_from_file": (
"bodhi_rag.indexing.infrastructure",
"load_documents_from_file",
),
}

if TYPE_CHECKING:
from bodhi_rag.application.models import (
IndexDocumentsRequest,
IndexDocumentsResponse,
)
from bodhi_rag.indexing.settings import IndexingSettings


def __getattr__(name: str) -> Any:
Expand Down
97 changes: 0 additions & 97 deletions src/bodhi_rag/indexing/infrastructure.py

This file was deleted.

24 changes: 0 additions & 24 deletions src/bodhi_rag/indexing/ports.py

This file was deleted.

41 changes: 0 additions & 41 deletions src/bodhi_rag/indexing/settings.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/bodhi_rag/interfaces/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Interface adapters for bodhi-rag platform entrypoints."""

__all__ = ["api", "cli", "tui", "worker"]
__all__ = ["api", "cli"]
2 changes: 1 addition & 1 deletion src/bodhi_rag/ports/reranker.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from typing import TYPE_CHECKING, Protocol, runtime_checkable

if TYPE_CHECKING:
from bodhi_rag.ports.vector_store import RetrievedDocument
from bodhi_rag.domain.entities import RetrievedDocument


@runtime_checkable
Expand Down
16 changes: 1 addition & 15 deletions src/bodhi_rag/ports/vector_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,10 @@
from typing import TYPE_CHECKING, Protocol

if TYPE_CHECKING:
from bodhi_rag.domain.entities import Chunk
from bodhi_rag.domain.entities import Chunk, RetrievedDocument
from bodhi_rag.domain.value_objects import DocumentId


class RetrievedDocument(Protocol):
"""
A document retrieved from the vector store.

This is a protocol to avoid coupling to specific implementations.
"""

chunk_id: str
document_id: str
text: str
score: float
metadata: dict


class VectorStorePort(Protocol):
"""
Protocol for vector storage and retrieval.
Expand Down
3 changes: 2 additions & 1 deletion src/bodhi_rag/retrieval/application/retrieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from bodhi_rag.domain.entities import RetrievedDocument
from bodhi_rag.ports.embedding import EmbeddingPort
from bodhi_rag.ports.reranker import RerankerPort
from bodhi_rag.ports.vector_store import RetrievedDocument, VectorStorePort
from bodhi_rag.ports.vector_store import VectorStorePort


class RetrieveQueryUseCase:
Expand Down
75 changes: 0 additions & 75 deletions tests/bodhi_rag/test_indexing_infrastructure.py

This file was deleted.

Loading