From 9ab254b9fb2768de9030c40ee80317fe25cfc834 Mon Sep 17 00:00:00 2001 From: Kven <2955163637@qq.com> Date: Thu, 22 May 2025 22:06:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(@vben/common-ui):=20=E6=9B=B4=E6=96=B0=20A?= =?UTF-8?q?I=20=E6=A8=A1=E5=9D=97=E8=B7=AF=E7=94=B1=E3=80=81API=20?= =?UTF-8?q?=E5=92=8C=E8=A7=86=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/api/core/chatflow.ts | 5 ++ apps/web-antd/src/api/core/spider.ts | 5 ++ apps/web-antd/src/api/core/workflow.ts | 12 ++--- .../src/router/routes/modules/aiFlow.ts | 14 ++--- apps/web-antd/src/views/home/index.vue | 6 +-- apps/web-antd/src/views/ppt/index.vue | 4 +- apps/web-antd/src/views/spider/index.vue | 4 +- apps/web-antd/src/views/word/index.vue | 4 +- .../common-ui/src/ui/ppt/ppt-work-view.vue | 52 +++---------------- .../src/ui/spider/spider-work-view.vue | 25 +++------ .../common-ui/src/ui/word/word-work-view.vue | 37 +++++-------- 11 files changed, 59 insertions(+), 109 deletions(-) diff --git a/apps/web-antd/src/api/core/chatflow.ts b/apps/web-antd/src/api/core/chatflow.ts index 45fc7ab..47e628f 100644 --- a/apps/web-antd/src/api/core/chatflow.ts +++ b/apps/web-antd/src/api/core/chatflow.ts @@ -57,6 +57,11 @@ export async function sendChatflow( return requestClient.post(`/v1/chat/completions/${params.appid}`, data); } +// word +export async function sendWord(data: ChatflowApi.CompletionsBody) { + return requestClient.post(`word/completions`, data); +} + export async function getChatList( params: ChatflowApi.ChatParams, data: ChatflowApi.ChatListBody, diff --git a/apps/web-antd/src/api/core/spider.ts b/apps/web-antd/src/api/core/spider.ts index 0830223..84d2ffe 100644 --- a/apps/web-antd/src/api/core/spider.ts +++ b/apps/web-antd/src/api/core/spider.ts @@ -5,6 +5,11 @@ export function runSpider(data: any) { return requestClient.post(`/spider/run`, data); } +// 广州公共资源爬虫 +export function runSpiderGz(data: any) { + return requestClient.post(`/spider2/run`, data); +} + export function getSpiderStatus() { return requestClient.post(`/spider/status`); } diff --git a/apps/web-antd/src/api/core/workflow.ts b/apps/web-antd/src/api/core/workflow.ts index 9f41a96..ac965cd 100644 --- a/apps/web-antd/src/api/core/workflow.ts +++ b/apps/web-antd/src/api/core/workflow.ts @@ -36,14 +36,10 @@ export function sendWorkflow( return requestClient.post(`/v1/workflow/run/${params.appid}`, data); } -// export function runWorkflow(data){ -// return requestClient.post('/v1/workflow/run/stream', data); -// }; -// -// export function stopWorkflow(data){ -// return requestClient.patch('/v1/workflow/stop', { data }); -// }; -// +export function sendPpt(data: WorkflowApi.WorkflowRunBody) { + return requestClient.post(`/ppt/run`, data); +} + export function getWorkflowInfo(data: WorkflowApi.WorkflowLogParams) { return requestClient.get(`/v1/workflow/info/${data.appid}`, { params: data }); } diff --git a/apps/web-antd/src/router/routes/modules/aiFlow.ts b/apps/web-antd/src/router/routes/modules/aiFlow.ts index 2566224..733444e 100644 --- a/apps/web-antd/src/router/routes/modules/aiFlow.ts +++ b/apps/web-antd/src/router/routes/modules/aiFlow.ts @@ -4,13 +4,13 @@ import { HugeAi, SvgPPT, SvgSpider, SvgWord } from '@vben/icons'; const routes: RouteRecordRaw[] = [ { - name: 'aiflow', - path: '/aiflow', + name: 'ai', + path: '/ai', meta: { icon: HugeAi, title: 'AI工作流', order: 4, - authority: ['system'], + authority: ['ai'], }, children: [ { @@ -21,7 +21,7 @@ const routes: RouteRecordRaw[] = [ icon: SvgSpider, title: 'AI平台信息获取', order: 1, - authority: ['dify:server:init'], + authority: ['ai:spider'], }, }, { @@ -32,7 +32,7 @@ const routes: RouteRecordRaw[] = [ icon: SvgWord, title: 'AI申报书WORD生成', order: 2, - authority: ['dify:chat:send'], + authority: ['ai:word'], }, }, { @@ -41,9 +41,9 @@ const routes: RouteRecordRaw[] = [ component: () => import('#/views/ppt/index.vue'), meta: { icon: SvgPPT, - title: 'PPT自动生成', + title: 'AI申报书PPT生成', order: 3, - authority: ['dify:workflow:run'], + authority: ['ai:ppt'], }, }, ], diff --git a/apps/web-antd/src/views/home/index.vue b/apps/web-antd/src/views/home/index.vue index adc29db..fe2e336 100644 --- a/apps/web-antd/src/views/home/index.vue +++ b/apps/web-antd/src/views/home/index.vue @@ -9,19 +9,19 @@ import { SvgPPT, SvgSpider, SvgWord } from '@vben/icons'; const items: WorkflowItem[] = [ { icon: SvgSpider, - title: '数据抓取工具', + title: 'AI平台信息获取', description: '自动抓取', path: '/ai/spider', }, { icon: SvgWord, - title: 'Word文档生成工具', + title: 'AI申报书WORD生成', description: '自动生成word文档', path: '/ai/word', }, { icon: SvgPPT, - title: 'PPT生成工具', + title: 'AI申报书PPT生成', description: '自动生成PPT文档', path: '/ai/ppt', }, diff --git a/apps/web-antd/src/views/ppt/index.vue b/apps/web-antd/src/views/ppt/index.vue index c68b88f..f83b192 100644 --- a/apps/web-antd/src/views/ppt/index.vue +++ b/apps/web-antd/src/views/ppt/index.vue @@ -7,7 +7,7 @@ import { PptListView, PptWorkView } from '@vben/common-ui'; import { notification } from 'ant-design-vue'; -import { getWorkflowInfo, getWorkflowList, sendWorkflow } from '#/api'; +import { getWorkflowInfo, getWorkflowList, sendPpt } from '#/api'; let temp = reactive({ id: 'ee3889b6-50fa-463e-b956-3b93447727fc', @@ -84,7 +84,7 @@ onMounted(() => { diff --git a/apps/web-antd/src/views/spider/index.vue b/apps/web-antd/src/views/spider/index.vue index ac62a7f..7b828af 100644 --- a/apps/web-antd/src/views/spider/index.vue +++ b/apps/web-antd/src/views/spider/index.vue @@ -10,7 +10,7 @@ import { getWorkflowInfo, getWorkflowList, runSpider, - sendWorkflow, + runSpiderGz, stopSpider, } from '#/api'; // sendWorkflow @@ -96,7 +96,7 @@ async function handleClickMode(item: TempItem) { :run-spider="runSpider" :stop-spider="stopSpider" :get-spider-status="getSpiderStatus" - :send-workflow="sendWorkflow" + :run-spider-gz="runSpiderGz" :item-message="itemMessage" /> diff --git a/apps/web-antd/src/views/word/index.vue b/apps/web-antd/src/views/word/index.vue index bb61cfa..19557e1 100644 --- a/apps/web-antd/src/views/word/index.vue +++ b/apps/web-antd/src/views/word/index.vue @@ -12,7 +12,7 @@ import { getChatflowMessage, getChatList, getChatParameters, - sendChatflow, + sendWord, } from '#/api'; interface ResultItem { @@ -133,7 +133,7 @@ onMounted(() => { diff --git a/packages/effects/common-ui/src/ui/ppt/ppt-work-view.vue b/packages/effects/common-ui/src/ui/ppt/ppt-work-view.vue index 165602c..a89d906 100644 --- a/packages/effects/common-ui/src/ui/ppt/ppt-work-view.vue +++ b/packages/effects/common-ui/src/ui/ppt/ppt-work-view.vue @@ -26,10 +26,6 @@ interface ResultItem { footer?: any; } -interface WorkflowParams { - appid: string; -} - interface WorkflowContext { userId: string; conversationId: string; @@ -48,10 +44,7 @@ interface WorkflowResult { interface Props { itemMessage?: ResultItem; item?: PPTTempItem; - runWorkflow?: ( - params: WorkflowParams, - context: WorkflowContext, - ) => Promise; + runWorkflow?: (context: WorkflowContext) => Promise; } defineOptions({ name: 'PlaygroundIndependentSetup' }); @@ -122,30 +115,6 @@ const fetchStatus = ref(''); const resultItems = ref([]); const fetchResult = ref(''); -// ==================== Runtime ==================== -// const [agent] = useXAgent({ -// request: async ({ message }, { onSuccess }) => { -// agentRequestLoading.value = true; -// await sleep(); -// agentRequestLoading.value = false; -// onSuccess(`Mock success return. You said: ${message}`); -// }, -// }); -// -// const { } = useXChat({ -// agent: agent.value, -// }); - -// watch( -// activeKey, -// () => { -// if (activeKey.value !== undefined) { -// setMessages([]); -// } -// }, -// { immediate: true }, -// ); - const [PreviewDrawer, previewDrawerApi] = useVbenDrawer({ // 连接抽离的组件 connectedComponent: PptPreview, @@ -188,19 +157,14 @@ const startFetching = async () => { }); try { - const res = await props.runWorkflow( - { - appid: 'ee3889b6-50fa-463e-b956-3b93447727fc', + const res = await props.runWorkflow({ + userId: '1562', + conversationId: '', + files: [], + inputs: { + declarationDoc: content.value, }, - { - userId: '1562', - conversationId: '', - files: [], - inputs: { - declarationDoc: content.value, - }, - }, - ); + }); const { result } = res.data.outputs; content.value = ''; diff --git a/packages/effects/common-ui/src/ui/spider/spider-work-view.vue b/packages/effects/common-ui/src/ui/spider/spider-work-view.vue index b4f7167..0aae7fd 100644 --- a/packages/effects/common-ui/src/ui/spider/spider-work-view.vue +++ b/packages/effects/common-ui/src/ui/spider/spider-work-view.vue @@ -30,10 +30,6 @@ import dayjs, { Dayjs } from 'dayjs'; import SpiderPreview from './spider-preview.vue'; -interface SpiderParams { - appid: string; -} - interface SpiderContext { userId: string; conversationId: string; @@ -67,7 +63,7 @@ interface Props { stopSpider?: () => Promise<{ status: string; }>; - sendWorkflow?: (params: SpiderParams, data: SpiderContext) => Promise; + runSpiderGz?: (data: SpiderContext) => Promise; } defineOptions({ @@ -93,7 +89,7 @@ const props = withDefaults(defineProps(), { msg: '', code: '', }), - sendWorkflow: () => async () => ({ + runSpiderGz: () => async () => ({ outputs: { result: '', files: [], @@ -272,17 +268,12 @@ const startFetching = async () => { message: '正在获取中...', duration: 3, }); - const res = await props.sendWorkflow( - { - appid: props.item.id, - }, - { - userId: '1562', - conversationId: '', - files: [], - inputs: {}, - }, - ); + const res = await props.runSpiderGz({ + userId: '1562', + conversationId: '', + files: [], + inputs: {}, + }); if (res.data.outputs.files) { // 保存抓取结果 fetchResult.value = res.data.outputs.files[0].url; diff --git a/packages/effects/common-ui/src/ui/word/word-work-view.vue b/packages/effects/common-ui/src/ui/word/word-work-view.vue index 8c5e296..f6049bc 100644 --- a/packages/effects/common-ui/src/ui/word/word-work-view.vue +++ b/packages/effects/common-ui/src/ui/word/word-work-view.vue @@ -52,9 +52,6 @@ interface ResultItem { content: string; footer?: any; } -interface WorkflowParams { - appid: string; -} interface WorkflowContext { userId: string; conversationId: string; @@ -77,10 +74,7 @@ interface Props { itemMessage?: ResultItem; item?: WordTempItem; paramsData?: {}; - runChatflow?: ( - params: WorkflowParams, - context: WorkflowContext, - ) => Promise; + runChatflow?: (context: WorkflowContext) => Promise; } defineOptions({ name: 'PlaygroundIndependentSetup' }); @@ -295,24 +289,19 @@ const startFetching = async () => { }); try { - const res = await props.runChatflow( - { - appid: 'baca08c1-e92b-4dc9-a445-3584803f54d4', + const res = await props.runChatflow({ + userId: '1562', + conversationId: conversationId.value, + files: [], + inputs: { + projectName: projectInfo.value.projectName, + projectContext: projectInfo.value.projectContext, + keyAvoidTechOrKeyword: projectInfo.value.projectKeyAvoidTechOrKeyword, + userInitialInnovationPoint: + projectInfo.value.userInitialInnovationPoint, }, - { - userId: '1562', - conversationId: conversationId.value, - files: [], - inputs: { - projectName: projectInfo.value.projectName, - projectContext: projectInfo.value.projectContext, - keyAvoidTechOrKeyword: projectInfo.value.projectKeyAvoidTechOrKeyword, - userInitialInnovationPoint: - projectInfo.value.userInitialInnovationPoint, - }, - content: content.value || '', - }, - ); + content: content.value || '', + }); content.value = ''; const { answer } = res; conversationId.value = res.conversationId;