From 2ba05b041f45dfba96867f0bcedc908c43b38bc2 Mon Sep 17 00:00:00 2001 From: Waffle <52460705+ox01024@users.noreply.github.com> Date: Fri, 19 Jul 2024 10:57:45 +0800 Subject: [PATCH] refactor(myscale):Set the default value of the myscale vector db in DifyConfig. (#6441) --- api/configs/middleware/vdb/myscale_config.py | 23 +++++++++---------- .../datasource/vdb/myscale/myscale_vector.py | 13 +++++------ 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/api/configs/middleware/vdb/myscale_config.py b/api/configs/middleware/vdb/myscale_config.py index e513cad0e8..895cd6f176 100644 --- a/api/configs/middleware/vdb/myscale_config.py +++ b/api/configs/middleware/vdb/myscale_config.py @@ -1,4 +1,3 @@ -from typing import Optional from pydantic import BaseModel, Field, PositiveInt @@ -8,32 +7,32 @@ class MyScaleConfig(BaseModel): MyScale configs """ - MYSCALE_HOST: Optional[str] = Field( + MYSCALE_HOST: str = Field( description='MyScale host', - default=None, + default='localhost', ) - MYSCALE_PORT: Optional[PositiveInt] = Field( + MYSCALE_PORT: PositiveInt = Field( description='MyScale port', default=8123, ) - MYSCALE_USER: Optional[str] = Field( + MYSCALE_USER: str = Field( description='MyScale user', - default=None, + default='default', ) - MYSCALE_PASSWORD: Optional[str] = Field( + MYSCALE_PASSWORD: str = Field( description='MyScale password', - default=None, + default='', ) - MYSCALE_DATABASE: Optional[str] = Field( + MYSCALE_DATABASE: str = Field( description='MyScale database name', - default=None, + default='default', ) - MYSCALE_FTS_PARAMS: Optional[str] = Field( + MYSCALE_FTS_PARAMS: str = Field( description='MyScale fts index parameters', - default=None, + default='', ) diff --git a/api/core/rag/datasource/vdb/myscale/myscale_vector.py b/api/core/rag/datasource/vdb/myscale/myscale_vector.py index 33ee8259c5..241b5a8414 100644 --- a/api/core/rag/datasource/vdb/myscale/myscale_vector.py +++ b/api/core/rag/datasource/vdb/myscale/myscale_vector.py @@ -159,12 +159,11 @@ class MyScaleVectorFactory(AbstractVectorFactory): return MyScaleVector( collection_name=collection_name, config=MyScaleConfig( - # TODO: I think setting those values as the default config would be a better option. - host=dify_config.MYSCALE_HOST or "localhost", - port=dify_config.MYSCALE_PORT or 8123, - user=dify_config.MYSCALE_USER or "default", - password=dify_config.MYSCALE_PASSWORD or "", - database=dify_config.MYSCALE_DATABASE or "default", - fts_params=dify_config.MYSCALE_FTS_PARAMS or "", + host=dify_config.MYSCALE_HOST, + port=dify_config.MYSCALE_PORT, + user=dify_config.MYSCALE_USER, + password=dify_config.MYSCALE_PASSWORD, + database=dify_config.MYSCALE_DATABASE, + fts_params=dify_config.MYSCALE_FTS_PARAMS, ), )