1414 VectorStoreConfig ,
1515)
1616from dbgpt .storage .vector_store .filters import FilterOperator , MetadataFilters
17+ from dbgpt .util import string_utils
1718from dbgpt .util .i18n_utils import _
1819
1920logger = logging .getLogger (__name__ )
@@ -110,6 +111,11 @@ def __init__(
110111 self .embeddings = embedding_fn
111112 if not self .embeddings :
112113 raise ValueError ("Embeddings is None" )
114+ self ._collection_name = name
115+ if string_utils .contains_chinese (name ):
116+ bytes_str = self ._collection_name .encode ("utf-8" )
117+ hex_str = bytes_str .hex ()
118+ self ._collection_name = hex_str
113119 chroma_settings = Settings (
114120 # chroma_db_impl="duckdb+parquet", => deprecated configuration of Chroma
115121 persist_directory = self .persist_dir ,
@@ -121,9 +127,9 @@ def __init__(
121127 path = self .persist_dir , settings = chroma_settings
122128 )
123129 collection_metadata = collection_metadata or {"hnsw:space" : "cosine" }
124- self . _collection_name = name
130+
125131 self ._collection = self ._chroma_client .get_or_create_collection (
126- name = name ,
132+ name = self . _collection_name ,
127133 embedding_function = None ,
128134 metadata = collection_metadata ,
129135 )
0 commit comments