feat(agent): 新增智能体应用功能

- 添加智能体列表页面和相关API
- 实现聊天功能,包括历史对话和当前对话
- 新增工作流功能,包括表单提交和结果展示- 优化路由配置,增加智能体相关路由
- 添加全局常量和枚举,用于智能体类型区分
This commit is contained in:
林志军
2025-07-16 18:49:28 +08:00
parent 616665d219
commit b3af007dd2
15 changed files with 412 additions and 182 deletions

View File

@ -1,27 +1,39 @@
<template>
<a-layout-sider width="250" style="background: #fff">
<div>
<div class="logo">
<img :src="cozeInfo?.icon_url" style="width: 100%; height: 70%" />
<img :src="cozeInfo?.icon_url" class="agent-img" />
</div>
<a-menu mode="inline" theme="light">
<a-menu-item key="1">
<span>{{ cozeInfo.title }}</span>
<span class="menu-title">{{ cozeInfo.title }}</span>
<span style="color: #8492ff; font-size: 12px">{{ cozeInfo.type == 1 ? '智能体' : '对话式' }}</span>
<span style="float: right">{{ cozeInfo.views }}次使用</span>
<p>{{ cozeInfo.description }}</p>
</a-menu-item>
<a-menu-item key="2">历史对话</a-menu-item>
<a-menu-item key="3">梳理这次舆情的时间线和关键节点</a-menu-item>
<a-menu-item key="4">提取事件发展的五阶段脉络</a-menu-item>
<a-menu-item key="5">提炼不同群体的主要观点和态度立场</a-menu-item>
<a-menu-item key="6">分类汇总正面中立负面声音要点</a-menu-item>
<a-menu-item key="7">分析文本中的情绪类型及占比</a-menu-item>
<a-menu-item key="8">识别负面情绪集中的评论内容</a-menu-item>
<div v-for="(item, index) in conversations" :key="index">
<a-dropdown-button>
<span> {{ item.content }} </span>
<template #content>
<a-doption>重命名</a-doption>
<a-popconfirm
content="确认删除对话吗?删除后,聊天记录将不可恢复。"
@ok="delMessage(item.chat_id, item.conversation_id)"
type="error"
>
<a-button>删除</a-button>
</a-popconfirm>
</template>
</a-dropdown-button>
</div>
</a-menu>
</a-layout-sider>
</div>
</template>
<script lang="ts" setup>
import { defineProps } from 'vue';
import { delAgentMessage, getHistoryChat } from '@/api/all/agent';
const props = defineProps({
cozeInfo: {
@ -33,14 +45,29 @@ const props = defineProps({
default: '',
},
});
const getHistoryChat = async () => {
const { code, data } = await getHistoryChat({ botId: props.botId });
console.log(data, 'data');
// 获取历史对话
const delMessage = async (chatId, conversationId) => {
const { code, data } = await delAgentMessage({ chat_id: chatId, conversation_id: conversationId });
if (code === 200) {
console.log(data, 'data');
}
};
const conversations = ref([]);
const getHistoryChatData = async (botId) => {
const { code, data } = await getHistoryChat({ bot_id: botId });
if (code === 200) {
conversations.value = data.list;
}
};
const truncateText = (text: string, maxLength = 30) => {
if (text.length <= maxLength) return text;
return text.slice(0, maxLength) + '...';
};
onMounted(() => {
getHistoryChat();
getHistoryChatData(props.botId);
});
</script>
@ -48,4 +75,19 @@ onMounted(() => {
.logo {
margin-bottom: 20px;
}
.menu-title {
color: var(--Text-1, #211f24);
font-size: 18px;
font-family: Alibaba PuHuiTi;
font-weight: 400;
line-height: 26px;
word-wrap: break-word;
}
.agent-img {
width: 100%;
height: 230px;
border-radius: 4px;
}
</style>