From cb422a106cc5da49873fcdcf1fd6d31fd1af59e2 Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Mon, 4 Dec 2023 10:00:23 +0100 Subject: [PATCH] update to latest api --- README.md | 3 +-- pyproject.toml | 1 - src/example_store/document_store.py | 9 ++++----- src/example_store/retriever.py | 2 +- tests/test_document_store.py | 2 +- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 83899df..5a489cc 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,7 @@ # Example Store This Github repository is a template that can be used to create custom document stores to extend -the new [Haystack](https://github.com/deepset-ai/haystack/) API available under the `preview` -package starting from version 1.15. +the new [Haystack](https://github.com/deepset-ai/haystack/) API available from version 2.0. While the new API is still under active development, the new "Store" architecture is quite stable and we are encouraging early adopters to contribute their custom document stores. diff --git a/pyproject.toml b/pyproject.toml index 8041e77..2fb32b4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,6 @@ classifiers = [ "Programming Language :: Python :: Implementation :: PyPy", ] dependencies = [ - # we distribute the preview version of Haystack 2.0 under the package "haystack-ai" "haystack-ai", "typing_extensions", ] diff --git a/src/example_store/document_store.py b/src/example_store/document_store.py index afa9560..9d2b662 100644 --- a/src/example_store/document_store.py +++ b/src/example_store/document_store.py @@ -4,15 +4,13 @@ import logging from typing import Any, Dict, List, Optional -from haystack.preview.dataclasses import Document -from haystack.preview.document_stores.decorator import document_store -from haystack.preview.document_stores.errors import DuplicateDocumentError, MissingDocumentError -from haystack.preview.document_stores.protocols import DuplicatePolicy +from haystack.dataclasses import Document +from haystack.document_stores.errors import DuplicateDocumentError, MissingDocumentError +from haystack.document_stores.protocols import DuplicatePolicy logger = logging.getLogger(__name__) -@document_store class ExampleDocumentStore: # FIXME """ Except for the __init__(), signatures of any other method in this class must not change. @@ -116,6 +114,7 @@ def write_documents(self, documents: List[Document], policy: DuplicatePolicy = D for _ in documents: # FIXME if policy == DuplicatePolicy.FAIL: raise DuplicateDocumentError + return 0 def delete_documents(self, document_ids: List[str]) -> None: """ diff --git a/src/example_store/retriever.py b/src/example_store/retriever.py index 3be6eeb..6ceeb24 100644 --- a/src/example_store/retriever.py +++ b/src/example_store/retriever.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 from typing import Any, Dict, Optional -from haystack.preview import component +from haystack import component from example_store import ExampleDocumentStore diff --git a/tests/test_document_store.py b/tests/test_document_store.py index fc7aafc..9ec0e31 100644 --- a/tests/test_document_store.py +++ b/tests/test_document_store.py @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 import pytest -from haystack.preview.testing.document_store import DocumentStoreBaseTests +from haystack.testing.document_store import DocumentStoreBaseTests from example_store.document_store import ExampleDocumentStore