This commit is contained in:
archer
2023-07-18 16:26:57 +08:00
parent 2330186a09
commit a993eba7f0
13 changed files with 45 additions and 42 deletions

View File

@@ -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包含上下文|

View File

@@ -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)

View File

@@ -7,5 +7,6 @@ export const defaultKbDetail: KbItemType = {
avatar: '/icon/logo.png',
name: '',
tags: '',
totalData: 0
totalData: 0,
model: 'text-embedding-ada-002'
};

View File

@@ -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 {

View File

@@ -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: {

View File

@@ -17,6 +17,7 @@ export async function updateSystemEnv() {
...global.systemEnv,
...res
};
console.log(global.systemEnv);
} catch (error) {
console.log('update system env error');
}

View File

@@ -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 (
<PageContainer>

View File

@@ -97,7 +97,6 @@ const QAImport = ({ kbId }: { kbId: string }) => {
}
return '';
})();
console.log(extension, text, '=====', icon);
if (icon && text) {
const splitRes = splitText_token({

View File

@@ -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({

View File

@@ -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()}`,

View File

@@ -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';

View File

@@ -22,6 +22,7 @@ type State = {
loadMyModels: () => Promise<null>;
appDetail: AppSchema;
loadAppDetail: (id: string, init?: boolean) => Promise<AppSchema>;
clearAppModules(): void;
// kb
myKbList: KbListItemType[];
loadKbList: () => Promise<any>;
@@ -78,6 +79,14 @@ export const useUserStore = create<State>()(
});
return res;
},
clearAppModules() {
set((state) => {
state.appDetail = {
...state.appDetail,
modules: []
};
});
},
myKbList: [],
async loadKbList() {
const res = await getKbList();

View File

@@ -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<string>((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);