Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
a993eba7
authored
Jul 18, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ts
parent
2330186a
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
45 additions
and
42 deletions
+45
-42
client/public/docs/chatProblem.md
+2
-1
client/public/docs/versionIntro.md
+1
-8
client/src/constants/kb.ts
+2
-1
client/src/hooks/useSendCode.ts
+2
-5
client/src/pages/api/openapi/text/sensitiveCheck.ts
+2
-2
client/src/pages/api/system/updateEnv.ts
+1
-0
client/src/pages/app/detail/index.tsx
+11
-10
client/src/pages/kb/detail/components/Import/QA.tsx
+0
-1
client/src/pages/login/components/RegisterForm.tsx
+7
-4
client/src/service/ai/openai.ts
+5
-3
client/src/service/events/generateQA.ts
+0
-4
client/src/store/user.ts
+9
-0
client/src/utils/plugin/google.ts
+3
-3
No files found.
client/public/docs/chatProblem.md
View file @
a993eba7
### 常见问题
### 常见问题
**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(包含上下文)|
...
...
client/public/docs/versionIntro.md
View file @
a993eba7
### 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)
client/src/constants/kb.ts
View file @
a993eba7
...
@@ -7,5 +7,6 @@ export const defaultKbDetail: KbItemType = {
...
@@ -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'
};
};
client/src/hooks/useSendCode.ts
View file @
a993eba7
...
@@ -4,12 +4,9 @@ import { UserAuthTypeEnum } from '@/constants/common';
...
@@ -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 = () => {
...
@@ -54,7 +51,7 @@ export const useSendCode = () => {
}
}
setCodeSending
(
false
);
setCodeSending
(
false
);
},
},
[
googleVerKey
,
toast
]
[
toast
]
);
);
return
{
return
{
...
...
client/src/pages/api/openapi/text/sensitiveCheck.ts
View file @
a993eba7
...
@@ -3,7 +3,7 @@ import type { NextApiRequest, NextApiResponse } from 'next';
...
@@ -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) {
...
@@ -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
:
{
...
...
client/src/pages/api/system/updateEnv.ts
View file @
a993eba7
...
@@ -17,6 +17,7 @@ export async function updateSystemEnv() {
...
@@ -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'
);
}
}
...
...
client/src/pages/app/detail/index.tsx
View file @
a993eba7
...
@@ -29,7 +29,7 @@ const AppDetail = ({ currentTab }: { currentTab: `${TabEnum}` }) => {
...
@@ -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}` }) => {
...
@@ -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
>
...
...
client/src/pages/kb/detail/components/Import/QA.tsx
View file @
a993eba7
...
@@ -97,7 +97,6 @@ const QAImport = ({ kbId }: { kbId: string }) => {
...
@@ -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
({
...
...
client/src/pages/login/components/RegisterForm.tsx
View file @
a993eba7
...
@@ -8,7 +8,7 @@ import type { ResLogin } from '@/api/response/user';
...
@@ -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) => {
...
@@ -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
({
...
...
client/src/service/ai/openai.ts
View file @
a993eba7
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 = () => {
...
@@ -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
()}
`
,
...
...
client/src/service/events/generateQA.ts
View file @
a993eba7
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'
;
...
...
client/src/store/user.ts
View file @
a993eba7
...
@@ -22,6 +22,7 @@ type State = {
...
@@ -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>()(
...
@@ -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
();
...
...
client/src/utils/plugin/google.ts
View file @
a993eba7
...
@@ -2,11 +2,11 @@ import axios from 'axios';
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment