From 58cbf10c85740a6e27bccaaa5819fb0d847accb8 Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Wed, 19 Jul 2023 08:11:14 +0800 Subject: [PATCH] init --- client/public/docs/chatProblem.md | 2 +- client/src/constants/flow/ModuleTemplate.ts | 2 +- client/src/pages/api/admin/initv4.ts | 92 +++++++------------ client/src/pages/api/app/detail.tsx | 3 +- .../pages/api/openapi/v1/chat/completions.ts | 4 + .../detail/components/Import/FileSelect.tsx | 3 +- 6 files changed, 41 insertions(+), 65 deletions(-) diff --git a/client/public/docs/chatProblem.md b/client/public/docs/chatProblem.md index a7356f90c..8b5420961 100644 --- a/client/public/docs/chatProblem.md +++ b/client/public/docs/chatProblem.md @@ -1,7 +1,7 @@ ### 常见问题 **反馈问卷**: 如果你遇到任何使用问题或有期望的功能,可以[填写该问卷](https://www.wjx.cn/vm/rLIw1uD.aspx#) -**Git 地址**: [项目地址。V4-preview 暂为开源,在正式版发布后会开源。](https://github.com/c121914yu/FastGPT) +**Git 地址**: [项目地址。V4-preview 暂未开源,在正式版发布后会开源。](https://github.com/c121914yu/FastGPT) **问题文档**: [先看文档,再提问](https://kjqvjse66l.feishu.cn/docx/HtrgdT0pkonP4kxGx8qcu6XDnGh) **价格表** | 计费项 | 价格: 元/ 1K tokens(包含上下文)| diff --git a/client/src/constants/flow/ModuleTemplate.ts b/client/src/constants/flow/ModuleTemplate.ts index 3106f4488..b822a819b 100644 --- a/client/src/constants/flow/ModuleTemplate.ts +++ b/client/src/constants/flow/ModuleTemplate.ts @@ -162,7 +162,7 @@ export const ChatModule: AppModuleTemplateItemType = { '限定模型对话范围,会被放置在本次提问前,拥有强引导和限定性。例如:\n1. 知识库是关于 Laf 的介绍,参考知识库回答问题,与 "Laf" 无关内容,直接回复: "我不知道"。\n2. 你仅回答关于 "xxx" 的问题,其他问题回复: "xxxx"', value: '' }, - Input_Template_TFSwitch, + // Input_Template_TFSwitch, { key: 'quotePrompt', type: FlowInputItemTypeEnum.target, diff --git a/client/src/pages/api/admin/initv4.ts b/client/src/pages/api/admin/initv4.ts index 41b1da6f3..a1750866f 100644 --- a/client/src/pages/api/admin/initv4.ts +++ b/client/src/pages/api/admin/initv4.ts @@ -3,7 +3,6 @@ import type { NextApiRequest, NextApiResponse } from 'next'; import { jsonRes } from '@/service/response'; import { authUser } from '@/service/utils/auth'; import { connectToDatabase, App } from '@/service/mongo'; -import { rawSearchKey } from '@/constants/chat'; const chatTemplate = ({ model, @@ -84,7 +83,7 @@ const chatTemplate = ({ }, { key: 'temperature', - type: 'custom', + type: 'slider', label: '温度', value: temperature, min: 0, @@ -108,16 +107,16 @@ const chatTemplate = ({ label: '回复上限', value: maxToken, min: 100, - max: 16000, + max: 4000, step: 50, markList: [ { - label: '0', - value: 0 + label: '100', + value: 100 }, { - label: '16000', - value: 16000 + label: '4000', + value: 4000 } ], connected: false @@ -144,12 +143,6 @@ const chatTemplate = ({ value: limitPrompt, connected: false }, - { - key: 'switch', - type: 'target', - label: '触发器', - connected: false - }, { key: 'quotePrompt', type: 'target', @@ -284,8 +277,8 @@ const kbTemplate = ({ } ], position: { - x: -210.24817109253843, - y: 665.7922967022607 + x: -196.84632684738483, + y: 797.3401378431948 }, moduleId: 'v0nc1s' }, @@ -327,8 +320,8 @@ const kbTemplate = ({ } ], position: { - x: -196.84632684738483, - y: 797.3401378431948 + x: 211.58250540918442, + y: 611.8700401034965 }, moduleId: 'k9y3jm' }, @@ -345,25 +338,12 @@ const kbTemplate = ({ type: 'custom', label: '对话模型', value: model, - list: [ - { - label: 'FastAI-4k', - value: 'gpt-3.5-turbo' - }, - { - label: 'FastAI-16k', - value: 'gpt-3.5-turbo-16k' - }, - { - label: 'FastAI-Plus', - value: 'gpt-4' - } - ], + list: [], connected: false }, { key: 'temperature', - type: 'custom', + type: 'slider', label: '温度', value: temperature, min: 0, @@ -387,16 +367,16 @@ const kbTemplate = ({ label: '回复上限', value: maxToken, min: 100, - max: 16000, + max: 4000, step: 50, markList: [ { - label: '0', - value: 0 + label: '100', + value: 100 }, { - label: '16000', - value: 16000 + label: '4000', + value: 4000 } ], connected: false @@ -423,12 +403,6 @@ const kbTemplate = ({ value: limitPrompt, connected: false }, - { - key: 'switch', - type: 'target', - label: '触发器', - connected: true - }, { key: 'quotePrompt', type: 'target', @@ -481,7 +455,7 @@ const kbTemplate = ({ }, { key: 'similarity', - type: 'custom', + type: 'slider', label: '相似度', value: searchSimilarity, min: 0, @@ -489,8 +463,8 @@ const kbTemplate = ({ step: 0.01, markList: [ { - label: '0', - value: 0 + label: '100', + value: 100 }, { label: '1', @@ -501,7 +475,7 @@ const kbTemplate = ({ }, { key: 'limit', - type: 'custom', + type: 'slider', label: '单次搜索上限', description: '最多取 n 条记录作为本次问题引用', value: searchLimit, @@ -524,7 +498,7 @@ const kbTemplate = ({ key: 'switch', type: 'target', label: '触发器', - connected: true + connected: false }, { key: 'userChatInput', @@ -535,7 +509,7 @@ const kbTemplate = ({ ], outputs: [ { - key: rawSearchKey, + key: 'rawSearch', label: '源搜索数据', type: 'hidden', response: true, @@ -545,16 +519,14 @@ const kbTemplate = ({ key: 'isEmpty', label: '搜索结果为空', type: 'source', - targets: [ - ...(searchEmptyText - ? [ - { - moduleId: 'w8av9y', - key: 'switch' - } - ] - : []) - ] + targets: searchEmptyText + ? [ + { + moduleId: 'w8av9y', + key: 'switch' + } + ] + : [] }, { key: 'quotePrompt', @@ -593,7 +565,7 @@ const kbTemplate = ({ { key: 'answerText', value: searchEmptyText, - type: 'input', + type: 'textarea', label: '回复的内容', connected: false } diff --git a/client/src/pages/api/app/detail.tsx b/client/src/pages/api/app/detail.tsx index 2ef3f0319..24bdeb1af 100644 --- a/client/src/pages/api/app/detail.tsx +++ b/client/src/pages/api/app/detail.tsx @@ -20,8 +20,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse< const { app } = await authApp({ appId, - userId, - authOwner: false + userId }); jsonRes(res, { diff --git a/client/src/pages/api/openapi/v1/chat/completions.ts b/client/src/pages/api/openapi/v1/chat/completions.ts index 18007f384..127a09e3b 100644 --- a/client/src/pages/api/openapi/v1/chat/completions.ts +++ b/client/src/pages/api/openapi/v1/chat/completions.ts @@ -125,6 +125,10 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex billId }); + if (!answerText) { + throw new Error('回复内容为空,可能模块编排出现问题'); + } + // save chat if (typeof chatId === 'string') { await saveChat({ diff --git a/client/src/pages/kb/detail/components/Import/FileSelect.tsx b/client/src/pages/kb/detail/components/Import/FileSelect.tsx index f11d5e4a1..c1ef6be4d 100644 --- a/client/src/pages/kb/detail/components/Import/FileSelect.tsx +++ b/client/src/pages/kb/detail/components/Import/FileSelect.tsx @@ -34,7 +34,8 @@ const FileSelect = ({ fileExtension, onSelectFile, isLoading, ...props }: Props) > - 拖拽文件至此,或{' '} + {/* 拖拽文件至此,或{' '} */} + 点击 选择文件