ts
This commit is contained in:
parent
2330186a09
commit
a993eba7f0
@ -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)
|
**问题文档**: [先看文档,再提问](https://kjqvjse66l.feishu.cn/docx/HtrgdT0pkonP4kxGx8qcu6XDnGh)
|
||||||
**价格表**
|
**价格表**
|
||||||
| 计费项 | 价格: 元/ 1K tokens(包含上下文)|
|
| 计费项 | 价格: 元/ 1K tokens(包含上下文)|
|
||||||
|
|||||||
@ -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. 全新交互,采用模块组合的方式构建知识库。
|
1. 全新交互,采用模块组合的方式构建知识库。
|
||||||
2. 问题分类 - 可以对用户的问题进行分类,再执行不同的操作。
|
2. 问题分类 - 可以对用户的问题进行分类,再执行不同的操作。
|
||||||
3. beta 版本尚未稳定,请以测试为主。详细使用文档后续会补上。
|
3. beta 版本尚未稳定,请以测试为主。详细使用文档后续会补上。
|
||||||
>>>>>>> 5f8a88d (flow chat)
|
|
||||||
|
|||||||
@ -7,5 +7,6 @@ export const defaultKbDetail: KbItemType = {
|
|||||||
avatar: '/icon/logo.png',
|
avatar: '/icon/logo.png',
|
||||||
name: '',
|
name: '',
|
||||||
tags: '',
|
tags: '',
|
||||||
totalData: 0
|
totalData: 0,
|
||||||
|
model: 'text-embedding-ada-002'
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,12 +4,9 @@ import { UserAuthTypeEnum } from '@/constants/common';
|
|||||||
let timer: any;
|
let timer: any;
|
||||||
import { useToast } from './useToast';
|
import { useToast } from './useToast';
|
||||||
import { getClientToken } from '@/utils/plugin/google';
|
import { getClientToken } from '@/utils/plugin/google';
|
||||||
import { useGlobalStore } from '@/store/global';
|
import { googleVerKey } from '@/store/static';
|
||||||
|
|
||||||
export const useSendCode = () => {
|
export const useSendCode = () => {
|
||||||
const {
|
|
||||||
initData: { googleVerKey }
|
|
||||||
} = useGlobalStore();
|
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const [codeSending, setCodeSending] = useState(false);
|
const [codeSending, setCodeSending] = useState(false);
|
||||||
const [codeCountDown, setCodeCountDown] = useState(0);
|
const [codeCountDown, setCodeCountDown] = useState(0);
|
||||||
@ -54,7 +51,7 @@ export const useSendCode = () => {
|
|||||||
}
|
}
|
||||||
setCodeSending(false);
|
setCodeSending(false);
|
||||||
},
|
},
|
||||||
[googleVerKey, toast]
|
[toast]
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import type { NextApiRequest, NextApiResponse } from 'next';
|
|||||||
import { jsonRes } from '@/service/response';
|
import { jsonRes } from '@/service/response';
|
||||||
import { authUser, getSystemOpenAiKey } from '@/service/utils/auth';
|
import { authUser, getSystemOpenAiKey } from '@/service/utils/auth';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { axiosConfig } from '@/service/utils/tools';
|
import { axiosConfig } from '@/service/ai/openai';
|
||||||
|
|
||||||
export type Props = {
|
export type Props = {
|
||||||
input: string;
|
input: string;
|
||||||
@ -33,7 +33,7 @@ export async function sensitiveCheck({ input }: Props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const response = await axios({
|
const response = await axios({
|
||||||
...axiosConfig(getSystemOpenAiKey()),
|
...axiosConfig(),
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: `/moderations`,
|
url: `/moderations`,
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@ -17,6 +17,7 @@ export async function updateSystemEnv() {
|
|||||||
...global.systemEnv,
|
...global.systemEnv,
|
||||||
...res
|
...res
|
||||||
};
|
};
|
||||||
|
console.log(global.systemEnv);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('update system env error');
|
console.log('update system env error');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,7 @@ const AppDetail = ({ currentTab }: { currentTab: `${TabEnum}` }) => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { appId } = router.query as { appId: string };
|
const { appId } = router.query as { appId: string };
|
||||||
const { appDetail = defaultApp } = useUserStore();
|
const { appDetail = defaultApp, clearAppModules } = useUserStore();
|
||||||
|
|
||||||
const setCurrentTab = useCallback(
|
const setCurrentTab = useCallback(
|
||||||
(tab: `${TabEnum}`) => {
|
(tab: `${TabEnum}`) => {
|
||||||
@ -53,16 +53,17 @@ const AppDetail = ({ currentTab }: { currentTab: `${TabEnum}` }) => {
|
|||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
// useEffect(() => {
|
useEffect(() => {
|
||||||
// window.onbeforeunload = (e) => {
|
window.onbeforeunload = (e) => {
|
||||||
// e.preventDefault();
|
e.preventDefault();
|
||||||
// e.returnValue = '内容已修改,确认离开页面吗?';
|
e.returnValue = '内容已修改,确认离开页面吗?';
|
||||||
// };
|
};
|
||||||
|
|
||||||
// return () => {
|
return () => {
|
||||||
// window.onbeforeunload = null;
|
window.onbeforeunload = null;
|
||||||
// };
|
clearAppModules();
|
||||||
// }, []);
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageContainer>
|
<PageContainer>
|
||||||
|
|||||||
@ -97,7 +97,6 @@ const QAImport = ({ kbId }: { kbId: string }) => {
|
|||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
})();
|
})();
|
||||||
console.log(extension, text, '=====', icon);
|
|
||||||
|
|
||||||
if (icon && text) {
|
if (icon && text) {
|
||||||
const splitRes = splitText_token({
|
const splitRes = splitText_token({
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import type { ResLogin } from '@/api/response/user';
|
|||||||
import { useToast } from '@/hooks/useToast';
|
import { useToast } from '@/hooks/useToast';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import { postCreateApp } from '@/api/app';
|
import { postCreateApp } from '@/api/app';
|
||||||
import { chatAppDemo } from '@/constants/app';
|
import { appTemplates } from '@/constants/flow/ModuleTemplate';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
loginSuccess: (e: ResLogin) => void;
|
loginSuccess: (e: ResLogin) => void;
|
||||||
@ -65,9 +65,12 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
|
|||||||
status: 'success'
|
status: 'success'
|
||||||
});
|
});
|
||||||
// aut register a model
|
// aut register a model
|
||||||
postCreateApp({
|
appTemplates.forEach((template) => {
|
||||||
name: '应用1',
|
postCreateApp({
|
||||||
modules: chatAppDemo.modules
|
avatar: template.avatar,
|
||||||
|
name: template.name,
|
||||||
|
modules: template.modules
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
toast({
|
toast({
|
||||||
|
|||||||
@ -1,13 +1,15 @@
|
|||||||
import { Configuration, OpenAIApi } from 'openai';
|
import { Configuration, OpenAIApi } from 'openai';
|
||||||
|
|
||||||
|
const baseUrl = process.env.ONEAPI_URL || process.env.OPENAI_BASE_URL || 'api.openai.com';
|
||||||
|
|
||||||
export const getSystemOpenAiKey = () => {
|
export const getSystemOpenAiKey = () => {
|
||||||
return process.env.ONEAPI_KEY || '';
|
return process.env.ONEAPI_KEY || process.env.OPENAIKEY || '';
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getOpenAIApi = () => {
|
export const getOpenAIApi = () => {
|
||||||
return new OpenAIApi(
|
return new OpenAIApi(
|
||||||
new Configuration({
|
new Configuration({
|
||||||
basePath: process.env.ONEAPI_URL
|
basePath: baseUrl
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -15,7 +17,7 @@ export const getOpenAIApi = () => {
|
|||||||
/* openai axios config */
|
/* openai axios config */
|
||||||
export const axiosConfig = () => {
|
export const axiosConfig = () => {
|
||||||
return {
|
return {
|
||||||
baseURL: process.env.ONEAPI_URL, // 此处仅对非 npm 模块有效
|
baseURL: baseUrl, // 此处仅对非 npm 模块有效
|
||||||
httpsAgent: global.httpsAgent,
|
httpsAgent: global.httpsAgent,
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${getSystemOpenAiKey()}`,
|
Authorization: `Bearer ${getSystemOpenAiKey()}`,
|
||||||
|
|||||||
@ -1,9 +1,5 @@
|
|||||||
import { TrainingData } from '@/service/mongo';
|
import { TrainingData } from '@/service/mongo';
|
||||||
import { OpenAiChatEnum } from '@/constants/model';
|
|
||||||
import { pushSplitDataBill } from '@/service/events/pushBill';
|
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 { pushDataToKb } from '@/pages/api/openapi/kb/pushData';
|
||||||
import { TrainingModeEnum } from '@/constants/plugin';
|
import { TrainingModeEnum } from '@/constants/plugin';
|
||||||
import { ERROR_ENUM } from '../errorCode';
|
import { ERROR_ENUM } from '../errorCode';
|
||||||
|
|||||||
@ -22,6 +22,7 @@ type State = {
|
|||||||
loadMyModels: () => Promise<null>;
|
loadMyModels: () => Promise<null>;
|
||||||
appDetail: AppSchema;
|
appDetail: AppSchema;
|
||||||
loadAppDetail: (id: string, init?: boolean) => Promise<AppSchema>;
|
loadAppDetail: (id: string, init?: boolean) => Promise<AppSchema>;
|
||||||
|
clearAppModules(): void;
|
||||||
// kb
|
// kb
|
||||||
myKbList: KbListItemType[];
|
myKbList: KbListItemType[];
|
||||||
loadKbList: () => Promise<any>;
|
loadKbList: () => Promise<any>;
|
||||||
@ -78,6 +79,14 @@ export const useUserStore = create<State>()(
|
|||||||
});
|
});
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
|
clearAppModules() {
|
||||||
|
set((state) => {
|
||||||
|
state.appDetail = {
|
||||||
|
...state.appDetail,
|
||||||
|
modules: []
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
myKbList: [],
|
myKbList: [],
|
||||||
async loadKbList() {
|
async loadKbList() {
|
||||||
const res = await getKbList();
|
const res = await getKbList();
|
||||||
|
|||||||
@ -2,11 +2,11 @@ import axios from 'axios';
|
|||||||
import { Obj2Query } from '../tools';
|
import { Obj2Query } from '../tools';
|
||||||
|
|
||||||
export const getClientToken = (googleVerKey: string) => {
|
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) => {
|
return new Promise<string>((resolve, reject) => {
|
||||||
grecaptcha.ready(async () => {
|
window.grecaptcha.ready(async () => {
|
||||||
try {
|
try {
|
||||||
const token = await grecaptcha.execute(googleVerKey, {
|
const token = await window.grecaptcha.execute(googleVerKey, {
|
||||||
action: 'submit'
|
action: 'submit'
|
||||||
});
|
});
|
||||||
resolve(token);
|
resolve(token);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user