Skip to content

Commit 1b7d412

Browse files
Add llama-index-retriever integration for HPE AlletraMP X10000 (#19798)
1 parent 1692239 commit 1b7d412

File tree

10 files changed

+2157
-0
lines changed

10 files changed

+2157
-0
lines changed
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
llama_index/_static
2+
.DS_Store
3+
# Byte-compiled / optimized / DLL files
4+
__pycache__/
5+
*.py[cod]
6+
*$py.class
7+
8+
# C extensions
9+
*.so
10+
11+
# Distribution / packaging
12+
.Python
13+
bin/
14+
build/
15+
develop-eggs/
16+
dist/
17+
downloads/
18+
eggs/
19+
.eggs/
20+
etc/
21+
include/
22+
lib/
23+
lib64/
24+
parts/
25+
sdist/
26+
share/
27+
var/
28+
wheels/
29+
pip-wheel-metadata/
30+
share/python-wheels/
31+
*.egg-info/
32+
.installed.cfg
33+
*.egg
34+
MANIFEST
35+
36+
# PyInstaller
37+
# Usually these files are written by a python script from a template
38+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
39+
*.manifest
40+
*.spec
41+
42+
# Installer logs
43+
pip-log.txt
44+
pip-delete-this-directory.txt
45+
46+
# Unit test / coverage reports
47+
htmlcov/
48+
.tox/
49+
.nox/
50+
.coverage
51+
.coverage.*
52+
.cache
53+
nosetests.xml
54+
coverage.xml
55+
*.cover
56+
*.py,cover
57+
.hypothesis/
58+
.pytest_cache/
59+
.ruff_cache
60+
61+
# Translations
62+
*.mo
63+
*.pot
64+
65+
# Django stuff:
66+
*.log
67+
local_settings.py
68+
db.sqlite3
69+
db.sqlite3-journal
70+
71+
# Flask stuff:
72+
instance/
73+
.webassets-cache
74+
75+
# Scrapy stuff:
76+
.scrapy
77+
78+
# Sphinx documentation
79+
docs/_build/
80+
81+
# PyBuilder
82+
target/
83+
84+
# Jupyter Notebook
85+
.ipynb_checkpoints
86+
notebooks/
87+
88+
# IPython
89+
profile_default/
90+
ipython_config.py
91+
92+
# pyenv
93+
.python-version
94+
95+
# pipenv
96+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
97+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
98+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
99+
# install all needed dependencies.
100+
#Pipfile.lock
101+
102+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
103+
__pypackages__/
104+
105+
# Celery stuff
106+
celerybeat-schedule
107+
celerybeat.pid
108+
109+
# SageMath parsed files
110+
*.sage.py
111+
112+
# Environments
113+
.env
114+
.venv
115+
env/
116+
venv/
117+
ENV/
118+
env.bak/
119+
venv.bak/
120+
pyvenv.cfg
121+
122+
# Spyder project settings
123+
.spyderproject
124+
.spyproject
125+
126+
# Rope project settings
127+
.ropeproject
128+
129+
# mkdocs documentation
130+
/site
131+
132+
# mypy
133+
.mypy_cache/
134+
.dmypy.json
135+
dmypy.json
136+
137+
# Pyre type checker
138+
.pyre/
139+
140+
# Jetbrains
141+
.idea
142+
modules/
143+
*.swp
144+
145+
# VsCode
146+
.vscode
147+
148+
# pipenv
149+
Pipfile
150+
Pipfile.lock
151+
152+
# pyright
153+
pyrightconfig.json
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
(C) Copyright [2025] Hewlett Packard Enterprise Development LP
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a
4+
copy of this software and associated documentation files (the "Software"),
5+
to deal in the Software without restriction, including without limitation
6+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
7+
and/or sell copies of the Software, and to permit persons to whom the
8+
Software is furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included
11+
in all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
17+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
18+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
19+
OTHER DEALINGS IN THE SOFTWARE.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright Hewlett Packard Enterprise Development LP.
2+
3+
GIT_ROOT ?= $(shell git rev-parse --show-toplevel)
4+
5+
help: ## Show all Makefile targets.
6+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[33m%-30s\033[0m %s\n", $$1, $$2}'
7+
8+
format: ## Run code autoformatters (black).
9+
pre-commit install
10+
git ls-files | xargs pre-commit run black --files
11+
12+
lint: ## Run linters: pre-commit (black, ruff, codespell) and mypy
13+
pre-commit install && git ls-files | xargs pre-commit run --show-diff-on-failure --files
14+
15+
test: ## Run tests via pytest.
16+
pytest tests
17+
18+
watch-docs: ## Build and watch documentation.
19+
sphinx-autobuild docs/ docs/_build/html --open-browser --watch $(GIT_ROOT)/llama_index/
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# LlamaIndex Retrievers Integration: AlletraX10000Retriever
2+
3+
This llama-index retriever will provide interfaces for the user applications to do semantic similarity search on the embeddings for Data Intelligence solution of HPE AlletraMP X10000
4+
5+
## How to use SDK
6+
7+
### Install llama-index-retrievers-alletra-x10000-retriever
8+
9+
```sh
10+
pip install llama-index-retrievers-alletra-x10000-retriever
11+
```
12+
13+
### Driver code
14+
15+
```python
16+
from llama_index.core.chat_engine import CondensePlusContextChatEngine
17+
from llama_index.core.memory import ChatMemoryBuffer
18+
from llama_index.retrievers.alletra_x10000_retriever import (
19+
AlletraX10000Retriever,
20+
)
21+
22+
23+
# Configure the llm settings before using the retriever
24+
25+
retriever = AlletraX10000Retriever(
26+
uri="https://example.com",
27+
s3_access_key="",
28+
s3_secret_key="",
29+
collection_name="testcollection",
30+
top_k=50,
31+
search_config={"radius": 0.75},
32+
)
33+
34+
memory = ChatMemoryBuffer.from_defaults(token_limit=1000)
35+
chatbot = CondensePlusContextChatEngine.from_defaults(
36+
retriever=retriever, memory=memory
37+
)
38+
39+
res = chatbot.chat(
40+
"Who was the eldest daughter of the steward of the old Lord de Versely?"
41+
)
42+
print(res)
43+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright Hewlett Packard Enterprise Development LP.
2+
3+
from llama_index.retrievers.alletra_x10000_retriever.base import AlletraX10000Retriever
4+
5+
__all__ = ["AlletraX10000Retriever"]
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Copyright Hewlett Packard Enterprise Development LP.
2+
3+
from pydi_client import DIClient
4+
from typing import Any, Dict, Union
5+
6+
from llama_index.core.retrievers import BaseRetriever
7+
from llama_index.core.schema import QueryBundle, NodeWithScore, TextNode
8+
9+
10+
class AlletraX10000Retriever(BaseRetriever):
11+
def __init__(
12+
self,
13+
uri: str,
14+
s3_access_key: str,
15+
s3_secret_key: str,
16+
collection_name: str,
17+
search_config: Union[Any, Dict[str, Any]] = None,
18+
top_k: int = 5,
19+
):
20+
self.uri = uri
21+
self.top_k = top_k
22+
self.collection_name = collection_name
23+
self.access_key = s3_access_key
24+
self.secret_key = s3_secret_key
25+
self.search_config = search_config
26+
27+
def _retrieve(self, query_bundle: QueryBundle) -> list[NodeWithScore]:
28+
query = query_bundle.query_str
29+
30+
client = DIClient(uri=self.uri)
31+
data = client.similarity_search(
32+
collection_name=self.collection_name,
33+
query=query,
34+
top_k=self.top_k,
35+
access_key=self.access_key,
36+
secret_key=self.secret_key,
37+
search_parameters=self.search_config,
38+
)
39+
40+
nodes = []
41+
for item in data:
42+
nodes.append(
43+
NodeWithScore(
44+
node=TextNode(
45+
text=item["dataChunk"], metadata=item["chunkMetadata"]
46+
),
47+
score=item["score"],
48+
)
49+
)
50+
return nodes
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[build-system]
2+
build-backend = "hatchling.build"
3+
requires = ["hatchling"]
4+
5+
[dependency-groups]
6+
dev = [
7+
"pytest==7.2.1",
8+
"pytest-mock==3.11.1",
9+
"pre-commit==3.2.0",
10+
"pytest-cov>=6.1.1",
11+
]
12+
13+
[project]
14+
name = "llama-index-retrievers-alletra-x10000-retriever"
15+
version = "0.1.0"
16+
description = "llama-index retriever for AlletraMP X10000"
17+
readme = "README.md"
18+
requires-python = ">=3.11.2,<4.0"
19+
authors = [{name = "HPE"}]
20+
dependencies = [
21+
"pydi-client>=1.0.0",
22+
"llama-index-core>=0.12.35",
23+
]
24+
25+
[tool.codespell]
26+
check-filenames = true
27+
check-hidden = true
28+
skip = "*.csv,*.html,*.json,*.jsonl,*.pdf,*.txt,*.ipynb"
29+
30+
[tool.hatch.build.targets.sdist]
31+
include = ["llama_index/"]
32+
33+
[tool.hatch.build.targets.wheel]
34+
include = ["llama_index/"]
35+
36+
[tool.llamahub]
37+
contains_example = false
38+
import_path = "llama_index.retrievers.alletra_x10000_retriever"
39+
40+
[tool.llamahub.class_authors]
41+
AlletraX10000Retriever = "HPE"
42+
43+
[tool.mypy]
44+
disallow_untyped_defs = true
45+
exclude = ["_static", "build", "examples", "notebooks", "venv"]
46+
ignore_missing_imports = true
47+
python_version = "3.11.2"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Copyright Hewlett Packard Enterprise Development LP.

0 commit comments

Comments
 (0)