6277db3951
- C-T1 Wingman 辅助面板 - C-T2 Wingman 后端接口 - C-T3 排查流程图编辑器 - C-T4 流程图后端接口 - C-T5 流程图H5端展示 - C-T6 运营数据看板 - C-T7 看板数据接口 - C-T8 全局一致性审查(周2) - C-T9 坐席绩效报表 - C-T10 绩效数据接口+Excel导出 - C-T11 会话智能标注 - C-T12 全局一致性审查(周3) - C-T13 代码评审+PR创建
111 lines
3.2 KiB
TypeScript
111 lines
3.2 KiB
TypeScript
// =============================================================================
|
||
// 企微IT智能服务台 — AI Wingman API 调用模块
|
||
// =============================================================================
|
||
// 说明:封装与 AI Wingman(坐席智能副驾驶)相关的 HTTP 请求
|
||
// 对应后端 API:/api/conversations/{id}/wingman
|
||
// 包括:生成草稿回复、生成会话摘要、生成标签建议
|
||
// =============================================================================
|
||
|
||
import apiClient from './index'
|
||
import type { AxiosResponse } from 'axios'
|
||
|
||
// --------------------------------------------------------------------------
|
||
// TypeScript 类型定义 — 与后端 Wingman API 响应格式保持一致
|
||
// --------------------------------------------------------------------------
|
||
|
||
/** 草稿回复结果 */
|
||
export interface DraftResult {
|
||
/** 草稿内容 */
|
||
content: string
|
||
/** 置信度(0-1) */
|
||
confidence: number
|
||
/** 生成推理说明 */
|
||
reasoning: string
|
||
}
|
||
|
||
/** 会话摘要结果 */
|
||
export interface SummaryResult {
|
||
/** 问题描述 */
|
||
problem: string
|
||
/** 原因分析 */
|
||
cause: string
|
||
/** 解决方案 */
|
||
solution: string
|
||
}
|
||
|
||
/** 标签建议结果 */
|
||
export interface TagsResult {
|
||
/** 建议标签列表 */
|
||
suggested_tags: string[]
|
||
/** 分类 */
|
||
category: string
|
||
/** 优先级: low/medium/high */
|
||
priority: string
|
||
}
|
||
|
||
// --------------------------------------------------------------------------
|
||
// API 函数
|
||
// --------------------------------------------------------------------------
|
||
|
||
/**
|
||
* 生成 AI 草稿回复
|
||
* 基于当前会话的消息历史,生成坐席可以采纳的草稿回复
|
||
*
|
||
* @param conversationId - 会话ID
|
||
* @returns 草稿回复结果
|
||
*/
|
||
export async function generateDraft(conversationId: string): Promise<DraftResult> {
|
||
const response: AxiosResponse = await apiClient.post(
|
||
`/conversations/${conversationId}/wingman/draft`
|
||
)
|
||
return response.data.data
|
||
}
|
||
|
||
/**
|
||
* 生成会话自动摘要
|
||
* 基于完整对话生成结构化摘要,包含问题、原因、解决方案
|
||
* 通常在结单时调用
|
||
*
|
||
* @param conversationId - 会话ID
|
||
* @returns 会话摘要结果
|
||
*/
|
||
export async function generateSummary(conversationId: string): Promise<SummaryResult> {
|
||
const response: AxiosResponse = await apiClient.post(
|
||
`/conversations/${conversationId}/wingman/summary`
|
||
)
|
||
return response.data.data
|
||
}
|
||
|
||
/**
|
||
* 生成自动标签建议
|
||
* 基于对话内容建议标签分类
|
||
*
|
||
* @param conversationId - 会话ID
|
||
* @returns 标签建议结果
|
||
*/
|
||
export async function suggestTags(conversationId: string): Promise<TagsResult> {
|
||
const response: AxiosResponse = await apiClient.post(
|
||
`/conversations/${conversationId}/wingman/tags`
|
||
)
|
||
return response.data.data
|
||
}
|
||
|
||
/**
|
||
* 保存会话标签
|
||
* 将标签保存到会话记录中
|
||
*
|
||
* @param conversationId - 会话ID
|
||
* @param tags - 标签字典
|
||
* @returns 更新后的会话详情
|
||
*/
|
||
export async function saveConversationTags(
|
||
conversationId: string,
|
||
tags: Record<string, any>
|
||
): Promise<any> {
|
||
const response: AxiosResponse = await apiClient.post(
|
||
`/conversations/${conversationId}/tags`,
|
||
{ tags }
|
||
)
|
||
return response.data.data
|
||
}
|