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
bf2310cc
authored
Jul 26, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: chat source
parent
c06a9fb5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
27 deletions
+35
-27
client/src/pages/api/chat/history/getHistory.ts
+2
-0
client/src/pages/api/system/getInitData.ts
+33
-27
No files found.
client/src/pages/api/chat/history/getHistory.ts
View file @
bf2310cc
...
@@ -3,6 +3,7 @@ import { jsonRes } from '@/service/response';
...
@@ -3,6 +3,7 @@ import { jsonRes } from '@/service/response';
import
{
connectToDatabase
,
Chat
}
from
'@/service/mongo'
;
import
{
connectToDatabase
,
Chat
}
from
'@/service/mongo'
;
import
{
authUser
}
from
'@/service/utils/auth'
;
import
{
authUser
}
from
'@/service/utils/auth'
;
import
type
{
ChatHistoryItemType
}
from
'@/types/chat'
;
import
type
{
ChatHistoryItemType
}
from
'@/types/chat'
;
import
{
ChatSourceEnum
}
from
'@/constants/chat'
;
/* 获取历史记录 */
/* 获取历史记录 */
export
default
async
function
handler
(
req
:
NextApiRequest
,
res
:
NextApiResponse
)
{
export
default
async
function
handler
(
req
:
NextApiRequest
,
res
:
NextApiResponse
)
{
...
@@ -15,6 +16,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
...
@@ -15,6 +16,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const
data
=
await
Chat
.
find
(
const
data
=
await
Chat
.
find
(
{
{
userId
,
userId
,
source
:
ChatSourceEnum
.
online
,
...(
appId
&&
{
appId
})
...(
appId
&&
{
appId
})
},
},
'chatId title top customTitle appId updateTime'
'chatId title top customTitle appId updateTime'
...
...
client/src/pages/api/system/getInitData.ts
View file @
bf2310cc
...
@@ -31,30 +31,13 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
...
@@ -31,30 +31,13 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
});
});
}
}
export
async
function
getInitConfig
()
{
const
defaultSystemEnv
=
{
try
{
const
res
=
JSON
.
parse
(
readFileSync
(
'data/config.json'
,
'utf-8'
));
console
.
log
(
res
);
global
.
systemEnv
=
res
.
SystemParams
;
global
.
feConfigs
=
res
.
FeConfig
;
global
.
chatModels
=
res
.
ChatModels
;
global
.
qaModels
=
res
.
QAModels
;
global
.
vectorModels
=
res
.
VectorModels
;
}
catch
(
error
)
{
setDefaultData
();
return
Promise
.
reject
(
'get init config error'
);
}
}
export
function
setDefaultData
()
{
global
.
systemEnv
=
{
vectorMaxProcess
:
15
,
vectorMaxProcess
:
15
,
qaMaxProcess
:
15
,
qaMaxProcess
:
15
,
pgIvfflatProbe
:
20
,
pgIvfflatProbe
:
20
,
sensitiveCheck
:
false
sensitiveCheck
:
false
};
};
global
.
f
eConfigs
=
{
const
defaultF
eConfigs
=
{
show_emptyChat
:
true
,
show_emptyChat
:
true
,
show_register
:
true
,
show_register
:
true
,
show_appStore
:
true
,
show_appStore
:
true
,
...
@@ -62,8 +45,8 @@ export function setDefaultData() {
...
@@ -62,8 +45,8 @@ export function setDefaultData() {
show_git
:
true
,
show_git
:
true
,
systemTitle
:
'FastAI'
,
systemTitle
:
'FastAI'
,
authorText
:
'Made by FastAI Team.'
authorText
:
'Made by FastAI Team.'
};
};
global
.
c
hatModels
=
[
const
defaultC
hatModels
=
[
{
{
model
:
'gpt-3.5-turbo'
,
model
:
'gpt-3.5-turbo'
,
name
:
'FastAI-4k'
,
name
:
'FastAI-4k'
,
...
@@ -88,20 +71,43 @@ export function setDefaultData() {
...
@@ -88,20 +71,43 @@ export function setDefaultData() {
maxTemperature
:
1.2
,
maxTemperature
:
1.2
,
price
:
45
price
:
45
}
}
];
];
global
.
qa
Models
=
[
const
defaultQA
Models
=
[
{
{
model
:
'gpt-3.5-turbo-16k'
,
model
:
'gpt-3.5-turbo-16k'
,
name
:
'FastAI-16k'
,
name
:
'FastAI-16k'
,
maxToken
:
16000
,
maxToken
:
16000
,
price
:
3
price
:
3
}
}
];
];
global
.
v
ectorModels
=
[
const
defaultV
ectorModels
=
[
{
{
model
:
'text-embedding-ada-002'
,
model
:
'text-embedding-ada-002'
,
name
:
'Embedding-2'
,
name
:
'Embedding-2'
,
price
:
0.2
price
:
0.2
}
}
];
];
export
async
function
getInitConfig
()
{
try
{
const
res
=
JSON
.
parse
(
readFileSync
(
'data/config.json'
,
'utf-8'
));
console
.
log
(
res
);
global
.
systemEnv
=
res
.
SystemParams
||
defaultSystemEnv
;
global
.
feConfigs
=
res
.
FeConfig
||
defaultFeConfigs
;
global
.
chatModels
=
res
.
ChatModels
||
defaultChatModels
;
global
.
qaModels
=
res
.
QAModels
||
defaultQAModels
;
global
.
vectorModels
=
res
.
VectorModels
||
defaultVectorModels
;
}
catch
(
error
)
{
setDefaultData
();
return
Promise
.
reject
(
'get init config error'
);
}
}
export
function
setDefaultData
()
{
global
.
systemEnv
=
defaultSystemEnv
;
global
.
feConfigs
=
defaultFeConfigs
;
global
.
chatModels
=
defaultChatModels
;
global
.
qaModels
=
defaultQAModels
;
global
.
vectorModels
=
defaultVectorModels
;
}
}
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