diff --git a/CHANGELOG.md b/CHANGELOG.md index d9083a9..4153060 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,10 @@ and this project adheres to - 🏗️(back) migrate to uv - ♻️(front) optimize syntax highlighting bundle size +### Fixed + +- 🐛(back) Cast collection Ids to API expected types + ## [0.0.12] - 2026-01-27 ### Fixed diff --git a/src/backend/chat/agent_rag/document_rag_backends/albert_rag_backend.py b/src/backend/chat/agent_rag/document_rag_backends/albert_rag_backend.py index 2e859f6..bc170fe 100644 --- a/src/backend/chat/agent_rag/document_rag_backends/albert_rag_backend.py +++ b/src/backend/chat/agent_rag/document_rag_backends/albert_rag_backend.py @@ -48,6 +48,11 @@ class AlbertRagBackend(BaseRagBackend): # pylint: disable=too-many-instance-att parser_class = import_string(settings.RAG_DOCUMENT_PARSER) self.parser = parser_class() + @staticmethod + def cast_collection_id(collection_id): + """Albert API expects int Ids.""" + return int(collection_id) + def create_collection(self, name: str, description: Optional[str] = None) -> str: """ Create a temporary collection for the search operation. diff --git a/src/backend/chat/agent_rag/document_rag_backends/base_rag_backend.py b/src/backend/chat/agent_rag/document_rag_backends/base_rag_backend.py index ed98c1d..615120b 100644 --- a/src/backend/chat/agent_rag/document_rag_backends/base_rag_backend.py +++ b/src/backend/chat/agent_rag/document_rag_backends/base_rag_backend.py @@ -41,6 +41,11 @@ class BaseRagBackend(ABC): self._default_collection_description = "Temporary collection for RAG document search" self.parser: BaseParser = BaseParser() + @staticmethod + def cast_collection_id(collection_id): + """Dummy method to be overridden when needed.""" + return collection_id + def get_all_collection_ids(self) -> List[str]: """ Get all collection IDs, including the main collection ID and read-only collection IDs. @@ -55,10 +60,13 @@ class BaseRagBackend(ABC): collection_ids = [] if self.collection_id: - collection_ids.append(self.collection_id) + collection_ids.append(self.cast_collection_id(self.collection_id)) if self.read_only_collection_id: collection_ids.extend( - [int(collection_id) for collection_id in self.read_only_collection_id] + [ + self.cast_collection_id(collection_id) + for collection_id in self.read_only_collection_id + ] ) return collection_ids