Skip to content

Commit

Permalink
update to latest api
Browse files Browse the repository at this point in the history
  • Loading branch information
masci committed Dec 4, 2023
1 parent f88ec10 commit cb422a1
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand Down
9 changes: 4 additions & 5 deletions src/example_store/document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
"""
Expand Down
2 changes: 1 addition & 1 deletion src/example_store/retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/test_document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit cb422a1

Please sign in to comment.