Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

feat: support dynamic project_name config in VectorDB / volcengine (#253)

baojun-zhangcab8ea540b97
diff --git a/docs/en/guides/01-configuration.md b/docs/en/guides/01-configuration.md
index 7c3c0fb2a..f9d7c6b39 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"
}
}
}
@@ -429,7 +425,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.md
index ec70d4bd4..2bcd2272a 100644
--- a/docs/zh/guides/01-configuration.md
+++ b/docs/zh/guides/01-configuration.md
@@ -432,7 +432,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.example
index 34cbc6a4a..5f78f7346 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.py
index 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.py
index 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 configuration
ak = 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):
):
pass
else:
- 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.py
index 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/vectordb/utils/constants.py b/openviking/storage/vectordb/utils/constants.py
index 519323ca3..c5fd9fa89 100644
--- a/openviking/storage/vectordb/utils/constants.py
+++ b/openviking/storage/vectordb/utils/constants.py
@@ -50,6 +50,5 @@ ENV_INDEX_MAINTENANCE_SECONDS = "VECTORDB_INDEX_MAINTENANCE_SECONDS"
# ==================== Other constants ====================
-DEFAULT_PROJECT_NAME = "default" # Default project name
DEFAULT_LIMIT = 10 # Default search return result count
STORAGE_DIR_NAME = "store" # Storage directory name
diff --git a/openviking/storage/viking_vector_index_backend.py b/openviking/storage/viking_vector_index_backend.py
index 57eecb833..bcfbdf1c6 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_project
self.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.py
index 6984322c4..090e1c881 100644
--- a/openviking_cli/utils/config/vectordb_config.py
+++ b/openviking_cli/utils/config/vectordb_config.py
@@ -5,6 +5,7 @@ from typing import Dict, Optional
from pydantic import BaseModel, Field, model_validator
COLLECTION_NAME = "context"
+DEFAULT_PROJECT_NAME = "default"
class VolcengineConfig(BaseModel):
@@ -53,6 +54,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')",