Skip to content
Merged
Show file tree
Hide file tree
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 Mar 28, 2025
c6a8d46
add nginx src into example test trigger path (#1474)
chensuyue Mar 28, 2025
4f55914
Bump version of web search (#1451)
Spycsh Mar 28, 2025
4b9e2a7
Docker support for nebula (#1396)
siddhivelankar23 Mar 29, 2025
6d3abbc
initial commit
aMahanna Mar 30, 2025
79abb45
cleanup
aMahanna Mar 31, 2025
aec87fe
fix: docstring
aMahanna Mar 31, 2025
3f2e0ff
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 31, 2025
c3ae3ac
new: `search`
aMahanna Mar 31, 2025
c4501d6
new: async methods
aMahanna Mar 31, 2025
ae7e0f5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 31, 2025
9889dad
CICD update to adapt the new xeon test cluster (#1475)
chensuyue Mar 31, 2025
72fc88a
ignore false positive errors in reseting cache permissions (#1489)
dtrawins Mar 31, 2025
76d00a6
Fix finetuning python regex syntax error (#1446)
eero-t Mar 31, 2025
5c04b9f
new: OpeaStore models
aMahanna Apr 1, 2025
16bf60e
attempt: doc fix
aMahanna Apr 1, 2025
5a1bfb1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 1, 2025
3d58254
Update nofile's hard limit to 262144 for opensearch (#1495)
ashahba Apr 1, 2025
6facd2f
unify service ports in compose and READMEs (#1506)
letonghan Apr 1, 2025
b9db610
fix: copyright for arangodb
aMahanna Apr 2, 2025
578e309
new: `developer.md`
aMahanna Apr 2, 2025
2a4abfd
cleanup: `opea_store`
aMahanna Apr 2, 2025
a2f793d
Remove langchain-huggingface from requirement. (#1505)
ZePan110 Apr 2, 2025
b7cde03
add model cache for example test (#1509)
chensuyue Apr 2, 2025
5a07fe9
Fix Dataprep ingest PPT and async issues (#1504)
letonghan Apr 2, 2025
b0a05d2
Integrate UI-TARS vLLM in lvm component (#1458)
Spycsh Apr 2, 2025
ab85d33
Fix model cache path and use Random to avoid ns conflict (#1500)
yongfengdu Apr 2, 2025
36675fb
MultimodalQnA audio features completion (#1433)
mhbuehler Apr 2, 2025
e661ae8
[Bug: 1379] Added Multimodal support for Milvus for retriever compone…
srajabos Apr 2, 2025
32609bf
VDMS langchain package update (#1317)
cwlacewe Apr 2, 2025
993e13e
fix: `test_arangodb`
aMahanna Apr 2, 2025
7132b94
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 2, 2025
40b6426
add python-arango dep
aMahanna Apr 3, 2025
0d4e648
Enable Telemetry Tracing in Agent Comp and also add class name along …
louie-tsai Apr 2, 2025
db94030
Fix CI workflow (#1518)
chensuyue Apr 3, 2025
cfd1f71
minor fix gpt-sovits service names (#1521)
Spycsh Apr 3, 2025
f286598
remove concurrency in image build and push workflow (#1510)
chensuyue Apr 3, 2025
9a66ce3
Add in entrypoint new download links for wav2lip and wav2lip_gan mode…
ctao456 Apr 3, 2025
caec4a6
Add xtune to finetuning (#1432)
jilongW Apr 3, 2025
66347b5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 3, 2025
031ada8
rem: decorator
aMahanna Apr 4, 2025
6f5af84
Unset TEI_EMBEDDING_ENDPOINT when running multimodal redis retriever …
dmsuehir Apr 4, 2025
d837d2d
Data Ingestion and Retrieval with custom index_name (#1439)
MSCetin37 Apr 4, 2025
c574c85
Update Gaudi Docker to v1.19.0 and PyTorch Installer 2.5.1 (#1513)
ashahba Apr 4, 2025
f83abf5
Limit vllm and vllm-fork tags (#1529)
ZePan110 Apr 7, 2025
ffaa0b2
new: `health_check`
aMahanna Apr 7, 2025
7552e3d
Merge branch 'main' into feature/opeastore
aMahanna Apr 7, 2025
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
248 changes: 248 additions & 0 deletions comps/cores/common/storage.py
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 = {}):
"""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 {

Check warning on line 40 in comps/cores/common/storage.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/common/storage.py#L40

Added line #L40 was not covered by tests
"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

Check warning on line 53 in comps/cores/common/storage.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/common/storage.py#L53

Added line #L53 was not covered by tests

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.")

Check warning on line 62 in comps/cores/common/storage.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/common/storage.py#L62

Added line #L62 was not covered by tests

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})"

Check warning on line 70 in comps/cores/common/storage.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/common/storage.py#L70

Added line #L70 was not covered by tests

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.")

Check warning on line 79 in comps/cores/common/storage.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/common/storage.py#L79

Added line #L79 was not covered by tests

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.")

Check warning on line 88 in comps/cores/common/storage.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/common/storage.py#L88

Added line #L88 was not covered by tests

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.")

Check warning on line 97 in comps/cores/common/storage.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/common/storage.py#L97

Added line #L97 was not covered by tests

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.")

Check warning on line 106 in comps/cores/common/storage.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/common/storage.py#L106

Added line #L106 was not covered by tests

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.")

Check warning on line 115 in comps/cores/common/storage.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/common/storage.py#L115

Added line #L115 was not covered by tests

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.")

Check warning on line 124 in comps/cores/common/storage.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/common/storage.py#L124

Added line #L124 was not covered by tests

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.")

Check warning on line 133 in comps/cores/common/storage.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/common/storage.py#L133

Added line #L133 was not covered by tests

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.")

Check warning on line 142 in comps/cores/common/storage.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/common/storage.py#L142

Added line #L142 was not covered by tests

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.")

Check warning on line 153 in comps/cores/common/storage.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/common/storage.py#L153

Added line #L153 was not covered by tests

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.")

Check warning on line 164 in comps/cores/common/storage.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/common/storage.py#L164

Added line #L164 was not covered by tests

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.")

Check warning on line 175 in comps/cores/common/storage.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/common/storage.py#L175

Added line #L175 was not covered by tests

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.")

Check warning on line 186 in comps/cores/common/storage.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/common/storage.py#L186

Added line #L186 was not covered by tests

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.")

Check warning on line 194 in comps/cores/common/storage.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/common/storage.py#L194

Added line #L194 was not covered by tests

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.")

Check warning on line 202 in comps/cores/common/storage.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/common/storage.py#L202

Added line #L202 was not covered by tests

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.")

Check warning on line 210 in comps/cores/common/storage.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/common/storage.py#L210

Added line #L210 was not covered by tests

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.")

Check warning on line 218 in comps/cores/common/storage.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/common/storage.py#L218

Added line #L218 was not covered by tests

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.")

Check warning on line 233 in comps/cores/common/storage.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/common/storage.py#L233

Added line #L233 was not covered by tests

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.")

Check warning on line 248 in comps/cores/common/storage.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/common/storage.py#L248

Added line #L248 was not covered by tests
18 changes: 18 additions & 0 deletions comps/cores/storages/__init__.py
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}")

Check warning on line 18 in comps/cores/storages/__init__.py

View check run for this annotation

Codecov / codecov/patch

comps/cores/storages/__init__.py#L18

Added line #L18 was not covered by tests
Loading
Loading