Skip to content

Commit

Permalink
v4.5.1-2 (labring#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu committed Oct 23, 2023
1 parent d37433e commit bf6dbfb
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 38 deletions.
1 change: 1 addition & 0 deletions docSite/content/docs/installation/upgrading/451.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ curl --location --request POST 'https://{{host}}/api/admin/initv451' \
### Fast GPT V4.5.1

1. 新增知识库文件夹管理
2. 修复了 openai4.x sdk 无法兼容 oneapi 的智谱和阿里的接口。

2 changes: 1 addition & 1 deletion packages/service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"winston-mongodb": "^5.1.1",
"tunnel": "^0.0.6",
"encoding": "^0.1.13",
"openai": "^4.12.1"
"openai": "^4.12.4"
},
"devDependencies": {
"@types/tunnel": "^0.0.4",
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion projects/app/src/components/ChatBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export type ComponentRef = {
resetVariables: (data?: Record<string, any>) => void;
resetHistory: (history: ChatSiteItemType[]) => void;
scrollToBottom: (behavior?: 'smooth' | 'auto') => void;
sendPrompt: (question: string) => void;
};

enum FeedbackTypeEnum {
Expand Down Expand Up @@ -452,7 +453,8 @@ const ChatBox = (
setVariableInputFinish(!!e.length);
setChatHistory(e);
},
scrollToBottom
scrollToBottom,
sendPrompt: (question: string) => handleSubmit((item) => sendPrompt(item, question))()
}));

/* style start */
Expand Down
17 changes: 10 additions & 7 deletions projects/app/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,16 @@ function App({ Component, pageProps }: AppProps) {
// get init data
(async () => {
const {
feConfigs: { scripts }
feConfigs: { scripts, isPlus }
} = 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 || []);
})();
// add window error track
Expand All @@ -61,12 +69,7 @@ function App({ Component, pageProps }: AppProps) {
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 () => {
window.onerror = null;
};
Expand Down
13 changes: 11 additions & 2 deletions projects/app/src/pages/chat/share.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ const OutLink = ({
});

useEffect(() => {
setIdEmbed(window !== parent);
if (window !== top) {
window.top?.postMessage({ type: 'shareChatReady' }, '*');
}
setIdEmbed(window !== top);
}, []);

return (
Expand Down Expand Up @@ -280,7 +283,13 @@ export async function getServerSideProps(context: any) {
const authToken = context?.query?.authToken || '';

return {
props: { shareId, chatId, showHistory, authToken, ...(await serviceSideProps(context)) }
props: {
shareId,
chatId,
showHistory,
authToken,
...(await serviceSideProps(context))
}
};
}

Expand Down
2 changes: 1 addition & 1 deletion projects/app/src/service/core/dataset/data/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function hasSameValue({
const { rows: existsRows } = await PgClient.query(`
SELECT COUNT(*) > 0 AS exists
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;

Expand Down
42 changes: 24 additions & 18 deletions projects/app/src/service/moduleDispatch/chat/oneapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,30 @@ export const dispatchChatCompletion = async (props: ChatProps): Promise<ChatResp
temperature = Math.max(temperature, 0.01);
const ai = getAIApi(user.openaiAccount, 480000);

const response = await ai.chat.completions.create({
model,
temperature,
max_tokens,
stream,
messages: [
...(modelConstantsData.defaultSystemChatPrompt
? [
{
role: ChatCompletionRequestMessageRoleEnum.System,
content: modelConstantsData.defaultSystemChatPrompt
}
]
: []),
...messages
]
});
const response = await ai.chat.completions.create(
{
model,
temperature,
max_tokens,
stream,
messages: [
...(modelConstantsData.defaultSystemChatPrompt
? [
{
role: ChatCompletionRequestMessageRoleEnum.System,
content: modelConstantsData.defaultSystemChatPrompt
}
]
: []),
...messages
]
},
{
headers: {
Accept: 'application/json, text/plain, */*'
}
}
);

const { answerText, totalTokens, completeMessages } = await (async () => {
if (stream) {
Expand Down Expand Up @@ -355,7 +362,6 @@ async function streamResponse({
readStream: stream
});
let answer = '';

for await (const part of stream) {
if (res.closed) {
stream.controller?.abort();
Expand Down
16 changes: 9 additions & 7 deletions projects/app/src/service/moduleDispatch/tools/runApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ export const dispatchAppRequest = async (props: Record<string, any>): Promise<Re
return Promise.reject('App not found');
}

responseWrite({
res,
event: detail ? sseResponseEventEnum.answer : undefined,
data: textAdaptGptResponse({
text: '\n'
})
});
if (stream) {
responseWrite({
res,
event: detail ? sseResponseEventEnum.answer : undefined,
data: textAdaptGptResponse({
text: '\n'
})
});
}

const { responseData, answerText } = await dispatchModules({
res,
Expand Down

0 comments on commit bf6dbfb

Please sign in to comment.