Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions frontend/const/knowledgeBase.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// Knowledge base related constants

// Keep this pattern in sync with AIDP's knowledge-base name validation.
export const AIDP_KNOWLEDGE_BASE_NAME_PATTERN =
/^[\u4e00-\u9fa5a-zA-Z][\u4e00-\u9fa5a-zA-Z0-9_]{0,255}$/;

// Document status constants
export const DOCUMENT_STATUS = {
WAIT_FOR_PROCESSING: "WAIT_FOR_PROCESSING",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ import { USER_ROLES } from "@/const/auth";
* compatibility.
*/
type RcFileLike = File & { uid: string; lastModifiedDate: Date };
import { AIDP_ACCEPT_STRING } from "@/const/knowledgeBase";
import {
AIDP_ACCEPT_STRING,
AIDP_KNOWLEDGE_BASE_NAME_PATTERN,
} from "@/const/knowledgeBase";
import {
partitionAidpFiles,
validateAidpFiles,
Expand Down Expand Up @@ -444,6 +447,10 @@ const AidpCreateKbModal: React.FC<AidpCreateKbModalProps> = ({
label={t("aidpKnowledge.kbName")}
rules={[
{ required: true, message: t("aidpKnowledge.kbNameRequired") },
{
pattern: AIDP_KNOWLEDGE_BASE_NAME_PATTERN,
message: t("aidpKnowledge.kbNameInvalid"),
},
]}
>
<Input placeholder={t("aidpKnowledge.kbNamePlaceholder")} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Modal, Form, Input, Select, message } from "antd";

import type { AidpKnowledgeBaseItem } from "@/types/agentConfig";
import aidpKnowledgeService from "@/ext_components/aidp/services/aidpKnowledgeService";
import { AIDP_KNOWLEDGE_BASE_NAME_PATTERN } from "@/const/knowledgeBase";
import { useGroupList } from "@/hooks/group/useGroupList";
import { useAuthorizationContext } from "@/components/providers/AuthorizationProvider";
import { USER_ROLES } from "@/const/auth";
Expand Down Expand Up @@ -163,6 +164,10 @@ const AidpUpdateKbModal: React.FC<AidpUpdateKbModalProps> = ({
label={t("aidpKnowledge.kbName")}
rules={[
{ required: true, message: t("aidpKnowledge.kbNameRequired") },
{
pattern: AIDP_KNOWLEDGE_BASE_NAME_PATTERN,
message: t("aidpKnowledge.kbNameInvalid"),
},
]}
>
<Input placeholder={t("aidpKnowledge.kbNamePlaceholder")} />
Expand Down
1 change: 1 addition & 0 deletions frontend/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -4191,6 +4191,7 @@
"aidpKnowledge.kbName": "Name",
"aidpKnowledge.kbNamePlaceholder": "Knowledge base name",
"aidpKnowledge.kbNameRequired": "Name is required",
"aidpKnowledge.kbNameInvalid": "Invalid name format: the name must start with a Chinese character or English letter, followed only by Chinese or English letters, digits, or underscores, and be 1–256 characters long.",
"aidpKnowledge.kbDescription": "Description",
"aidpKnowledge.kbDescriptionPlaceholder": "Optional description",
"aidpKnowledge.kbDescriptionRequired": "Please enter a description",
Expand Down
1 change: 1 addition & 0 deletions frontend/public/locales/zh/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -3922,6 +3922,7 @@
"aidpKnowledge.kbName": "名称",
"aidpKnowledge.kbNamePlaceholder": "知识库名称",
"aidpKnowledge.kbNameRequired": "名称是必填项",
"aidpKnowledge.kbNameInvalid": "名称格式不正确:必须以中文或英文字母开头,后续只能包含中文、英文字母、数字或下划线,长度为 1-256 个字符",
"aidpKnowledge.kbDescription": "描述",
"aidpKnowledge.kbDescriptionPlaceholder": "可选描述信息",
"aidpKnowledge.kbDescriptionRequired": "请输入知识库描述",
Expand Down
Loading