Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
feat: support dynamic project_name config in VectorDB / volcengine (#161)
baojun-zhanga469c416f9f2
diff --git a/docs/en/guides/01-configuration.md b/docs/en/guides/01-configuration.mdindex 6442210e5..a390b4fd0 100644--- a/docs/en/guides/01-configuration.md+++ b/docs/en/guides/01-configuration.md@@ -30,10 +30,6 @@ Create `~/.openviking/ov.conf` in your project directory:"agfs": {"backend": "local","path": "./data"- },- "vectordb": {- "backend": "local",- "path": "./data"}}}@@ -391,7 +387,8 @@ For startup and deployment details see [Deployment](./03-deployment.md), for aut"vectordb": {"backend": "local|remote","path": "string",- "url": "string"+ "url": "string",+ "project": "string"}},"server": {diff --git a/docs/zh/guides/01-configuration.md b/docs/zh/guides/01-configuration.mdindex 7ee667626..8bc4bfba9 100644--- a/docs/zh/guides/01-configuration.md+++ b/docs/zh/guides/01-configuration.md@@ -394,7 +394,8 @@ HTTP 客户端(`SyncHTTPClient` / `AsyncHTTPClient`)和 CLI 工具连接远"vectordb": {"backend": "local|remote","path": "string",- "url": "string"+ "url": "string",+ "project": "string"}},"server": {diff --git a/examples/ov.conf.example b/examples/ov.conf.exampleindex fc97ecc26..bf5b1a072 100644--- a/examples/ov.conf.example+++ b/examples/ov.conf.example@@ -10,6 +10,7 @@"name": "context","backend": "local","path": "./data",+ "project": "default","volcengine": {"region": "cn-beijing","ak": null,@@ -23,10 +24,15 @@"backend": "local","timeout": 10,"retry_times": 3,- "s3_bucket": null,- "s3_region": null,- "s3_access_key": null,- "s3_secret_key": null+ "s3": {+ "bucket": null,+ "region": null,+ "access_key": null,+ "secret_key": null,+ "endpoint": null,+ "prefix": "",+ "use_ssl": true+ }}},"embedding": {diff --git a/openviking/core/directories.py b/openviking/core/directories.pyindex 866a944d4..fa9f95cfb 100644--- a/openviking/core/directories.py+++ b/openviking/core/directories.py@@ -220,10 +220,12 @@ class DirectoryInitializer:logger.debug(f"[VikingFS] Directory {uri} already exists")# 2. Ensure record exists in vector storage- from openviking_cli.utils.config.vectordb_config import COLLECTION_NAME+ from openviking_cli.utils.config import get_openviking_config++ config = get_openviking_config()existing = await self.vikingdb.filter(- collection=COLLECTION_NAME,+ collection=config.storage.vectordb.name,filter={"op": "must", "field": "uri", "conds": [uri]},limit=1,)diff --git a/openviking/storage/vectordb/collection/volcengine_collection.py b/openviking/storage/vectordb/collection/volcengine_collection.pyindex 19a8c5f1f..dbdd55dca 100644--- a/openviking/storage/vectordb/collection/volcengine_collection.py+++ b/openviking/storage/vectordb/collection/volcengine_collection.py@@ -27,6 +27,9 @@ def get_or_create_volcengine_collection(config: Dict[str, Any], meta_data: Dict[Args:config: Configuration dictionary containing AK, SK, Region.meta_data: Collection metadata.++ Returns:+ VolcengineCollection instance"""# Extract configurationak = config.get("AK")@@ -63,6 +66,9 @@ def get_or_create_volcengine_collection(config: Dict[str, Any], meta_data: Dict[logger.info(f"Collection {collection_name} created successfully")return VolcengineCollection(ak, sk, region, host, meta_data)+ # Return VolcengineCollection instance+ return VolcengineCollection(ak=ak, sk=sk, region=region, host=host, meta_data=meta_data)+class VolcengineCollection(ICollection):def __init__(@@ -176,9 +182,7 @@ class VolcengineCollection(ICollection):):passelse:- raise Exception(- f"Failed to create collection: {response.status_code} {response.text}"- )+ raise Exception(f"Failed to create index: {response.status_code} {response.text}")def has_index(self, index_name: str):indexes = self.list_indexes()diff --git a/openviking/storage/vectordb/project/volcengine_project.py b/openviking/storage/vectordb/project/volcengine_project.pyindex d30fac08f..25ccf8b22 100644--- a/openviking/storage/vectordb/project/volcengine_project.py+++ b/openviking/storage/vectordb/project/volcengine_project.py@@ -148,6 +148,7 @@ class VolcengineProject:updated_meta = {**meta_data,"CollectionName": collection_name,+ "ProjectName": self.project_name,}logger.info(f"Creating Volcengine collection: {collection_name}")diff --git a/openviking/storage/viking_vector_index_backend.py b/openviking/storage/viking_vector_index_backend.pyindex 4f1b7efd4..906279d75 100644--- a/openviking/storage/viking_vector_index_backend.py+++ b/openviking/storage/viking_vector_index_backend.py@@ -35,8 +35,8 @@ class VikingVectorIndexBackend(VikingDBInterface):"""# Default project and index names- DEFAULT_PROJECT_NAME = "vectordb"DEFAULT_INDEX_NAME = "default"+ DEFAULT_LOCAL_PROJECT_NAME = "vectordb"def __init__(self,@@ -104,7 +104,7 @@ class VikingVectorIndexBackend(VikingDBInterface):)self.project = get_or_create_volcengine_project(- project_name=self.DEFAULT_PROJECT_NAME, config=volc_config+ project_name=config.project_name, config=volc_config)logger.info(f"VectorDB backend initialized in Volcengine mode: region={volc_config['Region']}"@@ -124,7 +124,7 @@ class VikingVectorIndexBackend(VikingDBInterface):)self.project = get_or_create_vikingdb_project(- project_name=self.DEFAULT_PROJECT_NAME, config=viking_config+ project_name=config.project_name, config=viking_config)logger.info(f"VikingDB backend initialized in private mode: {config.vikingdb.host}")elif config.backend == "http":@@ -137,7 +137,7 @@ class VikingVectorIndexBackend(VikingDBInterface):from openviking.storage.vectordb.project.http_project import get_or_create_http_projectself.project = get_or_create_http_project(- host=self.host, port=self.port, project_name=self.DEFAULT_PROJECT_NAME+ host=self.host, port=self.port, project_name=config.project_name)logger.info(f"VikingDB backend initialized in remote mode: {config.url}")elif config.backend == "local":@@ -147,7 +147,9 @@ class VikingVectorIndexBackend(VikingDBInterface):get_or_create_local_project,)- project_path = Path(config.path) / self.DEFAULT_PROJECT_NAME if config.path else ""+ project_path = (+ Path(config.path) / self.DEFAULT_LOCAL_PROJECT_NAME if config.path else ""+ )self.project = get_or_create_local_project(path=str(project_path))logger.info(f"VikingDB backend initialized with local storage: {project_path}")else:diff --git a/openviking_cli/utils/config/vectordb_config.py b/openviking_cli/utils/config/vectordb_config.pyindex 50ee4ee3a..b4f0c0242 100644--- a/openviking_cli/utils/config/vectordb_config.py+++ b/openviking_cli/utils/config/vectordb_config.py@@ -4,6 +4,8 @@ from typing import Dict, Optionalfrom pydantic import BaseModel, Field, model_validator+from openviking.storage.vectordb.utils.constants import DEFAULT_PROJECT_NAME+COLLECTION_NAME = "context"@@ -49,6 +51,10 @@ class VectorDBBackendConfig(BaseModel):description="Remote service URL for 'http' type (e.g., 'http://localhost:5000')",)+ project_name: Optional[str] = Field(+ default=DEFAULT_PROJECT_NAME, description="project name", alias="project"+ )+distance_metric: str = Field(default="cosine",description="Distance metric for vector similarity search (e.g., 'cosine', 'l2', 'ip')",