missing env TENCENT_VECTOR_DB_DATABASE
jianglin1008 opened this issue · comments
Self Checks
- This is only for bug report, if you would like to ask a question, please head to Discussions.
- I have searched for existing issues search for existing issues, including closed ones.
- I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
- 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
- Please do not modify this template :) and fill in all the required fields.
Dify version
0.6.12-fix1
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
When using Tencent VectorDB, I kept encountering the following error. After investigation, I discovered that TENCENT_VECTOR_DB_DATABASE
was missing in the model configuration definition, which led to its value being unobtainable.
File "/app/api/core/rag/datasource/vdb/tencent/tencent_vector.py", line 216, in init_vector
--
Mon, Jul 1 2024 8:23:49 pm | return TencentVector(
Mon, Jul 1 2024 8:23:49 pm | File "/app/api/core/rag/datasource/vdb/tencent/tencent_vector.py", line 50, in __init__
Mon, Jul 1 2024 8:23:49 pm | self._db = self._init_database()
Mon, Jul 1 2024 8:23:49 pm | File "/app/api/core/rag/datasource/vdb/tencent/tencent_vector.py", line 61, in _init_database
Mon, Jul 1 2024 8:23:49 pm | return self._client.create_database(database_name=self._client_config.database)
Mon, Jul 1 2024 8:23:49 pm | File "/app/api/.venv/lib/python3.10/site-packages/tcvectordb/client/stub.py", line 40, in create_database
Mon, Jul 1 2024 8:23:49 pm | db.create_database(timeout=timeout)
Mon, Jul 1 2024 8:23:49 pm | File "/app/api/.venv/lib/python3.10/site-packages/tcvectordb/model/database.py", line 48, in create_database
Mon, Jul 1 2024 8:23:49 pm | raise exceptions.ParamError(
Mon, Jul 1 2024 8:23:49 pm | tcvectordb.exceptions.ParamError: <ParamError: (code=-1, message=database name param not found)>
✔️ Expected Behavior
Successfully connected to Tencent VectorDB.
❌ Actual Behavior
tcvectordb.exceptions.ParamError: <ParamError: (code=-1, message=database name param not found)>
api/configs/middleware/vdb/tencent_vector_config.py
class TencentVectorDBConfig(BaseModel):
"""
Tencent Vector configs
"""
TENCENT_VECTOR_DB_URL: Optional[str] = Field(
description='Tencent Vector URL',
default=None,
)
TENCENT_VECTOR_DB_API_KEY: Optional[str] = Field(
description='Tencent Vector API key',
default=None,
)
TENCENT_VECTOR_DB_TIMEOUT: PositiveInt = Field(
description='Tencent Vector timeout in seconds',
default=30,
)
TENCENT_VECTOR_DB_USERNAME: Optional[str] = Field(
description='Tencent Vector password',
default=None,
)
TENCENT_VECTOR_DB_PASSWORD: Optional[str] = Field(
description='Tencent Vector password',
default=None,
)
## here
TENCENT_VECTOR_DB_SHARD: PositiveInt = Field(
description='Tencent Vector sharding number',
default=1,
)
TENCENT_VECTOR_DB_REPLICAS: PositiveInt = Field(
description='Tencent Vector replicas',
default=2,
)
@jianglin1008 Hello there! I'm here to assist you with any bugs, questions, or contributions you might have. Let's work together to resolve your issue.
To resolve the issue with the missing TENCENT_VECTOR_DB_DATABASE
field, you need to add this field to the TencentVectorDBConfig
class in your tencent_vector_config.py
file. Here is the updated class definition:
from typing import Optional
from pydantic import BaseModel, Field, PositiveInt
class TencentVectorDBConfig(BaseModel):
"""
Tencent Vector configs
"""
TENCENT_VECTOR_DB_URL: Optional[str] = Field(
description='Tencent Vector URL',
default=None,
)
TENCENT_VECTOR_DB_API_KEY: Optional[str] = Field(
description='Tencent Vector API key',
default=None,
)
TENCENT_VECTOR_DB_TIMEOUT: PositiveInt = Field(
description='Tencent Vector timeout in seconds',
default=30,
)
TENCENT_VECTOR_DB_USERNAME: Optional[str] = Field(
description='Tencent Vector username',
default=None,
)
TENCENT_VECTOR_DB_PASSWORD: Optional[str] = Field(
description='Tencent Vector password',
default=None,
)
TENCENT_VECTOR_DB_SHARD: PositiveInt = Field(
description='Tencent Vector sharding number',
default=1,
)
TENCENT_VECTOR_DB_REPLICAS: PositiveInt = Field(
description='Tencent Vector replicas',
default=2,
)
TENCENT_VECTOR_DB_DATABASE: Optional[str] = Field(
description='Tencent Vector database name',
default=None,
)
This addition includes the TENCENT_VECTOR_DB_DATABASE
field with an appropriate description and default value [1].
hi, doing a new pull of the code or running cp .env.example .env
? should resolve the issue.
@guchenhe extra = ignore
# api/configs/app_config.py
model_config = SettingsConfigDict(
# read from dotenv format config file
env_file='.env',
env_file_encoding='utf-8',
# ignore extra attributes
extra='ignore',
)