-
Notifications
You must be signed in to change notification settings - Fork 216
feature: OpeaStore Class #1493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feature: OpeaStore Class #1493
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
3c96817
Revert "Support parametrization of nginx port (#1456)" (#1473)
ZePan110 c6a8d46
add nginx src into example test trigger path (#1474)
chensuyue 4f55914
Bump version of web search (#1451)
Spycsh 4b9e2a7
Docker support for nebula (#1396)
siddhivelankar23 6d3abbc
initial commit
aMahanna 79abb45
cleanup
aMahanna aec87fe
fix: docstring
aMahanna 3f2e0ff
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] c3ae3ac
new: `search`
aMahanna c4501d6
new: async methods
aMahanna ae7e0f5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 9889dad
CICD update to adapt the new xeon test cluster (#1475)
chensuyue 72fc88a
ignore false positive errors in reseting cache permissions (#1489)
dtrawins 76d00a6
Fix finetuning python regex syntax error (#1446)
eero-t 5c04b9f
new: OpeaStore models
aMahanna 16bf60e
attempt: doc fix
aMahanna 5a1bfb1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 3d58254
Update nofile's hard limit to 262144 for opensearch (#1495)
ashahba 6facd2f
unify service ports in compose and READMEs (#1506)
letonghan b9db610
fix: copyright for arangodb
aMahanna 578e309
new: `developer.md`
aMahanna 2a4abfd
cleanup: `opea_store`
aMahanna a2f793d
Remove langchain-huggingface from requirement. (#1505)
ZePan110 b7cde03
add model cache for example test (#1509)
chensuyue 5a07fe9
Fix Dataprep ingest PPT and async issues (#1504)
letonghan b0a05d2
Integrate UI-TARS vLLM in lvm component (#1458)
Spycsh ab85d33
Fix model cache path and use Random to avoid ns conflict (#1500)
yongfengdu 36675fb
MultimodalQnA audio features completion (#1433)
mhbuehler e661ae8
[Bug: 1379] Added Multimodal support for Milvus for retriever compone…
srajabos 32609bf
VDMS langchain package update (#1317)
cwlacewe 993e13e
fix: `test_arangodb`
aMahanna 7132b94
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 40b6426
add python-arango dep
aMahanna 0d4e648
Enable Telemetry Tracing in Agent Comp and also add class name along …
louie-tsai db94030
Fix CI workflow (#1518)
chensuyue cfd1f71
minor fix gpt-sovits service names (#1521)
Spycsh f286598
remove concurrency in image build and push workflow (#1510)
chensuyue 9a66ce3
Add in entrypoint new download links for wav2lip and wav2lip_gan mode…
ctao456 caec4a6
Add xtune to finetuning (#1432)
jilongW 66347b5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 031ada8
rem: decorator
aMahanna 6f5af84
Unset TEI_EMBEDDING_ENDPOINT when running multimodal redis retriever …
dmsuehir d837d2d
Data Ingestion and Retrieval with custom index_name (#1439)
MSCetin37 c574c85
Update Gaudi Docker to v1.19.0 and PyTorch Installer 2.5.1 (#1513)
ashahba f83abf5
Limit vllm and vllm-fork tags (#1529)
ZePan110 ffaa0b2
new: `health_check`
aMahanna 7552e3d
Merge branch 'main' into feature/opeastore
aMahanna File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,248 @@ | ||
| # Copyright (C) 2024 Intel Corporation | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| from abc import ABC, abstractmethod | ||
| from typing import Any | ||
|
|
||
| from ..mega.logger import CustomLogger | ||
|
|
||
| logger = CustomLogger("OpeaStore") | ||
|
|
||
|
|
||
| class OpeaStore(ABC): | ||
| """The OpeaStore class serves as the base class for all Storage APIs. | ||
| It provides a unified interface and foundational attributes that every derived Storage API inherits and extends. | ||
|
|
||
| Attributes: | ||
| name (str): The name of the component (e.g 'arangodb', 'redis', 'mongodb', etc.) | ||
| description (str): A brief description of the component's functionality. | ||
| config (dict): A dictionary containing configuration parameters for the component. | ||
| """ | ||
|
|
||
| def __init__(self, name: str, description: str = "", config: dict = {}): | ||
aMahanna marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """Initializes an OpeaComponent instance with the provided attributes. | ||
|
|
||
| Args: | ||
| name (str): The name of the component. | ||
| description (str): A brief description of the component. | ||
| config (dict, optional): Configuration parameters for the component. Defaults to an empty dictionary. | ||
| """ | ||
| self.name = name | ||
| self.description = description | ||
| self.config = config if config is not None else {} | ||
|
|
||
| def get_meta(self) -> dict: | ||
| """Retrieves metadata about the component, including its name, type, description, and configuration. | ||
|
|
||
| Returns: | ||
| dict: A dictionary containing the component's metadata. | ||
| """ | ||
| return { | ||
| "name": self.name, | ||
| "description": self.description, | ||
| "config": self.config, | ||
| } | ||
|
|
||
| def update_config(self, key: str, value): | ||
| """Updates a configuration parameter for the component. | ||
|
|
||
| Args: | ||
| key (str): The configuration parameter's key. | ||
| value: The new value for the configuration parameter. | ||
| """ | ||
| self.config[key] = value | ||
|
|
||
| def health_check(self) -> bool: | ||
| """Performs a health check on the component to ensure it is connected to | ||
| the database correctly. | ||
|
|
||
| Returns: | ||
| bool: True if the component is healthy, False otherwise. | ||
| """ | ||
| raise NotImplementedError("health_check method must be implemented by subclasses.") | ||
|
|
||
| def __repr__(self): | ||
| """Provides a string representation of the component for debugging and logging purposes. | ||
|
|
||
| Returns: | ||
| str: A string representation of the OpeaComponent instance. | ||
| """ | ||
| return f"OpeaStore(name={self.name}, type={self.type}, description={self.description})" | ||
|
|
||
| def save_document(self, doc: dict) -> None: | ||
| """Save a single document to the store. | ||
| Document can optionally contain a unique identifier. | ||
|
|
||
| Args: | ||
| doc (dict): The document data to save. | ||
| """ | ||
| raise NotImplementedError("save_document method must be implemented by subclasses.") | ||
|
|
||
| async def asave_document(self, doc: dict) -> None: | ||
| """Asynchronously save a single document to the store. | ||
| Document can optionally contain a unique identifier. | ||
|
|
||
| Args: | ||
| doc (dict): The document data to save. | ||
| """ | ||
| raise NotImplementedError("asave_document method must be implemented by subclasses.") | ||
|
|
||
| def save_documents(self, docs: list[dict]) -> None: | ||
| """Save multiple documents to the store. | ||
| Documents can optionally contain unique identifiers. | ||
|
|
||
| Args: | ||
| docs (list[dict]): A list of document data to save. | ||
| """ | ||
| raise NotImplementedError("save_documents method must be implemented by subclasses.") | ||
|
|
||
| async def asave_documents(self, docs: list[dict]) -> None: | ||
| """Asynchronously save multiple documents to the store. | ||
| Documents can optionally contain unique identifiers. | ||
|
|
||
| Args: | ||
| docs (list[dict]): A list of document data to save. | ||
| """ | ||
| raise NotImplementedError("asave_documents method must be implemented by subclasses.") | ||
|
|
||
| def update_document(self, doc: dict) -> None: | ||
| """Update a single document in the store. | ||
| Document must contain its unique identifier. | ||
|
|
||
| Args: | ||
| doc (dict): The document data to update. | ||
| """ | ||
| raise NotImplementedError("update_document method must be implemented by subclasses.") | ||
|
|
||
| async def aupdate_document(self, doc: dict) -> None: | ||
| """Asynchronously update a single document in the store. | ||
| Document must contain its unique identifier. | ||
|
|
||
| Args: | ||
| doc (dict): The document data to update. | ||
| """ | ||
| raise NotImplementedError("aupdate_document method must be implemented by subclasses.") | ||
|
|
||
| def update_documents(self, docs: list[dict]) -> None: | ||
| """Update multiple documents in the store. | ||
| Each document must contain its unique identifier. | ||
|
|
||
| Args: | ||
| docs (list[dict]): The list of documents to update. | ||
| """ | ||
| raise NotImplementedError("update_documents method must be implemented by subclasses.") | ||
|
|
||
| async def aupdate_documents(self, docs: list[dict]) -> None: | ||
| """Asynchronously update multiple documents in the store. | ||
| Each document must contain its unique identifier. | ||
|
|
||
| Args: | ||
| docs (list[dict]): The list of documents to update. | ||
| """ | ||
| raise NotImplementedError("aupdate_documents method must be implemented by subclasses.") | ||
|
|
||
| def get_document_by_id(self, id: str) -> dict: | ||
| """Retrieve a single document by its unique identifier. | ||
|
|
||
| Args: | ||
| id (str): The unique identifier for the document. | ||
|
|
||
| Returns: | ||
| dict: The retrieved document data. | ||
| """ | ||
| raise NotImplementedError("get_document_by_id method must be implemented by subclasses.") | ||
|
|
||
| async def aget_document_by_id(self, id: str) -> dict: | ||
| """Asynchronously retrieve a single document by its unique identifier. | ||
|
|
||
| Args: | ||
| id (str): The unique identifier for the document. | ||
|
|
||
| Returns: | ||
| dict: The retrieved document data. | ||
| """ | ||
| raise NotImplementedError("aget_document_by_id method must be implemented by subclasses.") | ||
|
|
||
| def get_documents_by_ids(self, ids: list[str]) -> list[dict]: | ||
| """Retrieve multiple documents by their unique identifiers. | ||
|
|
||
| Args: | ||
| ids (list[str]): A list of unique identifiers for the documents. | ||
|
|
||
| Returns: | ||
| list[dict]: A list of retrieved document data. | ||
| """ | ||
| raise NotImplementedError("get_documents_by_ids method must be implemented by subclasses.") | ||
|
|
||
| async def aget_documents_by_ids(self, ids: list[str]) -> list[dict]: | ||
| """Asynchronously retrieve multiple documents by their unique identifiers. | ||
|
|
||
| Args: | ||
| ids (list[str]): A list of unique identifiers for the documents. | ||
|
|
||
| Returns: | ||
| list[dict]: A list of retrieved document data. | ||
| """ | ||
| raise NotImplementedError("aget_documents_by_ids method must be implemented by subclasses.") | ||
|
|
||
| def delete_document(self, id: str) -> None: | ||
| """Delete a single document from the store. | ||
|
|
||
| Args: | ||
| id (str): The unique identifier for the document. | ||
| """ | ||
| raise NotImplementedError("delete_document method must be implemented by subclasses.") | ||
|
|
||
| async def adelete_document(self, id: str) -> None: | ||
| """Asynchronously delete a single document from the store. | ||
|
|
||
| Args: | ||
| id (str): The unique identifier for the document. | ||
| """ | ||
| raise NotImplementedError("adelete_document method must be implemented by subclasses.") | ||
|
|
||
| def delete_documents(self, ids: list[str]) -> None: | ||
| """Delete multiple documents from the store. | ||
|
|
||
| Args: | ||
| ids (list[str]): A list of unique identifiers for the documents. | ||
| """ | ||
| raise NotImplementedError("delete_documents method must be implemented by subclasses.") | ||
|
|
||
| async def adelete_documents(self, ids: list[str]) -> None: | ||
| """Asynchronously delete multiple documents from the store. | ||
|
|
||
| Args: | ||
| ids (list[str]): A list of unique identifiers for the documents. | ||
| """ | ||
| raise NotImplementedError("adelete_documents method must be implemented by subclasses.") | ||
|
|
||
| def search(self, key: str, value: Any, search_type: str = "exact", **kwargs) -> list[dict]: | ||
| """Search for documents in the store based on a specific key-value pair. | ||
|
|
||
| Args: | ||
| key (str): The key to search for. | ||
| value (str): The value to search for. | ||
| search_type (str): The type of search to perform. | ||
| Can be ignored for some implementations. | ||
| **kwargs: Additional arguments for the search query. | ||
|
|
||
| Returns: | ||
| list[dict]: A list of documents matching the search criteria. | ||
| """ | ||
| raise NotImplementedError("search_by_keyword method must be implemented by subclasses.") | ||
|
|
||
| async def asearch(self, key: str, value: Any, search_type: str = "exact", **kwargs) -> list[dict]: | ||
| """Asynchronously search for documents in the store based on a specific key-value pair. | ||
|
|
||
| Args: | ||
| key (str): The key to search for. | ||
| value (str): The value to search for. | ||
| search_type (str): The type of search to perform. | ||
| Can be ignored for some implementations. | ||
| **kwargs: Additional arguments for the search query. | ||
|
|
||
| Returns: | ||
| list[dict]: A list of documents matching the search criteria. | ||
| """ | ||
| raise NotImplementedError("asearch_by_keyword method must be implemented by subclasses.") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Copyright (C) 2025 Intel Corporation | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| from .arangodb import ArangoDBStore | ||
|
|
||
| # from .redisdb import RedisDBStore | ||
| # from .mongodb import MongoDBStore | ||
|
|
||
|
|
||
| def opea_store(name: str, *args, **kwargs): | ||
| if name == "arangodb": | ||
| return ArangoDBStore(name, *args, **kwargs) | ||
| # elif name == "redis": | ||
| # return RedisDBStore(*args, **kwargs) | ||
| # elif name == "mongodb": | ||
| # return MongoDBStore(*args, **kwargs) | ||
| else: | ||
| raise ValueError(f"Unknown Data Store: {name}") | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.