diff --git a/client/public/docs/chatProblem.md b/client/public/docs/chatProblem.md index 1b4d7b3f7f..a7356f90c3 100644 --- a/client/public/docs/chatProblem.md +++ b/client/public/docs/chatProblem.md @@ -1,6 +1,7 @@ ### 常见问题 -**Git 地址**: [项目地址。V4-beta 暂为开源,在正式版发布后会开源。](https://github.com/c121914yu/FastGPT) +**反馈问卷**: 如果你遇到任何使用问题或有期望的功能,可以[填写该问卷](https://www.wjx.cn/vm/rLIw1uD.aspx#) +**Git 地址**: [项目地址。V4-preview 暂为开源,在正式版发布后会开源。](https://github.com/c121914yu/FastGPT) **问题文档**: [先看文档,再提问](https://kjqvjse66l.feishu.cn/docx/HtrgdT0pkonP4kxGx8qcu6XDnGh) **价格表** | 计费项 | 价格: 元/ 1K tokens(包含上下文)| diff --git a/client/public/docs/versionIntro.md b/client/public/docs/versionIntro.md index 77a2fb5313..971b918f80 100644 --- a/client/public/docs/versionIntro.md +++ b/client/public/docs/versionIntro.md @@ -1,12 +1,5 @@ -### Fast GPT V4.0-beta +### Fast GPT V4.0-preview -<<<<<<< HEAD -1. 新增 - 直接分段训练,可调节段落大小。 -2. 优化 - tokens 计算性能。 -3. 优化 - key 池管理,结合 one-api 项目,实现更方便的 key 池管理,具体参考[docker 部署 FastGpt](https://github.com/labring/FastGPT/blob/main/docs/deploy/docker.md) -4. 新增 - V2 版 OpenAPI,可以在任意第三方套壳 ChatGpt 项目中直接使用 FastGpt 的应用,注意!是直接,不需要改任何代码。具体参考[API 文档中《在第三方应用中使用 FastGpt》](https://kjqvjse66l.feishu.cn/docx/DmLedTWtUoNGX8xui9ocdUEjnNh) -======= 1. 全新交互,采用模块组合的方式构建知识库。 2. 问题分类 - 可以对用户的问题进行分类,再执行不同的操作。 3. beta 版本尚未稳定,请以测试为主。详细使用文档后续会补上。 ->>>>>>> 5f8a88d (flow chat) diff --git a/client/src/constants/kb.ts b/client/src/constants/kb.ts index 9a1e2c1ec3..8cf7b5a5c7 100644 --- a/client/src/constants/kb.ts +++ b/client/src/constants/kb.ts @@ -7,5 +7,6 @@ export const defaultKbDetail: KbItemType = { avatar: '/icon/logo.png', name: '', tags: '', - totalData: 0 + totalData: 0, + model: 'text-embedding-ada-002' }; diff --git a/client/src/hooks/useSendCode.ts b/client/src/hooks/useSendCode.ts index 4ef2a16497..ee43b5a314 100644 --- a/client/src/hooks/useSendCode.ts +++ b/client/src/hooks/useSendCode.ts @@ -4,12 +4,9 @@ import { UserAuthTypeEnum } from '@/constants/common'; let timer: any; import { useToast } from './useToast'; import { getClientToken } from '@/utils/plugin/google'; -import { useGlobalStore } from '@/store/global'; +import { googleVerKey } from '@/store/static'; export const useSendCode = () => { - const { - initData: { googleVerKey } - } = useGlobalStore(); const { toast } = useToast(); const [codeSending, setCodeSending] = useState(false); const [codeCountDown, setCodeCountDown] = useState(0); @@ -54,7 +51,7 @@ export const useSendCode = () => { } setCodeSending(false); }, - [googleVerKey, toast] + [toast] ); return { diff --git a/client/src/pages/api/openapi/text/sensitiveCheck.ts b/client/src/pages/api/openapi/text/sensitiveCheck.ts index 272e74746e..12842f3c34 100644 --- a/client/src/pages/api/openapi/text/sensitiveCheck.ts +++ b/client/src/pages/api/openapi/text/sensitiveCheck.ts @@ -3,7 +3,7 @@ import type { NextApiRequest, NextApiResponse } from 'next'; import { jsonRes } from '@/service/response'; import { authUser, getSystemOpenAiKey } from '@/service/utils/auth'; import axios from 'axios'; -import { axiosConfig } from '@/service/utils/tools'; +import { axiosConfig } from '@/service/ai/openai'; export type Props = { input: string; @@ -33,7 +33,7 @@ export async function sensitiveCheck({ input }: Props) { } const response = await axios({ - ...axiosConfig(getSystemOpenAiKey()), + ...axiosConfig(), method: 'POST', url: `/moderations`, data: { diff --git a/client/src/pages/api/system/updateEnv.ts b/client/src/pages/api/system/updateEnv.ts index 1576cf9bb0..5b0dd7bde6 100644 --- a/client/src/pages/api/system/updateEnv.ts +++ b/client/src/pages/api/system/updateEnv.ts @@ -17,6 +17,7 @@ export async function updateSystemEnv() { ...global.systemEnv, ...res }; + console.log(global.systemEnv); } catch (error) { console.log('update system env error'); } diff --git a/client/src/pages/app/detail/index.tsx b/client/src/pages/app/detail/index.tsx index 33feee472c..7f40c5849f 100644 --- a/client/src/pages/app/detail/index.tsx +++ b/client/src/pages/app/detail/index.tsx @@ -29,7 +29,7 @@ const AppDetail = ({ currentTab }: { currentTab: `${TabEnum}` }) => { const router = useRouter(); const theme = useTheme(); const { appId } = router.query as { appId: string }; - const { appDetail = defaultApp } = useUserStore(); + const { appDetail = defaultApp, clearAppModules } = useUserStore(); const setCurrentTab = useCallback( (tab: `${TabEnum}`) => { @@ -53,16 +53,17 @@ const AppDetail = ({ currentTab }: { currentTab: `${TabEnum}` }) => { [] ); - // useEffect(() => { - // window.onbeforeunload = (e) => { - // e.preventDefault(); - // e.returnValue = '内容已修改,确认离开页面吗?'; - // }; + useEffect(() => { + window.onbeforeunload = (e) => { + e.preventDefault(); + e.returnValue = '内容已修改,确认离开页面吗?'; + }; - // return () => { - // window.onbeforeunload = null; - // }; - // }, []); + return () => { + window.onbeforeunload = null; + clearAppModules(); + }; + }, []); return ( diff --git a/client/src/pages/kb/detail/components/Import/QA.tsx b/client/src/pages/kb/detail/components/Import/QA.tsx index f049ab3af6..e1202bb5f5 100644 --- a/client/src/pages/kb/detail/components/Import/QA.tsx +++ b/client/src/pages/kb/detail/components/Import/QA.tsx @@ -97,7 +97,6 @@ const QAImport = ({ kbId }: { kbId: string }) => { } return ''; })(); - console.log(extension, text, '=====', icon); if (icon && text) { const splitRes = splitText_token({ diff --git a/client/src/pages/login/components/RegisterForm.tsx b/client/src/pages/login/components/RegisterForm.tsx index c10a8f3252..15d8d6af2e 100644 --- a/client/src/pages/login/components/RegisterForm.tsx +++ b/client/src/pages/login/components/RegisterForm.tsx @@ -8,7 +8,7 @@ import type { ResLogin } from '@/api/response/user'; import { useToast } from '@/hooks/useToast'; import { useRouter } from 'next/router'; import { postCreateApp } from '@/api/app'; -import { chatAppDemo } from '@/constants/app'; +import { appTemplates } from '@/constants/flow/ModuleTemplate'; interface Props { loginSuccess: (e: ResLogin) => void; @@ -65,9 +65,12 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => { status: 'success' }); // aut register a model - postCreateApp({ - name: '应用1', - modules: chatAppDemo.modules + appTemplates.forEach((template) => { + postCreateApp({ + avatar: template.avatar, + name: template.name, + modules: template.modules + }); }); } catch (error: any) { toast({ diff --git a/client/src/service/ai/openai.ts b/client/src/service/ai/openai.ts index afd09e45d7..f4c20156c3 100644 --- a/client/src/service/ai/openai.ts +++ b/client/src/service/ai/openai.ts @@ -1,13 +1,15 @@ import { Configuration, OpenAIApi } from 'openai'; +const baseUrl = process.env.ONEAPI_URL || process.env.OPENAI_BASE_URL || 'api.openai.com'; + export const getSystemOpenAiKey = () => { - return process.env.ONEAPI_KEY || ''; + return process.env.ONEAPI_KEY || process.env.OPENAIKEY || ''; }; export const getOpenAIApi = () => { return new OpenAIApi( new Configuration({ - basePath: process.env.ONEAPI_URL + basePath: baseUrl }) ); }; @@ -15,7 +17,7 @@ export const getOpenAIApi = () => { /* openai axios config */ export const axiosConfig = () => { return { - baseURL: process.env.ONEAPI_URL, // 此处仅对非 npm 模块有效 + baseURL: baseUrl, // 此处仅对非 npm 模块有效 httpsAgent: global.httpsAgent, headers: { Authorization: `Bearer ${getSystemOpenAiKey()}`, diff --git a/client/src/service/events/generateQA.ts b/client/src/service/events/generateQA.ts index 4647703de0..7a4c286f06 100644 --- a/client/src/service/events/generateQA.ts +++ b/client/src/service/events/generateQA.ts @@ -1,9 +1,5 @@ import { TrainingData } from '@/service/mongo'; -import { OpenAiChatEnum } from '@/constants/model'; import { pushSplitDataBill } from '@/service/events/pushBill'; -import { openaiAccountError } from '../errorCode'; -import { ChatRoleEnum } from '@/constants/chat'; -import { BillSourceEnum } from '@/constants/user'; import { pushDataToKb } from '@/pages/api/openapi/kb/pushData'; import { TrainingModeEnum } from '@/constants/plugin'; import { ERROR_ENUM } from '../errorCode'; diff --git a/client/src/store/user.ts b/client/src/store/user.ts index 5f8891d2f5..1ee9f765b6 100644 --- a/client/src/store/user.ts +++ b/client/src/store/user.ts @@ -22,6 +22,7 @@ type State = { loadMyModels: () => Promise; appDetail: AppSchema; loadAppDetail: (id: string, init?: boolean) => Promise; + clearAppModules(): void; // kb myKbList: KbListItemType[]; loadKbList: () => Promise; @@ -78,6 +79,14 @@ export const useUserStore = create()( }); return res; }, + clearAppModules() { + set((state) => { + state.appDetail = { + ...state.appDetail, + modules: [] + }; + }); + }, myKbList: [], async loadKbList() { const res = await getKbList(); diff --git a/client/src/utils/plugin/google.ts b/client/src/utils/plugin/google.ts index d11daaf001..1e1e3788ef 100644 --- a/client/src/utils/plugin/google.ts +++ b/client/src/utils/plugin/google.ts @@ -2,11 +2,11 @@ import axios from 'axios'; import { Obj2Query } from '../tools'; export const getClientToken = (googleVerKey: string) => { - if (typeof grecaptcha === 'undefined' || !grecaptcha?.ready) return ''; + if (typeof window.grecaptcha === 'undefined' || !window.grecaptcha?.ready) return ''; return new Promise((resolve, reject) => { - grecaptcha.ready(async () => { + window.grecaptcha.ready(async () => { try { - const token = await grecaptcha.execute(googleVerKey, { + const token = await window.grecaptcha.execute(googleVerKey, { action: 'submit' }); resolve(token);