v4.6.4-Outlink (#589)

This commit is contained in:
Archer
2023-12-12 14:42:20 +08:00
committed by GitHub
parent d2d7eac9e0
commit e18c79ca71
79 changed files with 1094 additions and 762 deletions

View File

@@ -1,4 +1,5 @@
export type UpdateChatFeedbackProps = {
appId: string;
chatId: string;
chatItemId: string;
shareId?: string;

View File

@@ -12,8 +12,11 @@ export enum FlowNodeInputTypeEnum {
selectApp = 'selectApp',
// chat special input
aiSettings = 'aiSettings',
// maxToken = 'maxToken',
// model select
selectChatModel = 'selectChatModel',
selectCQModel = 'selectCQModel',
// dataset special input
selectDataset = 'selectDataset',
selectDatasetParamsModal = 'selectDatasetParamsModal',

View File

@@ -14,9 +14,13 @@ export const Input_Template_TFSwitch: FlowNodeInputItemType = {
export const Input_Template_History: FlowNodeInputItemType = {
key: ModuleInputKeyEnum.history,
type: FlowNodeInputTypeEnum.target,
type: FlowNodeInputTypeEnum.numberInput,
label: 'core.module.input.label.chat history',
required: true,
min: 0,
max: 30,
valueType: ModuleDataTypeEnum.chatHistory,
value: 6,
showTargetInApp: true,
showTargetInPlugin: true
};

View File

@@ -87,7 +87,6 @@ export const AiChatModule: FlowModuleTemplateType = {
type: FlowNodeInputTypeEnum.hidden,
label: '引用内容模板',
valueType: ModuleDataTypeEnum.string,
value: '',
showTargetInApp: false,
showTargetInPlugin: false
},
@@ -96,7 +95,6 @@ export const AiChatModule: FlowModuleTemplateType = {
type: FlowNodeInputTypeEnum.hidden,
label: '引用内容提示词',
valueType: ModuleDataTypeEnum.string,
value: '',
showTargetInApp: false,
showTargetInPlugin: false
},
@@ -104,7 +102,6 @@ export const AiChatModule: FlowModuleTemplateType = {
key: ModuleInputKeyEnum.aiChatSettingModal,
type: FlowNodeInputTypeEnum.aiSettings,
label: '',
connected: false,
valueType: ModuleDataTypeEnum.any,
showTargetInApp: false,
showTargetInPlugin: false
@@ -118,21 +115,19 @@ export const AiChatModule: FlowModuleTemplateType = {
valueType: ModuleDataTypeEnum.string,
description: chatNodeSystemPromptTip,
placeholder: chatNodeSystemPromptTip,
value: '',
showTargetInApp: true,
showTargetInPlugin: true
},
Input_Template_History,
{
key: ModuleInputKeyEnum.aiChatDatasetQuote,
type: FlowNodeInputTypeEnum.target,
label: '引用内容',
description: "对象数组格式,结构:\n [{q:'问题',a:'回答'}]",
valueType: ModuleDataTypeEnum.datasetQuote,
connected: false,
showTargetInApp: true,
showTargetInPlugin: true
},
Input_Template_History,
Input_Template_UserChatInput
],
outputs: [

View File

@@ -17,7 +17,6 @@ export const AssignedAnswerModule: FlowModuleTemplateType = {
key: ModuleInputKeyEnum.answerText,
type: FlowNodeInputTypeEnum.textarea,
valueType: ModuleDataTypeEnum.any,
value: '',
label: '回复的内容',
description:
'可以使用 \\n 来实现连续换行。\n\n可以通过外部模块输入实现回复外部模块输入时会覆盖当前填写的内容。\n\n如传入非字符串类型数据将会自动转成字符串',

View File

@@ -27,7 +27,7 @@ export const ClassifyQuestionModule: FlowModuleTemplateType = {
Input_Template_TFSwitch,
{
key: ModuleInputKeyEnum.aiModel,
type: FlowNodeInputTypeEnum.selectChatModel,
type: FlowNodeInputTypeEnum.selectCQModel,
valueType: ModuleDataTypeEnum.string,
label: '分类模型',
required: true,
@@ -38,7 +38,6 @@ export const ClassifyQuestionModule: FlowModuleTemplateType = {
key: ModuleInputKeyEnum.aiSystemPrompt,
type: FlowNodeInputTypeEnum.textarea,
valueType: ModuleDataTypeEnum.string,
value: '',
label: '背景知识',
description:
'你可以添加一些特定内容的介绍,从而更好的识别用户的问题类型。这个内容通常是给模型介绍一个它不知道的内容。',
@@ -57,15 +56,15 @@ export const ClassifyQuestionModule: FlowModuleTemplateType = {
value: [
{
value: '打招呼',
key: 'fasw'
key: 'wqre'
},
{
value: '关于 xxx 的问题',
key: 'fqsw'
key: 'sdfa'
},
{
value: '其他问题',
key: 'fesw'
key: 'agex'
}
],
showTargetInApp: false,
@@ -75,19 +74,19 @@ export const ClassifyQuestionModule: FlowModuleTemplateType = {
outputs: [
// custom output
{
key: 'fasw',
key: 'wqre',
label: '',
type: FlowNodeOutputTypeEnum.hidden,
targets: []
},
{
key: 'fqsw',
key: 'sdfa',
label: '',
type: FlowNodeOutputTypeEnum.hidden,
targets: []
},
{
key: 'fesw',
key: 'agex',
label: '',
type: FlowNodeOutputTypeEnum.hidden,
targets: []

View File

@@ -26,12 +26,11 @@ export const ContextExtractModule: FlowModuleTemplateType = {
key: ModuleInputKeyEnum.description,
type: FlowNodeInputTypeEnum.textarea,
valueType: ModuleDataTypeEnum.string,
value: '',
label: '提取要求描述',
description: '写一段提取要求,告诉 AI 需要提取哪些内容',
description: '给AI一些对应的背景知识或要求描述引导AI更好的完成任务',
required: true,
placeholder:
'例如: \n1. 你是一个实验室预约助手。根据用户问题,提取出姓名、实验室号和预约时间',
'例如: \n1. 你是一个实验室预约助手,你的任务是帮助用户预约实验室。\n2. 你是谷歌搜索助手,需要从文本中提取出合适的搜索词。',
showTargetInApp: true,
showTargetInPlugin: true
},

View File

@@ -74,7 +74,6 @@ export const DatasetSearchModule: FlowModuleTemplateType = {
key: ModuleInputKeyEnum.datasetParamsModal,
type: FlowNodeInputTypeEnum.selectDatasetParamsModal,
label: '',
connected: false,
valueType: ModuleDataTypeEnum.any,
showTargetInApp: false,
showTargetInPlugin: false

View File

@@ -11,7 +11,7 @@ export const HistoryModule: FlowModuleTemplateType = {
templateType: ModuleTemplateTypeEnum.systemInput,
flowType: FlowNodeTypeEnum.historyNode,
avatar: '/imgs/module/history.png',
name: '聊天记录',
name: '聊天记录(弃用)',
intro: '用户输入的内容。该模块通常作为应用的入口,用户在发送消息后会首先执行该模块。',
inputs: [
{

View File

@@ -16,7 +16,6 @@ export const HttpModule: FlowModuleTemplateType = {
Input_Template_TFSwitch,
{
key: ModuleInputKeyEnum.httpUrl,
value: '',
type: FlowNodeInputTypeEnum.input,
valueType: ModuleDataTypeEnum.string,
label: '请求地址',

View File

@@ -8,7 +8,7 @@
"encoding": "^0.1.13",
"js-tiktoken": "^1.0.7",
"node-html-markdown": "^1.3.0",
"openai": "^4.16.1",
"openai": "^4.20.1",
"timezones-list": "^3.0.2"
},
"devDependencies": {

View File

@@ -70,8 +70,9 @@ instance.interceptors.request.use(requestStart, (err) => Promise.reject(err));
instance.interceptors.response.use(responseSuccess, (err) => Promise.reject(err));
export function request(url: string, data: any, config: ConfigType, method: Method): any {
if (global.systemEnv && !global.systemEnv?.pluginBaseUrl) {
return Promise.reject('该功能为商业版特有...');
if (!global.systemEnv || !global.systemEnv?.pluginBaseUrl) {
console.log('未部署商业版接口');
return Promise.reject('The The request was denied...');
}
/* 去空 */

View File

@@ -14,7 +14,7 @@ export async function getChatItems({
return { history: [] };
}
const history = await MongoChatItem.find({ chatId }, field).sort({ _id: -1 }).limit(limit);
const history = await MongoChatItem.find({ chatId }, field).sort({ _id: -1 }).limit(limit).lean();
history.reverse();

View File

@@ -30,7 +30,7 @@ export const pushResult2Remote = async ({
shareId?: string;
responseData?: any[];
}) => {
if (!shareId || !outLinkUid || !global.systemEnv.pluginBaseUrl) return;
if (!shareId || !outLinkUid || !global.systemEnv?.pluginBaseUrl) return;
try {
const outLink = await MongoOutLink.findOne({
shareId