Skip to content

Commit dc7f752

Browse files
authored
Support AI Assistant and MCP functions (#1477)
1. Add AI assistant-related business. 2. Add Mcp related configuration in the management background
1 parent c509723 commit dc7f752

File tree

49 files changed

+3533
-18
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+3533
-18
lines changed

i18n/en_US.yaml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,16 @@ ui:
857857
http_403: HTTP Error 403
858858
logout: Log Out
859859
posts: Posts
860+
ai_assistant: AI Assistant
861+
ai_assistant:
862+
description: Got a question? Ask it and get answers, perspectives, and recommendations.
863+
recent_conversations: Recent Conversations
864+
show_more: Show more
865+
new: New chat
866+
ai_generate: AI-generated from posts and may not be accurate.
867+
copy: Copy
868+
ask_a_follow_up: Ask a follow-up
869+
ask_placeholder: Ask a question
860870
notifications:
861871
title: Notifications
862872
inbox: Inbox
@@ -1823,6 +1833,11 @@ ui:
18231833
policies: Policies
18241834
security: Security
18251835
files: Files
1836+
apikeys: API Keys
1837+
intelligence: Intelligence
1838+
ai_assistant: AI Assistant
1839+
ai_settings: AI Settings
1840+
mcp: MCP
18261841
website_welcome: Welcome to {{site_name}}
18271842
user_center:
18281843
login: Login
@@ -2298,6 +2313,70 @@ ui:
22982313
show_logs: Show logs
22992314
status: Status
23002315
title: Badges
2316+
apikeys:
2317+
title: API Keys
2318+
add_api_key: Add API Key
2319+
desc: Description
2320+
scope: Scope
2321+
key: Key
2322+
created: Created
2323+
last_used: Last used
2324+
add_or_edit_modal:
2325+
add_title: Add API Key
2326+
edit_title: Edit API Key
2327+
description: Description
2328+
description_required: Description is required.
2329+
scope: Scope
2330+
global: Global
2331+
read-only: Read-only
2332+
created_modal:
2333+
title: API key created
2334+
api_key: API key
2335+
description: This key will not be displayed again. Make sure you take a copy before continuing.
2336+
delete_modal:
2337+
title: Delete API Key
2338+
content: Any applications or scripts using this key will no longer be able to access the API. This is permanent!
2339+
ai_settings:
2340+
enabled:
2341+
label: AI enabled
2342+
check: Enable AI features
2343+
text: The AI model must be configured correctly before it can be used.
2344+
provider:
2345+
label: Provider
2346+
api_host:
2347+
label: API host
2348+
msg: API host is required
2349+
api_key:
2350+
label: API key
2351+
check: Check
2352+
check_success: "Connection successful."
2353+
msg: API key is required
2354+
model:
2355+
label: Model
2356+
msg: Model is required
2357+
add_success: AI settings updated successfully.
2358+
conversations:
2359+
topic: Topic
2360+
helpful: Helpful
2361+
unhelpful: Unhelpful
2362+
created: Created
2363+
action: Action
2364+
empty: No conversations found.
2365+
delete_modal:
2366+
title: Delete conversation
2367+
content: Are you sure you want to delete this conversation? This is permanent!
2368+
delete_success: Conversation deleted successfully.
2369+
mcp:
2370+
mcp_server:
2371+
label: MCP server
2372+
switch: Enabled
2373+
type:
2374+
label: Type
2375+
url:
2376+
label: URL
2377+
http_header:
2378+
label: HTTP header
2379+
text: Please replace {key} with the API Key.
23012380
form:
23022381
optional: (optional)
23032382
empty: cannot be empty

i18n/zh_CN.yaml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,16 @@ ui:
846846
http_403: HTTP 错误 403
847847
logout: 退出
848848
posts: 帖子
849+
ai_assistant: AI 助手
850+
ai_assistant:
851+
description: 有问题吗?尽管提问,即可获得解答、不同观点及实用建议。
852+
recent_conversations: 最近的对话
853+
show_more: 展示更多
854+
new: 新建对话
855+
ai_generate: 由帖子生成的 AI 内容,可能并不准确。
856+
copy: 复制
857+
ask_a_follow_up: 继续提问
858+
ask_placeholder: 提出问题
849859
notifications:
850860
title: 通知
851861
inbox: 收件箱
@@ -1785,6 +1795,11 @@ ui:
17851795
policies: 政策
17861796
security: 安全
17871797
files: 文件
1798+
apikeys: API Keys
1799+
intelligence: 人工智能
1800+
ai_assistant: AI 助手
1801+
ai_settings: AI 设置
1802+
mcp: MCP
17881803
website_welcome: 欢迎来到 {{site_name}}
17891804
user_center:
17901805
login: 登录
@@ -2259,6 +2274,70 @@ ui:
22592274
show_logs: 显示日志
22602275
status: 状态
22612276
title: 徽章
2277+
apikeys:
2278+
title: API Keys
2279+
add_api_key: 添加 API Key
2280+
desc: 描述
2281+
scope: 范围
2282+
key: Key
2283+
created: 创建时间
2284+
last_used: 最后使用时间
2285+
add_or_edit_modal:
2286+
add_title: 添加 API Key
2287+
edit_title: 编辑 API Key
2288+
description: 描述
2289+
description_required: 描述必填.
2290+
scope: 范围
2291+
global: 全局
2292+
read-only: 只读
2293+
created_modal:
2294+
title: API key 创建成功
2295+
api_key: API key
2296+
description: 此密钥将不会再显示。请确保在继续之前复制一份。
2297+
delete_modal:
2298+
title: 删除 API Key
2299+
content: 任何使用此密钥的应用程序或脚本将无法再访问 API。这是永久性的!
2300+
ai_settings:
2301+
enabled:
2302+
label: AI 启用
2303+
check: 启用 AI 功能
2304+
text: AI 模型必须正确配置才能使用。
2305+
provider:
2306+
label: 提供者
2307+
api_host:
2308+
label: API 主机
2309+
msg: API 主机必填
2310+
api_key:
2311+
label: API Key
2312+
check: 校验
2313+
check_success: "连接成功."
2314+
msg: API key 必填
2315+
model:
2316+
label: 模型
2317+
msg: 模型必填
2318+
add_success: AI 设置已成功更新.
2319+
conversations:
2320+
topic: 话题
2321+
helpful: 有用的
2322+
unhelpful: 无用的
2323+
created: 创建于
2324+
action: 操作
2325+
empty: 没有会话记录。
2326+
delete_modal:
2327+
title: 删除对话
2328+
content: 你确定要删除此对话吗?这是永久的!
2329+
delete_success: 对话删除成功.
2330+
mcp:
2331+
mcp_server:
2332+
label: MCP 服务
2333+
switch: 启用
2334+
type:
2335+
label: 类型
2336+
url:
2337+
label: URL
2338+
http_header:
2339+
label: HTTP header
2340+
text: 请将 {key} 替换为 API Key。
22622341
form:
22632342
optional: (选填)
22642343
empty: 不能为空

ui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"react-router-dom": "^7.0.2",
4747
"semver": "^7.3.8",
4848
"swr": "^1.3.0",
49+
"uuid": "13.0.0",
4950
"zustand": "^5.0.2"
5051
},
5152
"devDependencies": {

ui/pnpm-lock.yaml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/src/common/constants.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ export const ADMIN_NAV_MENUS = [
102102
{ name: 'tags', path: 'tags/settings', pathPrefix: 'tags/' },
103103
],
104104
},
105+
{
106+
name: 'intelligence',
107+
icon: 'robot',
108+
children: [
109+
{ name: 'ai_settings', path: 'ai-settings' },
110+
{ name: 'ai_assistant', path: 'ai-assistant' },
111+
],
112+
},
105113
{
106114
name: 'community',
107115
icon: 'people-fill',
@@ -135,6 +143,8 @@ export const ADMIN_NAV_MENUS = [
135143
{ name: 'login' },
136144
{ name: 'seo' },
137145
{ name: 'smtp' },
146+
{ name: 'apikeys' },
147+
{ name: 'mcp' },
138148
],
139149
},
140150
{

ui/src/common/interface.ts

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ export interface SiteSettings {
427427
version: string;
428428
revision: string;
429429
site_security: AdminSettingsSecurity;
430+
ai_enabled: boolean;
430431
}
431432

432433
export interface AdminSettingBranding {
@@ -809,6 +810,76 @@ export interface BadgeDetailListRes {
809810
list: BadgeDetailListItem[];
810811
}
811812

813+
export interface AdminApiKeysItem {
814+
access_key: string;
815+
created_at: number;
816+
description: string;
817+
id: number;
818+
last_used_at: number;
819+
scope: string;
820+
}
821+
822+
export interface AddOrEditApiKeyParams {
823+
description: string;
824+
scope?: string;
825+
id?: number;
826+
}
827+
828+
export interface AiConfig {
829+
enabled: boolean;
830+
chosen_provider: string;
831+
ai_providers: Array<{
832+
provider: string;
833+
api_host: string;
834+
api_key: string;
835+
model: string;
836+
}>;
837+
}
838+
839+
export interface AiProviderItem {
840+
name: string;
841+
display_name: string;
842+
default_api_host: string;
843+
}
844+
845+
export interface ConversationListItem {
846+
conversation_id: string;
847+
created_at: number;
848+
topic: string;
849+
}
850+
851+
export interface AdminConversationListItem {
852+
id: string;
853+
topic: string;
854+
helpful_count: number;
855+
unhelpful_count: number;
856+
created_at: number;
857+
user_info: UserInfoBase;
858+
}
859+
860+
export interface ConversationDetailItem {
861+
chat_completion_id: string;
862+
content: string;
863+
role: string;
864+
helpful: number;
865+
unhelpful: number;
866+
created_at: number;
867+
}
868+
869+
export interface ConversationDetail {
870+
conversation_id: string;
871+
created_at: number;
872+
records: ConversationDetailItem[];
873+
topic: string;
874+
updated_at: number;
875+
}
876+
877+
export interface VoteConversationParams {
878+
cancel: boolean;
879+
chat_completion_id: string;
880+
vote_type: 'helpful' | 'unhelpful';
881+
}
882+
812883
export interface AdminQuestionSetting {
813884
min_tags: number;
814885
min_content: number;

0 commit comments

Comments
 (0)