Skip to content

Commit 0e9faf4

Browse files
authored
fix:issue2484 (#2485)
Close #2484 # Description fix issue 2484 # How Has This Been Tested? create knowledge space with Chinese # Snapshots: Include snapshots for easier review. # Checklist: - [ ] My code follows the style guidelines of this project - [ ] I have already rebased the commits and make the commit message conform to the project standard. - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] Any dependent changes have been merged and published in downstream modules
2 parents df045c2 + 4376394 commit 0e9faf4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/dbgpt-ext/src/dbgpt_ext/storage/vector_store/chroma_store.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
VectorStoreConfig,
1515
)
1616
from dbgpt.storage.vector_store.filters import FilterOperator, MetadataFilters
17+
from dbgpt.util import string_utils
1718
from dbgpt.util.i18n_utils import _
1819

1920
logger = 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

Comments
 (0)