feat(@vben/common-ui): 更新 AI 模块路由、API 和视图

This commit is contained in:
Kven 2025-05-22 22:06:32 +08:00
parent 24e2f29203
commit 9ab254b9fb
11 changed files with 59 additions and 109 deletions

View File

@ -57,6 +57,11 @@ export async function sendChatflow(
return requestClient.post(`/v1/chat/completions/${params.appid}`, data); 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( export async function getChatList(
params: ChatflowApi.ChatParams, params: ChatflowApi.ChatParams,
data: ChatflowApi.ChatListBody, data: ChatflowApi.ChatListBody,

View File

@ -5,6 +5,11 @@ export function runSpider(data: any) {
return requestClient.post(`/spider/run`, data); return requestClient.post(`/spider/run`, data);
} }
// 广州公共资源爬虫
export function runSpiderGz(data: any) {
return requestClient.post(`/spider2/run`, data);
}
export function getSpiderStatus() { export function getSpiderStatus() {
return requestClient.post(`/spider/status`); return requestClient.post(`/spider/status`);
} }

View File

@ -36,14 +36,10 @@ export function sendWorkflow(
return requestClient.post(`/v1/workflow/run/${params.appid}`, data); return requestClient.post(`/v1/workflow/run/${params.appid}`, data);
} }
// export function runWorkflow(data){ export function sendPpt(data: WorkflowApi.WorkflowRunBody) {
// return requestClient.post('/v1/workflow/run/stream', data); return requestClient.post(`/ppt/run`, data);
// }; }
//
// export function stopWorkflow(data){
// return requestClient.patch('/v1/workflow/stop', { data });
// };
//
export function getWorkflowInfo(data: WorkflowApi.WorkflowLogParams) { export function getWorkflowInfo(data: WorkflowApi.WorkflowLogParams) {
return requestClient.get(`/v1/workflow/info/${data.appid}`, { params: data }); return requestClient.get(`/v1/workflow/info/${data.appid}`, { params: data });
} }

View File

@ -4,13 +4,13 @@ import { HugeAi, SvgPPT, SvgSpider, SvgWord } from '@vben/icons';
const routes: RouteRecordRaw[] = [ const routes: RouteRecordRaw[] = [
{ {
name: 'aiflow', name: 'ai',
path: '/aiflow', path: '/ai',
meta: { meta: {
icon: HugeAi, icon: HugeAi,
title: 'AI工作流', title: 'AI工作流',
order: 4, order: 4,
authority: ['system'], authority: ['ai'],
}, },
children: [ children: [
{ {
@ -21,7 +21,7 @@ const routes: RouteRecordRaw[] = [
icon: SvgSpider, icon: SvgSpider,
title: 'AI平台信息获取', title: 'AI平台信息获取',
order: 1, order: 1,
authority: ['dify:server:init'], authority: ['ai:spider'],
}, },
}, },
{ {
@ -32,7 +32,7 @@ const routes: RouteRecordRaw[] = [
icon: SvgWord, icon: SvgWord,
title: 'AI申报书WORD生成', title: 'AI申报书WORD生成',
order: 2, order: 2,
authority: ['dify:chat:send'], authority: ['ai:word'],
}, },
}, },
{ {
@ -41,9 +41,9 @@ const routes: RouteRecordRaw[] = [
component: () => import('#/views/ppt/index.vue'), component: () => import('#/views/ppt/index.vue'),
meta: { meta: {
icon: SvgPPT, icon: SvgPPT,
title: 'PPT自动生成', title: 'AI申报书PPT生成',
order: 3, order: 3,
authority: ['dify:workflow:run'], authority: ['ai:ppt'],
}, },
}, },
], ],

View File

@ -9,19 +9,19 @@ import { SvgPPT, SvgSpider, SvgWord } from '@vben/icons';
const items: WorkflowItem[] = [ const items: WorkflowItem[] = [
{ {
icon: SvgSpider, icon: SvgSpider,
title: '数据抓取工具', title: 'AI平台信息获取',
description: '自动抓取', description: '自动抓取',
path: '/ai/spider', path: '/ai/spider',
}, },
{ {
icon: SvgWord, icon: SvgWord,
title: 'Word文档生成工具', title: 'AI申报书WORD生成',
description: '自动生成word文档', description: '自动生成word文档',
path: '/ai/word', path: '/ai/word',
}, },
{ {
icon: SvgPPT, icon: SvgPPT,
title: 'PPT生成工具', title: 'AI申报书PPT生成',
description: '自动生成PPT文档', description: '自动生成PPT文档',
path: '/ai/ppt', path: '/ai/ppt',
}, },

View File

@ -7,7 +7,7 @@ import { PptListView, PptWorkView } from '@vben/common-ui';
import { notification } from 'ant-design-vue'; import { notification } from 'ant-design-vue';
import { getWorkflowInfo, getWorkflowList, sendWorkflow } from '#/api'; import { getWorkflowInfo, getWorkflowList, sendPpt } from '#/api';
let temp = reactive<PPTTempItem>({ let temp = reactive<PPTTempItem>({
id: 'ee3889b6-50fa-463e-b956-3b93447727fc', id: 'ee3889b6-50fa-463e-b956-3b93447727fc',
@ -84,7 +84,7 @@ onMounted(() => {
</div> </div>
<PptWorkView <PptWorkView
:item="temp" :item="temp"
:run-workflow="sendWorkflow" :run-workflow="sendPpt"
:item-message="itemMessage" :item-message="itemMessage"
/> />
</div> </div>

View File

@ -10,7 +10,7 @@ import {
getWorkflowInfo, getWorkflowInfo,
getWorkflowList, getWorkflowList,
runSpider, runSpider,
sendWorkflow, runSpiderGz,
stopSpider, stopSpider,
} from '#/api'; } from '#/api';
// sendWorkflow // sendWorkflow
@ -96,7 +96,7 @@ async function handleClickMode(item: TempItem) {
:run-spider="runSpider" :run-spider="runSpider"
:stop-spider="stopSpider" :stop-spider="stopSpider"
:get-spider-status="getSpiderStatus" :get-spider-status="getSpiderStatus"
:send-workflow="sendWorkflow" :run-spider-gz="runSpiderGz"
:item-message="itemMessage" :item-message="itemMessage"
/> />
</div> </div>

View File

@ -12,7 +12,7 @@ import {
getChatflowMessage, getChatflowMessage,
getChatList, getChatList,
getChatParameters, getChatParameters,
sendChatflow, sendWord,
} from '#/api'; } from '#/api';
interface ResultItem { interface ResultItem {
@ -133,7 +133,7 @@ onMounted(() => {
<WordWorkView <WordWorkView
:item="temp" :item="temp"
:params-data="params" :params-data="params"
:run-chatflow="sendChatflow" :run-chatflow="sendWord"
:item-message="itemMessage" :item-message="itemMessage"
/> />
</div> </div>

View File

@ -26,10 +26,6 @@ interface ResultItem {
footer?: any; footer?: any;
} }
interface WorkflowParams {
appid: string;
}
interface WorkflowContext { interface WorkflowContext {
userId: string; userId: string;
conversationId: string; conversationId: string;
@ -48,10 +44,7 @@ interface WorkflowResult {
interface Props { interface Props {
itemMessage?: ResultItem; itemMessage?: ResultItem;
item?: PPTTempItem; item?: PPTTempItem;
runWorkflow?: ( runWorkflow?: (context: WorkflowContext) => Promise<WorkflowResult>;
params: WorkflowParams,
context: WorkflowContext,
) => Promise<WorkflowResult>;
} }
defineOptions({ name: 'PlaygroundIndependentSetup' }); defineOptions({ name: 'PlaygroundIndependentSetup' });
@ -122,30 +115,6 @@ const fetchStatus = ref('');
const resultItems = ref<ResultItem[]>([]); const resultItems = ref<ResultItem[]>([]);
const fetchResult = 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({ const [PreviewDrawer, previewDrawerApi] = useVbenDrawer({
// //
connectedComponent: PptPreview, connectedComponent: PptPreview,
@ -188,19 +157,14 @@ const startFetching = async () => {
}); });
try { try {
const res = await props.runWorkflow( const res = await props.runWorkflow({
{ userId: '1562',
appid: 'ee3889b6-50fa-463e-b956-3b93447727fc', conversationId: '',
files: [],
inputs: {
declarationDoc: content.value,
}, },
{ });
userId: '1562',
conversationId: '',
files: [],
inputs: {
declarationDoc: content.value,
},
},
);
const { result } = res.data.outputs; const { result } = res.data.outputs;
content.value = ''; content.value = '';

View File

@ -30,10 +30,6 @@ import dayjs, { Dayjs } from 'dayjs';
import SpiderPreview from './spider-preview.vue'; import SpiderPreview from './spider-preview.vue';
interface SpiderParams {
appid: string;
}
interface SpiderContext { interface SpiderContext {
userId: string; userId: string;
conversationId: string; conversationId: string;
@ -67,7 +63,7 @@ interface Props {
stopSpider?: () => Promise<{ stopSpider?: () => Promise<{
status: string; status: string;
}>; }>;
sendWorkflow?: (params: SpiderParams, data: SpiderContext) => Promise<any>; runSpiderGz?: (data: SpiderContext) => Promise<any>;
} }
defineOptions({ defineOptions({
@ -93,7 +89,7 @@ const props = withDefaults(defineProps<Props>(), {
msg: '', msg: '',
code: '', code: '',
}), }),
sendWorkflow: () => async () => ({ runSpiderGz: () => async () => ({
outputs: { outputs: {
result: '', result: '',
files: [], files: [],
@ -272,17 +268,12 @@ const startFetching = async () => {
message: '正在获取中...', message: '正在获取中...',
duration: 3, duration: 3,
}); });
const res = await props.sendWorkflow( const res = await props.runSpiderGz({
{ userId: '1562',
appid: props.item.id, conversationId: '',
}, files: [],
{ inputs: {},
userId: '1562', });
conversationId: '',
files: [],
inputs: {},
},
);
if (res.data.outputs.files) { if (res.data.outputs.files) {
// //
fetchResult.value = res.data.outputs.files[0].url; fetchResult.value = res.data.outputs.files[0].url;

View File

@ -52,9 +52,6 @@ interface ResultItem {
content: string; content: string;
footer?: any; footer?: any;
} }
interface WorkflowParams {
appid: string;
}
interface WorkflowContext { interface WorkflowContext {
userId: string; userId: string;
conversationId: string; conversationId: string;
@ -77,10 +74,7 @@ interface Props {
itemMessage?: ResultItem; itemMessage?: ResultItem;
item?: WordTempItem; item?: WordTempItem;
paramsData?: {}; paramsData?: {};
runChatflow?: ( runChatflow?: (context: WorkflowContext) => Promise<WorkflowResult>;
params: WorkflowParams,
context: WorkflowContext,
) => Promise<WorkflowResult>;
} }
defineOptions({ name: 'PlaygroundIndependentSetup' }); defineOptions({ name: 'PlaygroundIndependentSetup' });
@ -295,24 +289,19 @@ const startFetching = async () => {
}); });
try { try {
const res = await props.runChatflow( const res = await props.runChatflow({
{ userId: '1562',
appid: 'baca08c1-e92b-4dc9-a445-3584803f54d4', conversationId: conversationId.value,
files: [],
inputs: {
projectName: projectInfo.value.projectName,
projectContext: projectInfo.value.projectContext,
keyAvoidTechOrKeyword: projectInfo.value.projectKeyAvoidTechOrKeyword,
userInitialInnovationPoint:
projectInfo.value.userInitialInnovationPoint,
}, },
{ content: content.value || '',
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.value = ''; content.value = '';
const { answer } = res; const { answer } = res;
conversationId.value = res.conversationId; conversationId.value = res.conversationId;