feat: agent and ui

This commit is contained in:
archer
2023-07-06 19:35:02 +08:00
parent 46f20c7dc3
commit 23642af6e2
44 changed files with 588 additions and 1148 deletions

View File

@@ -155,145 +155,145 @@ export const chatAppDemo: AppItemType = {
modules: [chatModule({ id: 'chat' })]
};
export const kbChatAppDemo: AppItemType = {
id: 'kbchat',
name: 'kbchat',
// 标记字段
modules: [
{
moduleId: 'kbsearch',
flowType: FlowModuleTypeEnum.kbSearchNode,
type: AppModuleItemTypeEnum.http,
url: '/openapi/modules/kb/search',
position: { x: -500, y: 0 },
inputs: [
{
key: 'kb_ids',
type: FlowInputItemTypeEnum.custom,
label: '关联的知识库',
value: ['646627f4f7b896cfd8910e38'],
list: []
},
// export const kbChatAppDemo: AppItemType = {
// id: 'kbchat',
// name: 'kbchat',
// // 标记字段
// modules: [
// {
// moduleId: 'kbsearch',
// flowType: FlowModuleTypeEnum.kbSearchNode,
// type: AppModuleItemTypeEnum.http,
// url: '/openapi/modules/kb/search',
// position: { x: -500, y: 0 },
// inputs: [
// {
// key: 'kb_ids',
// type: FlowInputItemTypeEnum.custom,
// label: '关联的知识库',
// value: ['646627f4f7b896cfd8910e38'],
// list: []
// },
{
key: 'similarity',
type: FlowInputItemTypeEnum.slider,
label: '相似度',
value: 0.8,
min: 0,
max: 1,
step: 0.01,
markList: [
{ label: '0', value: 0 },
{ label: '1', value: 1 }
]
},
{
key: 'limit',
type: FlowInputItemTypeEnum.slider,
label: '单次搜索上限',
value: 5,
min: 1,
max: 20,
step: 1,
markList: [
{ label: '1', value: 1 },
{ label: '20', value: 20 }
]
},
{
key: SystemInputEnum.history,
type: FlowInputItemTypeEnum.hidden,
label: '引用复用数量',
value: 1
},
{
key: SystemInputEnum.userChatInput,
type: FlowInputItemTypeEnum.none,
label: '用户输入(系统自动填写)',
description: ''
}
],
outputs: [
{
key: 'rawSearch',
label: '源搜索数据',
type: FlowOutputItemTypeEnum.none,
response: true,
targets: []
},
{
key: 'isEmpty',
label: '无搜索结果',
type: FlowOutputItemTypeEnum.source,
targets: [
{
moduleId: 'tfswitch',
key: SystemInputEnum.switch
}
]
},
{
key: 'quotePrompt',
label: '引用内容(字符串)',
type: FlowOutputItemTypeEnum.source,
targets: [
{
moduleId: 'chat',
key: 'quotePrompt'
}
]
}
]
},
{
moduleId: 'tfswitch',
type: AppModuleItemTypeEnum.switch,
flowType: FlowModuleTypeEnum.tfSwitchNode,
position: { x: 0, y: 510 },
inputs: [
{
key: SystemInputEnum.switch,
type: FlowInputItemTypeEnum.target,
label: '触发器',
connected: true
}
],
outputs: [
{
key: 'true',
label: '无搜索数据',
type: FlowOutputItemTypeEnum.source,
targets: [
{
moduleId: 'answer',
key: SystemInputEnum.switch
}
]
},
{
key: 'false',
label: '有搜索数据',
type: FlowOutputItemTypeEnum.source,
targets: [
{
moduleId: 'chat',
key: SystemInputEnum.switch
}
]
}
]
},
{
...chatModule({ id: 'chat', limitPrompt: '参考知识库内容进行回答', history: 5 }),
position: { x: 300, y: 240 }
},
{
...answerModule({ id: 'answer' }),
position: { x: 300, y: 0 }
}
]
};
// {
// key: 'similarity',
// type: FlowInputItemTypeEnum.slider,
// label: '相似度',
// value: 0.8,
// min: 0,
// max: 1,
// step: 0.01,
// markList: [
// { label: '0', value: 0 },
// { label: '1', value: 1 }
// ]
// },
// {
// key: 'limit',
// type: FlowInputItemTypeEnum.slider,
// label: '单次搜索上限',
// value: 5,
// min: 1,
// max: 20,
// step: 1,
// markList: [
// { label: '1', value: 1 },
// { label: '20', value: 20 }
// ]
// },
// {
// key: SystemInputEnum.history,
// type: FlowInputItemTypeEnum.hidden,
// label: '引用复用数量',
// value: 1
// },
// {
// key: SystemInputEnum.userChatInput,
// type: FlowInputItemTypeEnum.none,
// label: '用户输入(系统自动填写)',
// description: ''
// }
// ],
// outputs: [
// {
// key: 'rawSearch',
// label: '源搜索数据',
// type: FlowOutputItemTypeEnum.none,
// response: true,
// targets: []
// },
// {
// key: 'isEmpty',
// label: '无搜索结果',
// type: FlowOutputItemTypeEnum.source,
// targets: [
// {
// moduleId: 'tfswitch',
// key: SystemInputEnum.switch
// }
// ]
// },
// {
// key: 'quotePrompt',
// label: '引用内容(字符串)',
// type: FlowOutputItemTypeEnum.source,
// targets: [
// {
// moduleId: 'chat',
// key: 'quotePrompt'
// }
// ]
// }
// ]
// },
// {
// moduleId: 'tfswitch',
// type: AppModuleItemTypeEnum.switch,
// flowType: FlowModuleTypeEnum.tfSwitchNode,
// position: { x: 0, y: 510 },
// inputs: [
// {
// key: SystemInputEnum.switch,
// type: FlowInputItemTypeEnum.target,
// label: '触发器',
// connected: true
// }
// ],
// outputs: [
// {
// key: 'true',
// label: '无搜索数据',
// type: FlowOutputItemTypeEnum.source,
// targets: [
// {
// moduleId: 'answer',
// key: SystemInputEnum.switch
// }
// ]
// },
// {
// key: 'false',
// label: '有搜索数据',
// type: FlowOutputItemTypeEnum.source,
// targets: [
// {
// moduleId: 'chat',
// key: SystemInputEnum.switch
// }
// ]
// }
// ]
// },
// {
// ...chatModule({ id: 'chat', limitPrompt: '参考知识库内容进行回答', history: 5 }),
// position: { x: 300, y: 240 }
// },
// {
// ...answerModule({ id: 'answer' }),
// position: { x: 300, y: 0 }
// }
// ]
// };
// export const classifyQuestionDemo: AppItemType = {
// id: 'classifyQuestionDemo',

View File

@@ -25,4 +25,4 @@ export const ChatRoleMap = {
};
export const HUMAN_ICON = `https://fastgpt.run/icon/human.png`;
export const LOGO_ICON = `https://fastgpt.run/imgs/modelAvatar.png`;
export const LOGO_ICON = `https://fastgpt.run/icon/logo.png`;

View File

@@ -1,4 +1,4 @@
import { AppModuleItemTypeEnum, SystemInputEnum } from '../app';
import { AppModuleItemTypeEnum, SystemInputEnum, SpecificInputEnum } from '../app';
import { FlowModuleTypeEnum, FlowInputItemTypeEnum, FlowOutputItemTypeEnum } from './index';
import type { AppModuleTemplateItemType } from '@/types/app';
import { chatModelList } from '../data';
@@ -9,7 +9,7 @@ import {
} from './inputTemplate';
export const UserInputModule: AppModuleTemplateItemType = {
logo: '',
logo: '/imgs/module/userChatInput.png',
name: '用户问题',
intro: '用户输入的内容。该模块通常作为应用的入口,用户在发送消息后会首先执行该模块。',
type: AppModuleItemTypeEnum.initInput,
@@ -32,7 +32,7 @@ export const UserInputModule: AppModuleTemplateItemType = {
]
};
export const HistoryModule: AppModuleTemplateItemType = {
logo: '',
logo: '/imgs/module/history.png',
name: '聊天记录',
intro: '用户输入的内容。该模块通常作为应用的入口,用户在发送消息后会首先执行该模块。',
type: AppModuleItemTypeEnum.initInput,
@@ -64,7 +64,7 @@ export const HistoryModule: AppModuleTemplateItemType = {
};
export const ChatModule: AppModuleTemplateItemType = {
logo: '',
logo: '/imgs/module/AI.png',
name: 'AI 对话',
intro: 'OpenAI GPT 大模型对话。',
flowType: FlowModuleTypeEnum.chatNode,
@@ -135,7 +135,7 @@ export const ChatModule: AppModuleTemplateItemType = {
],
outputs: [
{
key: 'answer',
key: SpecificInputEnum.answerText,
label: '模型回复',
description: '直接响应,无需配置',
type: FlowOutputItemTypeEnum.hidden,
@@ -145,7 +145,7 @@ export const ChatModule: AppModuleTemplateItemType = {
};
export const KBSearchModule: AppModuleTemplateItemType = {
logo: '',
logo: '/imgs/module/db.png',
name: '知识库搜索',
intro: '去知识库中搜索对应的答案。可作为 AI 对话引用参考。',
flowType: FlowModuleTypeEnum.kbSearchNode,
@@ -205,7 +205,7 @@ export const KBSearchModule: AppModuleTemplateItemType = {
{
key: 'quotePrompt',
label: '引用内容',
description: '搜索结果为空时不触发',
description: '搜索结果为空时不返回',
type: FlowOutputItemTypeEnum.source,
targets: []
}
@@ -213,7 +213,7 @@ export const KBSearchModule: AppModuleTemplateItemType = {
};
export const AnswerModule: AppModuleTemplateItemType = {
logo: '',
logo: '/imgs/module/reply.png',
name: '指定回复',
intro: '该模块可以直接回复一段指定的内容。常用于引导、提示。',
type: AppModuleItemTypeEnum.answer,
@@ -221,7 +221,7 @@ export const AnswerModule: AppModuleTemplateItemType = {
inputs: [
Input_Template_TFSwitch,
{
key: 'answerText',
key: SpecificInputEnum.answerText,
value: '',
type: FlowInputItemTypeEnum.input,
label: '回复的内容'
@@ -257,31 +257,52 @@ export const TFSwitchModule: AppModuleTemplateItemType = {
}
]
};
export const ClassifyQuestionModule: AppModuleTemplateItemType = {
logo: '',
logo: '/imgs/module/cq.png',
name: '意图识别',
intro: '可以判断用户问题属于哪方面问题,从而执行不同的操作。',
type: AppModuleItemTypeEnum.switch,
flowType: FlowModuleTypeEnum.tfSwitchNode,
type: AppModuleItemTypeEnum.http,
url: '/openapi/modules/agent/classifyQuestion',
flowType: FlowModuleTypeEnum.classifyQuestionNode,
inputs: [
{
key: SystemInputEnum.switch,
type: FlowInputItemTypeEnum.target,
label: '输入'
key: 'systemPrompt',
type: FlowInputItemTypeEnum.textarea,
label: '系统提示词',
description:
'你可以添加一些特定内容的介绍,从而更好的识别用户的问题类型。这个内容通常是给模型介绍一个它不知道的内容。',
placeholder: '例如: \n1. Laf 是一个云函数开发平台……\n2. Sealos 是一个集群操作系统',
value: ''
},
Input_Template_History,
Input_Template_UserChatInput,
{
key: 'agents',
type: FlowInputItemTypeEnum.custom,
label: '',
value: [
{
value: '',
key: 'a'
},
{
value: '',
key: 'b'
}
]
}
],
outputs: [
{
key: 'true',
label: 'True',
type: FlowOutputItemTypeEnum.source,
key: 'a',
label: '',
type: FlowOutputItemTypeEnum.hidden,
targets: []
},
{
key: 'false',
label: 'False',
type: FlowOutputItemTypeEnum.source,
key: 'b',
label: '',
type: FlowOutputItemTypeEnum.hidden,
targets: []
}
]
@@ -302,7 +323,7 @@ export const ModuleTemplates = [
},
{
label: '工具',
list: [AnswerModule, TFSwitchModule]
list: [AnswerModule]
},
{
label: 'Agent',

View File

@@ -24,7 +24,8 @@ export enum FlowModuleTypeEnum {
chatNode = 'chatNode',
kbSearchNode = 'kbSearchNode',
tfSwitchNode = 'tfSwitchNode',
answerNode = 'answerNode'
answerNode = 'answerNode',
classifyQuestionNode = 'classifyQuestionNode'
}
export const edgeOptions = {

View File

@@ -202,6 +202,16 @@ const Select = selectMultiStyle({
}
});
const Tooltip = defineStyleConfig({
baseStyle: {
p: 3,
bg: 'white',
color: 'blackAlpha.800',
borderRadius: '8px',
boxShadow: '1px 1px 10px rgba(0,0,0,0.2)'
}
});
// 全局主题
export const theme = extendTheme({
styles: {
@@ -297,6 +307,7 @@ export const theme = extendTheme({
Textarea,
Switch,
Select,
Tooltip,
NumberInput
}
});