From 84988b89fe910226cdced3b6c2223c9da4120129 Mon Sep 17 00:00:00 2001 From: A-Salty-Fish <41696599+A-Salty-Fish@users.noreply.github.com> Date: Mon, 22 Jul 2024 19:13:52 +0800 Subject: [PATCH] fix: Solve the problem of invalid subgraph naming when creating tugraph (#1731) --- dbgpt/app/knowledge/service.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dbgpt/app/knowledge/service.py b/dbgpt/app/knowledge/service.py index c4e2f2f9a..0f93bac8a 100644 --- a/dbgpt/app/knowledge/service.py +++ b/dbgpt/app/knowledge/service.py @@ -1,5 +1,6 @@ import json import logging +import re from datetime import datetime from dbgpt._private.config import Config @@ -79,6 +80,10 @@ def create_knowledge_space(self, request: KnowledgeSpaceRequest): ) if request.vector_type == "VectorStore": request.vector_type = CFG.VECTOR_STORE_TYPE + if request.vector_type == "KnowledgeGraph": + knowledge_space_name_pattern = r"^[a-zA-Z0-9\u4e00-\u9fa5]+$" + if not re.match(knowledge_space_name_pattern, request.name): + raise Exception(f"space name:{request.name} invalid") spaces = knowledge_space_dao.get_knowledge_space(query) if len(spaces) > 0: raise Exception(f"space name:{request.name} have already named")