v4.5.1-2 (#421)
This commit is contained in:
parent
d37433eacd
commit
bf6dbfb245
@ -31,4 +31,5 @@ curl --location --request POST 'https://{{host}}/api/admin/initv451' \
|
|||||||
### Fast GPT V4.5.1
|
### Fast GPT V4.5.1
|
||||||
|
|
||||||
1. 新增知识库文件夹管理
|
1. 新增知识库文件夹管理
|
||||||
|
2. 修复了 openai4.x sdk 无法兼容 oneapi 的智谱和阿里的接口。
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
"winston-mongodb": "^5.1.1",
|
"winston-mongodb": "^5.1.1",
|
||||||
"tunnel": "^0.0.6",
|
"tunnel": "^0.0.6",
|
||||||
"encoding": "^0.1.13",
|
"encoding": "^0.1.13",
|
||||||
"openai": "^4.12.1"
|
"openai": "^4.12.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/tunnel": "^0.0.4",
|
"@types/tunnel": "^0.0.4",
|
||||||
|
|||||||
2
pnpm-lock.yaml
generated
2
pnpm-lock.yaml
generated
@ -76,7 +76,7 @@ importers:
|
|||||||
specifier: ^2.1.2
|
specifier: ^2.1.2
|
||||||
version: registry.npmmirror.com/nextjs-cors@2.1.2(next@13.5.2)
|
version: registry.npmmirror.com/nextjs-cors@2.1.2(next@13.5.2)
|
||||||
openai:
|
openai:
|
||||||
specifier: ^4.12.1
|
specifier: ^4.12.4
|
||||||
version: registry.npmmirror.com/openai@4.12.4(encoding@0.1.13)
|
version: registry.npmmirror.com/openai@4.12.4(encoding@0.1.13)
|
||||||
tunnel:
|
tunnel:
|
||||||
specifier: ^0.0.6
|
specifier: ^0.0.6
|
||||||
|
|||||||
@ -83,6 +83,7 @@ export type ComponentRef = {
|
|||||||
resetVariables: (data?: Record<string, any>) => void;
|
resetVariables: (data?: Record<string, any>) => void;
|
||||||
resetHistory: (history: ChatSiteItemType[]) => void;
|
resetHistory: (history: ChatSiteItemType[]) => void;
|
||||||
scrollToBottom: (behavior?: 'smooth' | 'auto') => void;
|
scrollToBottom: (behavior?: 'smooth' | 'auto') => void;
|
||||||
|
sendPrompt: (question: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum FeedbackTypeEnum {
|
enum FeedbackTypeEnum {
|
||||||
@ -452,7 +453,8 @@ const ChatBox = (
|
|||||||
setVariableInputFinish(!!e.length);
|
setVariableInputFinish(!!e.length);
|
||||||
setChatHistory(e);
|
setChatHistory(e);
|
||||||
},
|
},
|
||||||
scrollToBottom
|
scrollToBottom,
|
||||||
|
sendPrompt: (question: string) => handleSubmit((item) => sendPrompt(item, question))()
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/* style start */
|
/* style start */
|
||||||
|
|||||||
@ -45,8 +45,16 @@ function App({ Component, pageProps }: AppProps) {
|
|||||||
// get init data
|
// get init data
|
||||||
(async () => {
|
(async () => {
|
||||||
const {
|
const {
|
||||||
feConfigs: { scripts }
|
feConfigs: { scripts, isPlus }
|
||||||
} = await clientInitData();
|
} = await clientInitData();
|
||||||
|
|
||||||
|
// log fastgpt
|
||||||
|
!isPlus &&
|
||||||
|
console.log(
|
||||||
|
'%cWelcome to FastGPT',
|
||||||
|
'font-family:Arial; color:#3370ff ; font-size:18px; font-weight:bold;',
|
||||||
|
`GitHub:https://github.com/labring/FastGPT`
|
||||||
|
);
|
||||||
setScripts(scripts || []);
|
setScripts(scripts || []);
|
||||||
})();
|
})();
|
||||||
// add window error track
|
// add window error track
|
||||||
@ -61,12 +69,7 @@ function App({ Component, pageProps }: AppProps) {
|
|||||||
url
|
url
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
// log fastgpt
|
|
||||||
console.log(
|
|
||||||
'%cWelcome to FastGPT',
|
|
||||||
'font-family:Arial; color:#3370ff ; font-size:18px; font-weight:bold;',
|
|
||||||
`GitHub:https://github.com/labring/FastGPT`
|
|
||||||
);
|
|
||||||
return () => {
|
return () => {
|
||||||
window.onerror = null;
|
window.onerror = null;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -166,7 +166,10 @@ const OutLink = ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setIdEmbed(window !== parent);
|
if (window !== top) {
|
||||||
|
window.top?.postMessage({ type: 'shareChatReady' }, '*');
|
||||||
|
}
|
||||||
|
setIdEmbed(window !== top);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -280,7 +283,13 @@ export async function getServerSideProps(context: any) {
|
|||||||
const authToken = context?.query?.authToken || '';
|
const authToken = context?.query?.authToken || '';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: { shareId, chatId, showHistory, authToken, ...(await serviceSideProps(context)) }
|
props: {
|
||||||
|
shareId,
|
||||||
|
chatId,
|
||||||
|
showHistory,
|
||||||
|
authToken,
|
||||||
|
...(await serviceSideProps(context))
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@ export async function hasSameValue({
|
|||||||
const { rows: existsRows } = await PgClient.query(`
|
const { rows: existsRows } = await PgClient.query(`
|
||||||
SELECT COUNT(*) > 0 AS exists
|
SELECT COUNT(*) > 0 AS exists
|
||||||
FROM ${PgDatasetTableName}
|
FROM ${PgDatasetTableName}
|
||||||
WHERE md5(q)=md5('${q}') AND md5(a)=md5('${a}') collection_id='${collectionId}'
|
WHERE md5(q)=md5('${q}') AND md5(a)=md5('${a}') AND collection_id='${collectionId}'
|
||||||
`);
|
`);
|
||||||
const exists = existsRows[0]?.exists || false;
|
const exists = existsRows[0]?.exists || false;
|
||||||
|
|
||||||
|
|||||||
@ -110,7 +110,8 @@ export const dispatchChatCompletion = async (props: ChatProps): Promise<ChatResp
|
|||||||
temperature = Math.max(temperature, 0.01);
|
temperature = Math.max(temperature, 0.01);
|
||||||
const ai = getAIApi(user.openaiAccount, 480000);
|
const ai = getAIApi(user.openaiAccount, 480000);
|
||||||
|
|
||||||
const response = await ai.chat.completions.create({
|
const response = await ai.chat.completions.create(
|
||||||
|
{
|
||||||
model,
|
model,
|
||||||
temperature,
|
temperature,
|
||||||
max_tokens,
|
max_tokens,
|
||||||
@ -126,7 +127,13 @@ export const dispatchChatCompletion = async (props: ChatProps): Promise<ChatResp
|
|||||||
: []),
|
: []),
|
||||||
...messages
|
...messages
|
||||||
]
|
]
|
||||||
});
|
},
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/json, text/plain, */*'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const { answerText, totalTokens, completeMessages } = await (async () => {
|
const { answerText, totalTokens, completeMessages } = await (async () => {
|
||||||
if (stream) {
|
if (stream) {
|
||||||
@ -355,7 +362,6 @@ async function streamResponse({
|
|||||||
readStream: stream
|
readStream: stream
|
||||||
});
|
});
|
||||||
let answer = '';
|
let answer = '';
|
||||||
|
|
||||||
for await (const part of stream) {
|
for await (const part of stream) {
|
||||||
if (res.closed) {
|
if (res.closed) {
|
||||||
stream.controller?.abort();
|
stream.controller?.abort();
|
||||||
|
|||||||
@ -42,6 +42,7 @@ export const dispatchAppRequest = async (props: Record<string, any>): Promise<Re
|
|||||||
return Promise.reject('App not found');
|
return Promise.reject('App not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stream) {
|
||||||
responseWrite({
|
responseWrite({
|
||||||
res,
|
res,
|
||||||
event: detail ? sseResponseEventEnum.answer : undefined,
|
event: detail ? sseResponseEventEnum.answer : undefined,
|
||||||
@ -49,6 +50,7 @@ export const dispatchAppRequest = async (props: Record<string, any>): Promise<Re
|
|||||||
text: '\n'
|
text: '\n'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const { responseData, answerText } = await dispatchModules({
|
const { responseData, answerText } = await dispatchModules({
|
||||||
res,
|
res,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user