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
26 changes: 26 additions & 0 deletions ui/src/api/API_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,21 @@ API 对象和工作空间上下文,作为该抽屉的范围选择例外。Syst
详情和取消为 GET action/<actionId>、POST action/<actionId>/cancel。
- 智能体复制查询完整 ApplicationDetail,model 映射 model_id 后创建,不使用卡片摘要。

### 智能体概览

`admin/workspace/application/overview.ts` 独立维护概览接口,沿用 v2 的应用统计协议,在
`/workspace/<workspaceId>/application/<applicationId>` 下提供三个 GET 接口,均传入
`start_time`、`end_time`,由调用方管理 loading:

- `getMonitoring(workspaceId, range, applicationId)` 请求 `/application_stats`,返回 `HomeMonitoringDay[]`,供概览复用首页监控。
- `getTokenUsage` 请求 `/application_token_usage`,返回 `ApplicationTokenUsage[]`,字段为
`username`、`token_usage`。
- `getTopQuestions` 请求 `/top_questions`,返回 `ApplicationTopQuestion[]`,字段为
`username`、`chat_record_count`。

两类用户排行返回按使用量降序排列的完整数组,不使用首页排行的分页、总量或导出接口。
业务类型经 `@/api/types` 导出;Tokens 接口不包含用户对话次数,不据此展示每轮平均消耗。

### 工作空间首页

`admin/workspace/homepage.ts` 维护 `/workspace/<workspaceId>/homepage` 的四类资源汇总、
Expand Down Expand Up @@ -568,6 +583,17 @@ System 前缀中的额外 `knowledge` 段暂按 V2 保留,不能依据普通
目标文档选项通过 `workspace/knowledge/document.ts` 的 `getAllDocuments(knowledgeId)`
请求不分页的文档列表。聊天记录与标注接口保留在同一 API 文件,尚未接入日志详情正文。

### 智能体发布渠道

`admin/workspace/application/access.ts` 独立维护发布渠道接口,前缀为
`/workspace/<workspaceId>/application/<applicationId>/platform`,沿用 v2 协议。
GET `/status` 返回按平台标识索引的 `[是否已配置, 是否启用]`;POST `/status` 提交
`{ type, status }`。GET、POST `/<type>` 查询与保存对应平台配置,不由通用 application.ts 转发。
平台标识由 `APPLICATION_ACCESS_PLATFORM` 定义,业务类型在 `types/application.ts` 经公共入口导出。
公众号配置包含布尔值 `is_certification`,其余表单字段为字符串;配置保存保留未编辑字段。
回调地址沿用 Admin API base 下的 `/chat/<type>/<applicationId>`,不使用独立 Chat API base。
这些接口依赖部署端提供对应的平台接入服务。

### 知识库外部检索服务

四个知识库范围分别在自己的 `external-retrieval.ts` 中维护配置接口,仅资源前缀与写入能力不同:
Expand Down
49 changes: 21 additions & 28 deletions ui/src/api/admin/system/homepage.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { get, getExportFile } from '../core/request'
import type { ParamsPage, ResponsePage } from '../core/types'
import type {
Dict,
HomeApplicationAggregation,
HomeKnowledgeAggregation,
HomeToolAggregation,
Expand All @@ -14,52 +13,46 @@ import type {

const prefix = `/system/homepage`

/** 合并系统首页的工作空间筛选条件。 */
const withWorkspaceId = (workspaceId: string, query: Dict<unknown> = {}) => ({
...query,
workspace_id: workspaceId,
})
/** 获取智能体数量与发布状态。 */
const getApplicationAggregation = (workspaceId: string) =>
get<HomeApplicationAggregation>(`${prefix}/application/aggregation`, withWorkspaceId(workspaceId))
get<HomeApplicationAggregation>(`${prefix}/application/aggregation`, { workspace_id: workspaceId })
/** 获取知识库与文档数量。 */
const getKnowledgeAggregation = (workspaceId: string) =>
get<HomeKnowledgeAggregation>(`${prefix}/knowledge/aggregation`, withWorkspaceId(workspaceId))
get<HomeKnowledgeAggregation>(`${prefix}/knowledge/aggregation`, { workspace_id: workspaceId })
/** 获取工具数量与类型分布。 */
const getToolAggregation = (workspaceId: string) => get<HomeToolAggregation>(`${prefix}/tool/aggregation`, withWorkspaceId(workspaceId))
const getToolAggregation = (workspaceId: string) => get<HomeToolAggregation>(`${prefix}/tool/aggregation`, { workspace_id: workspaceId })
/** 获取模型数量与类型分布。 */
const getModelAggregation = (workspaceId: string) => get<HomeModelAggregation>(`${prefix}/model/aggregation`, withWorkspaceId(workspaceId))
const getModelAggregation = (workspaceId: string) => get<HomeModelAggregation>(`${prefix}/model/aggregation`, { workspace_id: workspaceId })
/** 获取指定日期及智能体范围内的每日使用趋势。 */
const getMonitoring = (workspaceId: string, range: HomeDateRange, applicationId?: string) =>
get<HomeMonitoringDay[]>(
`${prefix}/monitoring/aggregation`,
withWorkspaceId(workspaceId, {
...range,
...(applicationId ? { application_id: applicationId } : {}),
}),
)
get<HomeMonitoringDay[]>(`${prefix}/monitoring/aggregation`, {
...range,
...(applicationId ? { application_id: applicationId } : {}),
workspace_id: workspaceId,
})
/** 获取工作空间日期范围内的 Tokens 总量。 */
const getTokensAggregation = (workspaceId: string, range: HomeDateRange) =>
get<number>(`${prefix}/tokens/aggregation`, withWorkspaceId(workspaceId, { ...range }))
get<number>(`${prefix}/tokens/aggregation`, { ...range, workspace_id: workspaceId })
/** 获取工作空间日期范围内的对话轮次。 */
const getChatRecordAggregation = (workspaceId: string, range: HomeDateRange) =>
get<number>(`${prefix}/chat_record/aggregation`, withWorkspaceId(workspaceId, { ...range }))
get<number>(`${prefix}/chat_record/aggregation`, { ...range, workspace_id: workspaceId })

const rankingPaths = { tokens: 'tokens_ranking', questions: 'question_ranking', userTokens: 'user_tokens_ranking' }

/** 分页查询智能体或用户使用排行。 */
const getRanking = (workspaceId: string, kind: HomeRankingKind, page: ParamsPage, range: HomeDateRange, name?: string) =>
get<ResponsePage<HomeRankingRecord>>(
`${prefix}/application/${rankingPaths[kind]}/${page.currentPage}/${page.pageSize}`,
withWorkspaceId(workspaceId, { ...range, ...(name ? { name } : {}) }),
)
get<ResponsePage<HomeRankingRecord>>(`${prefix}/application/${rankingPaths[kind]}/${page.currentPage}/${page.pageSize}`, {
...range,
...(name ? { name } : {}),
workspace_id: workspaceId,
})
/** 按当前日期与名称筛选导出完整排行。 */
const exportRanking = (workspaceId: string, kind: HomeRankingKind, range: HomeDateRange, name?: string) =>
getExportFile(
`${rankingPaths[kind]}.xlsx`,
`${prefix}/${rankingPaths[kind]}/export`,
withWorkspaceId(workspaceId, { ...range, ...(name ? { name } : {}) }),
)
getExportFile(`${rankingPaths[kind]}.xlsx`, `${prefix}/${rankingPaths[kind]}/export`, {
...range,
...(name ? { name } : {}),
workspace_id: workspaceId,
})

export default {
getApplicationAggregation,
Expand Down
22 changes: 22 additions & 0 deletions ui/src/api/admin/workspace/application/access.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/** 工作空间智能体发布渠道配置与启停接口。 */
import { get, post } from '../../core/request'
import type { ApplicationAccessConfig, ApplicationAccessPlatform, ApplicationAccessStatus, ApplicationAccessStatusPayload } from '@/api/types'
import { getWorkspaceId } from '@/utils/resource-context'

const getPrefix = (applicationId: string) => `/workspace/${getWorkspaceId()}/application/${applicationId}/platform`

/** 获取智能体各发布渠道的配置及启用状态。 */
const getPlatformStatus = (applicationId: string) => get<ApplicationAccessStatus>(`${getPrefix(applicationId)}/status`)

/** 启用或停用智能体发布渠道。 */
const postPlatformStatus = (applicationId: string, payload: ApplicationAccessStatusPayload) => post(`${getPrefix(applicationId)}/status`, payload)

/** 获取智能体指定发布渠道的配置。 */
const getPlatformConfig = (applicationId: string, platform: ApplicationAccessPlatform) =>
get<ApplicationAccessConfig | null>(`${getPrefix(applicationId)}/${platform}`)

/** 保存智能体指定发布渠道的配置。 */
const postPlatformConfig = (applicationId: string, platform: ApplicationAccessPlatform, payload: ApplicationAccessConfig) =>
post(`${getPrefix(applicationId)}/${platform}`, payload)

export default { getPlatformStatus, postPlatformStatus, getPlatformConfig, postPlatformConfig }
1 change: 0 additions & 1 deletion ui/src/api/admin/workspace/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ const putApplicationPublish = (applicationId: string, publishName: string, publi
})
}


export default {
getApplicationPage,
getApplicationDetail,
Expand Down
24 changes: 24 additions & 0 deletions ui/src/api/admin/workspace/application/overview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/** 工作空间智能体概览的使用统计与用户排行接口。 */
import { get } from '../../core/request'
import type { ApplicationTokenUsage, ApplicationTopQuestion, HomeDateRange, HomeMonitoringDay } from '@/api/types'
import { getWorkspaceId } from '@/utils/resource-context'

const getPrefix = (workspaceId = getWorkspaceId()) => `/workspace/${workspaceId}/application`

/** 获取智能体每日对话、用户、Tokens 与满意度统计。 */
const getMonitoring = (workspaceId: string, range: HomeDateRange, applicationId: string) =>
get<HomeMonitoringDay[]>(`${getPrefix(workspaceId)}/${applicationId}/application_stats`, { ...range })

/** 获取智能体按用户排序的 Tokens 消耗。 */
const getTokenUsage = (applicationId: string, range: HomeDateRange) =>
get<ApplicationTokenUsage[]>(`${getPrefix()}/${applicationId}/application_token_usage`, { ...range })

/** 获取智能体按用户排序的提问次数。 */
const getTopQuestions = (applicationId: string, range: HomeDateRange) =>
get<ApplicationTopQuestion[]>(`${getPrefix()}/${applicationId}/top_questions`, { ...range })

export default {
getMonitoring,
getTokenUsage,
getTopQuestions,
}
10 changes: 10 additions & 0 deletions ui/src/api/enums/application.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
/** 后端智能体类型枚举值。 */
export const APPLICATION_TYPE = { SIMPLE: 'SIMPLE', WORK_FLOW: 'WORK_FLOW' } as const

/** 智能体发布渠道的后端平台标识。 */
export const APPLICATION_ACCESS_PLATFORM = {
WECOM_BOT: 'wecomBot',
WECOM: 'wecom',
DINGTALK: 'dingtalk',
WECHAT: 'wechat',
LARK: 'lark',
SLACK: 'slack',
} as const
30 changes: 29 additions & 1 deletion ui/src/api/types/application.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
/** Workspace 智能体列表及其卡片共用的业务类型。 */

import type LogicFlow from '@logicflow/core'
import { APPLICATION_TYPE } from '@/api/enums'
import { APPLICATION_ACCESS_PLATFORM, APPLICATION_TYPE } from '@/api/enums'
import type { DefaultModelSettingPayload } from './model'
import type { WorkflowStoreTemplate } from './workflow-template'
import type { Dict } from './common'

export type ApplicationType = (typeof APPLICATION_TYPE)[keyof typeof APPLICATION_TYPE]

export type ApplicationAccessPlatform = (typeof APPLICATION_ACCESS_PLATFORM)[keyof typeof APPLICATION_ACCESS_PLATFORM]

/** 状态数组依次为是否已配置、是否启用;未配置的平台可能不返回。 */
export type ApplicationAccessStatus = Partial<Record<ApplicationAccessPlatform, [exists: boolean, isActive: boolean]>>

export interface ApplicationAccessConfig extends Dict<string | boolean | undefined> {
callback_url?: string
is_certification?: boolean
}

export interface ApplicationAccessStatusPayload {
type: ApplicationAccessPlatform
status: boolean
}

export interface ApplicationDetail extends Omit<ApplicationFormPayload, 'desc'> {
/** 详情接口返回的主模型 ID。 */
model?: string | null
Expand Down Expand Up @@ -96,3 +112,15 @@ export interface ApplicationStoreResponse {
additionalProperties: { tags: { key: string; name: string }[] }
apps: ApplicationStoreTemplate[]
}

/** 智能体概览的用户 Tokens 消耗,接口返回完整排行。 */
export interface ApplicationTokenUsage {
username: string
token_usage: number | null
}

/** 智能体概览的用户提问次数,接口返回完整排行。 */
export interface ApplicationTopQuestion {
username: string
chat_record_count: number
}
2 changes: 1 addition & 1 deletion ui/src/assets/iconfont.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions ui/src/assets/logo/logo_enterprise-wechat-bot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions ui/src/assets/logo/logo_slack.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions ui/src/assets/logo/logo_wechat.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion ui/src/router/ROUTE_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ Workspace 共享覆盖 resourceScope,保留 Workspace scope 及知识库 activ
### 智能体

Workspace 详情父路由为 workspace-application-detail-layout,详情参数包含 applicationId 与 ApplicationDetail.type。
菜单为概览、设置、接入第三方、对话用户、对话日志;SIMPLE 的 setting 与高级 workflow-entry 互斥显示。
菜单为概览、设置、发布渠道、对话用户、对话日志;SIMPLE 的 setting 与高级 workflow-entry 互斥显示。
发布渠道使用 access 路径、workspace-application-access 路由名,对应 application-detail/access 页面。
高级设置重定向 workflow-application,保留 workspaceId、applicationId 和 query。
对话日志保留 operation-log 路径和 workspace-application-operation-log 名称。

Expand Down
8 changes: 4 additions & 4 deletions ui/src/router/admin/workspace/modules/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ export const applicationRoutes: RouteRecordRaw[] = [
},
},
{
path: 'integration',
name: 'workspace-application-integration',
component: () => import('@/views/application-detail/integration/index.vue'),
meta: { title: '接入第三方', icon: 'icon_dataset_outlined', activeIcon: 'icon_dataset_filled', order: 30 },
path: 'access',
name: 'workspace-application-access',
component: () => import('@/views/application-detail/access/index.vue'),
meta: { title: '发布渠道', icon: 'icon_application_outlined', activeIcon: 'icon_application_filled', order: 30 },
},
{
path: 'chat-user',
Expand Down
Loading
Loading