feat(@vben/common-ui): 更新 AI 模块路由、API 和视图
This commit is contained in:
parent
24e2f29203
commit
9ab254b9fb
@ -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,
|
||||
|
@ -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`);
|
||||
}
|
||||
|
@ -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 });
|
||||
}
|
||||
|
@ -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'],
|
||||
},
|
||||
},
|
||||
],
|
||||
|
@ -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',
|
||||
},
|
||||
|
@ -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<PPTTempItem>({
|
||||
id: 'ee3889b6-50fa-463e-b956-3b93447727fc',
|
||||
@ -84,7 +84,7 @@ onMounted(() => {
|
||||
</div>
|
||||
<PptWorkView
|
||||
:item="temp"
|
||||
:run-workflow="sendWorkflow"
|
||||
:run-workflow="sendPpt"
|
||||
:item-message="itemMessage"
|
||||
/>
|
||||
</div>
|
||||
|
@ -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"
|
||||
/>
|
||||
</div>
|
||||
|
@ -12,7 +12,7 @@ import {
|
||||
getChatflowMessage,
|
||||
getChatList,
|
||||
getChatParameters,
|
||||
sendChatflow,
|
||||
sendWord,
|
||||
} from '#/api';
|
||||
|
||||
interface ResultItem {
|
||||
@ -133,7 +133,7 @@ onMounted(() => {
|
||||
<WordWorkView
|
||||
:item="temp"
|
||||
:params-data="params"
|
||||
:run-chatflow="sendChatflow"
|
||||
:run-chatflow="sendWord"
|
||||
:item-message="itemMessage"
|
||||
/>
|
||||
</div>
|
||||
|
@ -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<WorkflowResult>;
|
||||
runWorkflow?: (context: WorkflowContext) => Promise<WorkflowResult>;
|
||||
}
|
||||
|
||||
defineOptions({ name: 'PlaygroundIndependentSetup' });
|
||||
@ -122,30 +115,6 @@ const fetchStatus = ref('');
|
||||
const resultItems = ref<ResultItem[]>([]);
|
||||
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 = '';
|
||||
|
||||
|
@ -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<any>;
|
||||
runSpiderGz?: (data: SpiderContext) => Promise<any>;
|
||||
}
|
||||
|
||||
defineOptions({
|
||||
@ -93,7 +89,7 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
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;
|
||||
|
@ -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<WorkflowResult>;
|
||||
runChatflow?: (context: WorkflowContext) => Promise<WorkflowResult>;
|
||||
}
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user