@@ -2,7 +2,8 @@ import { LLMModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
import {
|
||||
ChatCompletionCreateParamsNonStreaming,
|
||||
ChatCompletionCreateParamsStreaming,
|
||||
ChatCompletionMessageParam
|
||||
ChatCompletionMessageParam,
|
||||
StreamChatType
|
||||
} from '@fastgpt/global/core/ai/type';
|
||||
import { countGptMessagesTokens } from '../../common/string/tiktoken';
|
||||
import { getLLMModel } from './model';
|
||||
@@ -87,3 +88,12 @@ export const llmCompletionsBodyFormat = <T extends CompletionsBodyType>(
|
||||
|
||||
return requestBody as InferCompletionsBody<T>;
|
||||
};
|
||||
|
||||
export const llmStreamResponseToText = async (response: StreamChatType) => {
|
||||
let answer = '';
|
||||
for await (const part of response) {
|
||||
const content = part.choices?.[0]?.delta?.content || '';
|
||||
answer += content;
|
||||
}
|
||||
return answer;
|
||||
};
|
||||
|
||||
@@ -63,7 +63,7 @@ export const useRequest2 = <TData, TParams extends any[]>(
|
||||
...rest,
|
||||
onError: (err, params) => {
|
||||
rest?.onError?.(err, params);
|
||||
if (errorToast !== undefined) {
|
||||
if (errorToast !== '') {
|
||||
const errText = t(getErrText(err, errorToast || '') as any);
|
||||
if (errText) {
|
||||
toast({
|
||||
|
||||
@@ -93,10 +93,10 @@
|
||||
"code_error.team_error.org_parent_not_exist": "Parent organization does not exist",
|
||||
"code_error.team_error.over_size": "error.team.overSize",
|
||||
"code_error.team_error.plugin_amount_not_enough": "Plugin Limit Reached",
|
||||
"code_error.team_error.re_rank_not_enough": "Unauthorized to Use Re-Rank",
|
||||
"code_error.team_error.re_rank_not_enough": "Search rearrangement cannot be used in the free version~",
|
||||
"code_error.team_error.un_auth": "Unauthorized to Operate This Team",
|
||||
"code_error.team_error.user_not_active": "The user did not accept or has left the team",
|
||||
"code_error.team_error.website_sync_not_enough": "Unauthorized to Use Website Sync",
|
||||
"code_error.team_error.website_sync_not_enough": "The free version cannot be synchronized with the web site ~",
|
||||
"code_error.token_error_code.403": "Invalid Login Status, Please Re-login",
|
||||
"code_error.user_error.balance_not_enough": "Insufficient Account Balance",
|
||||
"code_error.user_error.bin_visitor_guest": "You Are Currently a Guest, Unauthorized to Operate",
|
||||
|
||||
@@ -97,10 +97,10 @@
|
||||
"code_error.team_error.org_parent_not_exist": "父部门不存在",
|
||||
"code_error.team_error.over_size": "error.team.overSize",
|
||||
"code_error.team_error.plugin_amount_not_enough": "插件数量已达上限~",
|
||||
"code_error.team_error.re_rank_not_enough": "无权使用检索重排~",
|
||||
"code_error.team_error.re_rank_not_enough": "免费版无法使用检索重排~",
|
||||
"code_error.team_error.un_auth": "无权操作该团队",
|
||||
"code_error.team_error.user_not_active": "用户未接受或已离开团队",
|
||||
"code_error.team_error.website_sync_not_enough": "无权使用Web站点同步~",
|
||||
"code_error.team_error.website_sync_not_enough": "免费版无法使用Web站点同步~",
|
||||
"code_error.token_error_code.403": "登录状态无效,请重新登录",
|
||||
"code_error.user_error.balance_not_enough": "账号余额不足~",
|
||||
"code_error.user_error.bin_visitor_guest": "您当前身份为游客,无权操作",
|
||||
|
||||
@@ -92,10 +92,10 @@
|
||||
"code_error.team_error.org_parent_not_exist": "父組織不存在",
|
||||
"code_error.team_error.over_size": "error.team.overSize",
|
||||
"code_error.team_error.plugin_amount_not_enough": "已達外掛程式數量上限",
|
||||
"code_error.team_error.re_rank_not_enough": "無權使用結果重新排名",
|
||||
"code_error.team_error.re_rank_not_enough": "免費版無法使用檢索重排~",
|
||||
"code_error.team_error.un_auth": "無權操作此團隊",
|
||||
"code_error.team_error.user_not_active": "使用者未接受或已離開團隊",
|
||||
"code_error.team_error.website_sync_not_enough": "無權使用網站同步",
|
||||
"code_error.team_error.website_sync_not_enough": "免費版無法使用Web站點同步~",
|
||||
"code_error.token_error_code.403": "登入狀態無效,請重新登入",
|
||||
"code_error.user_error.balance_not_enough": "帳戶餘額不足",
|
||||
"code_error.user_error.bin_visitor_guest": "您目前身份為訪客,無權操作",
|
||||
|
||||
Reference in New Issue
Block a user