feat(vector-io): add OpenGauss vector database provider

Implement OpenGauss vector database integration for Llama Stack with the following features:
- Add OpenGaussVectorIOAdapter for vector storage and retrieval
- Support native vector similarity search operations
- Implement connection and query management with psycopg2
- Provide configuration template for easy setup
- Add comprehensive unit tests

The implementation allows Llama Stack users to leverage OpenGauss as an
enterprise-grade vector database for RAG applications. Users can configure
their environment through a simple YAML configuration and environment variables.
This commit is contained in:
qifengleqifengle 2025-07-14 16:50:29 +08:00
parent d880c2df0e
commit 5e9c394500
10 changed files with 854 additions and 0 deletions

View file

@ -0,0 +1,9 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
# from .mymilvus_demo import get_distribution_template
# __all__ = ["get_distribution_template"]

View file

@ -0,0 +1,27 @@
version: 2
distribution_spec:
description: "Custom configuration using Opengauss for vector storage and metadata"
providers:
inference:
- remote::together-openai-compat
vector_io:
- remote::opengauss
agents:
- inline::meta-reference
tool_runtime:
- inline::rag-runtime
files:
- inline::localfs
telemetry:
- inline::meta-reference
safety:
- inline::llama-guard
image_type: venv
additional_pip_packages:
- psycopg2-binary>=2.9.3
- pgvector>=0.2.0
- asyncpg>=0.27.0
# rm -rf ~/.llama/distributions/opengauss-demo
# uv run --with llama-stack llama stack build --template opengauss-demo --image-type venv
# uv run --env-file .env --with llama-stack llama stack run /home/gt/.llama/distributions/opengauss-demo/opengauss-demo-run.yaml

View file

@ -0,0 +1,96 @@
version: 2
image_name: opengauss-demo
apis:
- agents
- inference
- vector_io
- tool_runtime
- files
- models
- telemetry
- safety
providers:
inference:
- provider_id: together
provider_type: remote::together
config:
api_key: ${env.TOGETHER_API_KEY}
url: ${env.TOGETHER_API_BASE_URL}
- provider_id: sentence-transformers
provider_type: inline::sentence-transformers
config: {}
vector_io:
- provider_id: opengauss
provider_type: remote::opengauss
config:
host: ${env.OPENGAUSS_HOST}
port: ${env.OPENGAUSS_PORT:=5432}
db: ${env.OPENGAUSS_DB}
user: ${env.OPENGAUSS_USER}
password: ${env.OPENGAUSS_PASSWORD}
agents:
- provider_id: meta-reference
provider_type: inline::meta-reference
config:
persistence_store:
type: sqlite
db_path: ${env.SQLITE_STORE_DIR:=~/.llama/distributions/opengauss-demo}/agent_store.db
responses_store:
type: sqlite
db_path: ${env.SQLITE_STORE_DIR:=~/.llama/distributions/opengauss-demo}/agent_responses.db
tool_store:
type: sqlite
db_path: ${env.SQLITE_STORE_DIR:=~/.llama/distributions/opengauss-demo}/agent_tools.db
tool_runtime:
- provider_id: rag-runtime
provider_type: inline::rag-runtime
config: {}
files:
- provider_id: localfs
provider_type: inline::localfs
config:
storage_dir: ${env.LOCALFS_BASE_PATH:=~/.llama/distributions/opengauss-demo/files}
metadata_store:
type: sqlite
db_path: ${env.SQLITE_STORE_DIR:=~/.llama/distributions/opengauss-demo}/files_metadata.db
telemetry:
- provider_id: meta-reference
provider_type: inline::meta-reference
config: {}
safety:
- provider_id: llama-guard
provider_type: inline::llama-guard
config: {}
models:
- model_id: meta-llama/Llama-3.3-70B-Instruct-Turbo
model_type: llm
provider_id: together
provider_model_id: meta-llama/Llama-3.3-70B-Instruct-Turbo
metadata: {}
- model_id: all-MiniLM-L6-v2
model_type: embedding
provider_id: sentence-transformers
provider_model_id: all-MiniLM-L6-v2
metadata:
embedding_dimension: 384
metadata_store:
type: sqlite
db_path: ${env.SQLITE_STORE_DIR:=~/.llama/distributions/opengauss-demo}/registry.db
inference_store:
type: sqlite
db_path: ${env.SQLITE_STORE_DIR:=~/.llama/distributions/opengauss-demo}/inference_store.db
tool_groups:
- toolgroup_id: builtin::rag
provider_id: rag-runtime