1- from typing import TypedDict
21from pydantic import BaseModel , SecretStr
3- from ..api import DBConfig , DBCaseConfig , MetricType , IndexType
2+
3+ from ..api import DBCaseConfig , DBConfig , IndexType , MetricType
4+
45
56class ClickhouseConfig (DBConfig ):
6- user_name : str = "clickhouse"
7+ user_name : str = "clickhouse"
78 password : SecretStr
89 host : str = "localhost"
910 port : int = 8123
@@ -16,7 +17,7 @@ def to_dict(self) -> dict:
1617 "port" : self .port ,
1718 "dbname" : self .db_name ,
1819 "user" : self .user_name ,
19- "password" : pwd_str
20+ "password" : pwd_str ,
2021 }
2122
2223
@@ -32,8 +33,11 @@ def parse_metric(self) -> str:
3233 def parse_metric_str (self ) -> str :
3334 if self .metric_type == MetricType .L2 :
3435 return "L2Distance"
35- elif self .metric_type == MetricType .COSINE :
36+ if self .metric_type == MetricType .COSINE :
3637 return "cosineDistance"
38+ msg = f"Not Support for { self .metric_type } "
39+ raise RuntimeError (msg )
40+ return None
3741
3842
3943class ClickhouseHNSWConfig (ClickhouseIndexConfig , DBCaseConfig ):
@@ -51,6 +55,6 @@ def index_param(self) -> dict:
5155
5256 def search_param (self ) -> dict :
5357 return {
54- "metric_type " : self .parse_metric_str (),
58+ "met˝ric_type " : self .parse_metric_str (),
5559 "params" : {"ef" : self .ef },
56- }
60+ }
0 commit comments