feat: markdown extension (#3663)

* feat: markdown extension

* media cros

* rerank test

* default price

* perf: default model

* fix: cannot custom provider

* fix: default model select

* update bg

* perf: default model selector

* fix: usage export

* i18n

* fix: rerank

* update init extension

* perf: ip limit check

* doubao model order

* web default modle

* perf: tts selector

* perf: tts error

* qrcode package
This commit is contained in:
Archer 2025-01-24 23:42:04 +08:00 committed by GitHub
parent 02fcb6a61e
commit d2948d7e57
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
49 changed files with 672 additions and 290 deletions

View File

@ -32,5 +32,6 @@ curl --location --request POST 'https://{{host}}/api/admin/initv4820' \
1. 新增 - 可视化模型参数配置。预设超过 100 个模型配置。同时支持所有类型模型的一键测试。(预计下个版本会完全支持在页面上配置渠道)。
2. 新增 - 使用记录导出和仪表盘。
3. 优化 - 页面组件抽离,减少页面组件路由。
4. 优化 - 全文检索,忽略大小写。
3. 新增 - markdown 语法扩展,支持音视频(代码块 audio 和 video
4. 优化 - 页面组件抽离,减少页面组件路由。
5. 优化 - 全文检索,忽略大小写。

View File

@ -1,6 +1,5 @@
import { ApiRequestProps } from '../../type/next';
import requestIp from 'request-ip';
import { ERROR_ENUM } from '@fastgpt/global/common/error/errorCode';
import { authFrequencyLimit } from '../system/frequencyLimit/utils';
import { addSeconds } from 'date-fns';
import { NextApiResponse } from 'next';
@ -9,7 +8,17 @@ import { jsonRes } from '../response';
// unit: times/s
// how to use?
// export default NextAPI(useQPSLimit(10), handler); // limit 10 times per second for a ip
export function useIPFrequencyLimit(seconds: number, limit: number, force = false) {
export function useIPFrequencyLimit({
id,
seconds,
limit,
force = false
}: {
id: string;
seconds: number;
limit: number;
force?: boolean;
}) {
return async (req: ApiRequestProps, res: NextApiResponse) => {
const ip = requestIp.getClientIp(req);
if (!ip || (process.env.USE_IP_LIMIT !== 'true' && !force)) {
@ -17,14 +26,14 @@ export function useIPFrequencyLimit(seconds: number, limit: number, force = fals
}
try {
await authFrequencyLimit({
eventId: 'ip-qps-limit' + ip,
eventId: `ip-qps-limit-${id}-` + ip,
maxAmount: limit,
expiredTime: addSeconds(new Date(), seconds)
});
} catch (_) {
jsonRes(res, {
code: 429,
error: ERROR_ENUM.tooManyRequest
error: `Too many request, request ${limit} times every ${seconds} seconds`
});
}
};

View File

@ -33,7 +33,15 @@ export const jsonRes = <T = any>(
addLog.error(`Api response error: ${url}`, ERROR_RESPONSE[errResponseKey]);
return res.status(code).json(ERROR_RESPONSE[errResponseKey]);
res.status(code);
if (message) {
res.send(message);
} else {
res.json(ERROR_RESPONSE[errResponseKey]);
}
return;
}
// another error

View File

@ -2,11 +2,11 @@
"provider": "Doubao",
"list": [
{
"model": "Doubao-lite-128k",
"name": "Doubao-lite-128k",
"maxContext": 128000,
"model": "Doubao-lite-4k",
"name": "Doubao-lite-4k",
"maxContext": 4000,
"maxResponse": 4000,
"quoteMaxToken": 120000,
"quoteMaxToken": 4000,
"maxTemperature": 1,
"vision": false,
"toolChoice": true,
@ -46,11 +46,11 @@
"type": "llm"
},
{
"model": "Doubao-lite-4k",
"name": "Doubao-lite-4k",
"maxContext": 4000,
"model": "Doubao-lite-128k",
"name": "Doubao-lite-128k",
"maxContext": 128000,
"maxResponse": 4000,
"quoteMaxToken": 4000,
"quoteMaxToken": 120000,
"maxTemperature": 1,
"vision": false,
"toolChoice": true,
@ -68,11 +68,33 @@
"type": "llm"
},
{
"model": "Doubao-pro-128k",
"name": "Doubao-pro-128k",
"maxContext": 128000,
"model": "Doubao-vision-lite-32k",
"name": "Doubao-vision-lite-32k",
"maxContext": 32000,
"maxResponse": 4000,
"quoteMaxToken": 120000,
"quoteMaxToken": 32000,
"maxTemperature": 1,
"vision": true,
"toolChoice": false,
"functionCall": false,
"defaultSystemChatPrompt": "",
"datasetProcess": true,
"usedInClassify": true,
"customCQPrompt": "",
"usedInExtractFields": true,
"usedInQueryExtension": true,
"customExtractPrompt": "",
"usedInToolCall": true,
"defaultConfig": {},
"fieldMap": {},
"type": "llm"
},
{
"model": "Doubao-pro-4k",
"name": "Doubao-pro-4k",
"maxContext": 4000,
"maxResponse": 4000,
"quoteMaxToken": 4000,
"maxTemperature": 1,
"vision": false,
"toolChoice": true,
@ -112,11 +134,11 @@
"type": "llm"
},
{
"model": "Doubao-pro-4k",
"name": "Doubao-pro-4k",
"maxContext": 4000,
"model": "Doubao-pro-128k",
"name": "Doubao-pro-128k",
"maxContext": 128000,
"maxResponse": 4000,
"quoteMaxToken": 4000,
"quoteMaxToken": 120000,
"maxTemperature": 1,
"vision": false,
"toolChoice": true,
@ -133,28 +155,6 @@
"fieldMap": {},
"type": "llm"
},
{
"model": "Doubao-vision-lite-32k",
"name": "Doubao-vision-lite-32k",
"maxContext": 32000,
"maxResponse": 4000,
"quoteMaxToken": 32000,
"maxTemperature": 1,
"vision": true,
"toolChoice": false,
"functionCall": false,
"defaultSystemChatPrompt": "",
"datasetProcess": true,
"usedInClassify": true,
"customCQPrompt": "",
"usedInExtractFields": true,
"usedInQueryExtension": true,
"customExtractPrompt": "",
"usedInToolCall": true,
"defaultConfig": {},
"fieldMap": {},
"type": "llm"
},
{
"model": "Doubao-vision-pro-32k",
"name": "Doubao-vision-pro-32k",
@ -192,4 +192,4 @@
"type": "embedding"
}
]
}
}

View File

@ -47,194 +47,194 @@
},
{
"model": "speech-01-turbo",
"name": "Minimax-speech-01-turbo",
"name": "speech-01-turbo",
"voices": [
{
"label": "minimax-male-qn-qingse",
"label": "male-qn-qingse",
"value": "male-qn-qingse"
},
{
"label": "minimax-male-qn-jingying",
"label": "male-qn-jingying",
"value": "male-qn-jingying"
},
{
"label": "minimax-male-qn-badao",
"label": "male-qn-badao",
"value": "male-qn-badao"
},
{
"label": "minimax-male-qn-daxuesheng",
"label": "male-qn-daxuesheng",
"value": "male-qn-daxuesheng"
},
{
"label": "minimax-female-shaonv",
"label": "female-shaonv",
"value": "female-shaonv"
},
{
"label": "minimax-female-yujie",
"label": "female-yujie",
"value": "female-yujie"
},
{
"label": "minimax-female-chengshu",
"label": "female-chengshu",
"value": "female-chengshu"
},
{
"label": "minimax-female-tianmei",
"label": "female-tianmei",
"value": "female-tianmei"
},
{
"label": "minimax-presenter_male",
"label": "presenter_male",
"value": "presenter_male"
},
{
"label": "minimax-presenter_female",
"label": "presenter_female",
"value": "presenter_female"
},
{
"label": "minimax-audiobook_male_1",
"label": "audiobook_male_1",
"value": "audiobook_male_1"
},
{
"label": "minimax-audiobook_male_2",
"label": "audiobook_male_2",
"value": "audiobook_male_2"
},
{
"label": "minimax-audiobook_female_1",
"label": "audiobook_female_1",
"value": "audiobook_female_1"
},
{
"label": "minimax-audiobook_female_2",
"label": "audiobook_female_2",
"value": "audiobook_female_2"
},
{
"label": "minimax-male-qn-qingse-jingpin",
"label": "male-qn-qingse-jingpin",
"value": "male-qn-qingse-jingpin"
},
{
"label": "minimax-male-qn-jingying-jingpin",
"label": "male-qn-jingying-jingpin",
"value": "male-qn-jingying-jingpin"
},
{
"label": "minimax-male-qn-badao-jingpin",
"label": "male-qn-badao-jingpin",
"value": "male-qn-badao-jingpin"
},
{
"label": "minimax-male-qn-daxuesheng-jingpin",
"label": "male-qn-daxuesheng-jingpin",
"value": "male-qn-daxuesheng-jingpin"
},
{
"label": "minimax-female-shaonv-jingpin",
"label": "female-shaonv-jingpin",
"value": "female-shaonv-jingpin"
},
{
"label": "minimax-female-yujie-jingpin",
"label": "female-yujie-jingpin",
"value": "female-yujie-jingpin"
},
{
"label": "minimax-female-chengshu-jingpin",
"label": "female-chengshu-jingpin",
"value": "female-chengshu-jingpin"
},
{
"label": "minimax-female-tianmei-jingpin",
"label": "female-tianmei-jingpin",
"value": "female-tianmei-jingpin"
},
{
"label": "minimax-clever_boy",
"label": "clever_boy",
"value": "clever_boy"
},
{
"label": "minimax-cute_boy",
"label": "cute_boy",
"value": "cute_boy"
},
{
"label": "minimax-lovely_girl",
"label": "lovely_girl",
"value": "lovely_girl"
},
{
"label": "minimax-cartoon_pig",
"label": "cartoon_pig",
"value": "cartoon_pig"
},
{
"label": "minimax-bingjiao_didi",
"label": "bingjiao_didi",
"value": "bingjiao_didi"
},
{
"label": "minimax-junlang_nanyou",
"label": "junlang_nanyou",
"value": "junlang_nanyou"
},
{
"label": "minimax-chunzhen_xuedi",
"label": "chunzhen_xuedi",
"value": "chunzhen_xuedi"
},
{
"label": "minimax-lengdan_xiongzhang",
"label": "lengdan_xiongzhang",
"value": "lengdan_xiongzhang"
},
{
"label": "minimax-badao_shaoye",
"label": "badao_shaoye",
"value": "badao_shaoye"
},
{
"label": "minimax-tianxin_xiaoling",
"label": "tianxin_xiaoling",
"value": "tianxin_xiaoling"
},
{
"label": "minimax-qiaopi_mengmei",
"label": "qiaopi_mengmei",
"value": "qiaopi_mengmei"
},
{
"label": "minimax-wumei_yujie",
"label": "wumei_yujie",
"value": "wumei_yujie"
},
{
"label": "minimax-diadia_xuemei",
"label": "diadia_xuemei",
"value": "diadia_xuemei"
},
{
"label": "minimax-danya_xuejie",
"label": "danya_xuejie",
"value": "danya_xuejie"
},
{
"label": "minimax-Santa_Claus",
"label": "Santa_Claus",
"value": "Santa_Claus"
},
{
"label": "minimax-Grinch",
"label": "Grinch",
"value": "Grinch"
},
{
"label": "minimax-Rudolph",
"label": "Rudolph",
"value": "Rudolph"
},
{
"label": "minimax-Arnold",
"label": "Arnold",
"value": "Arnold"
},
{
"label": "minimax-Charming_Santa",
"label": "Charming_Santa",
"value": "Charming_Santa"
},
{
"label": "minimax-Charming_Lady",
"label": "Charming_Lady",
"value": "Charming_Lady"
},
{
"label": "minimax-Sweet_Girl",
"label": "Sweet_Girl",
"value": "Sweet_Girl"
},
{
"label": "minimax-Cute_Elf",
"label": "Cute_Elf",
"value": "Cute_Elf"
},
{
"label": "minimax-Attractive_Girl",
"label": "Attractive_Girl",
"value": "Attractive_Girl"
},
{
"label": "minimax-Serene_Woman",
"label": "Serene_Woman",
"value": "Serene_Woman"
}
],
"type": "tts"
}
]
}
}

View File

@ -10,7 +10,7 @@
"maxTemperature": 1.2,
"vision": true,
"toolChoice": true,
"functionCall": false,
"functionCall": true,
"defaultSystemChatPrompt": "",
"datasetProcess": true,
"usedInClassify": true,
@ -53,7 +53,7 @@
"maxTemperature": 1.2,
"vision": false,
"toolChoice": false,
"functionCall": false,
"functionCall": true,
"defaultSystemChatPrompt": "",
"datasetProcess": true,
"usedInClassify": true,
@ -77,7 +77,7 @@
"maxTemperature": 1.2,
"vision": false,
"toolChoice": false,
"functionCall": false,
"functionCall": true,
"defaultSystemChatPrompt": "",
"datasetProcess": true,
"usedInClassify": true,
@ -102,7 +102,7 @@
"maxTemperature": 1.2,
"vision": false,
"toolChoice": false,
"functionCall": false,
"functionCall": true,
"defaultSystemChatPrompt": "",
"datasetProcess": true,
"usedInClassify": true,
@ -127,7 +127,7 @@
"maxTemperature": 1.2,
"vision": false,
"toolChoice": true,
"functionCall": false,
"functionCall": true,
"defaultSystemChatPrompt": "",
"datasetProcess": true,
"usedInClassify": true,
@ -147,7 +147,7 @@
"maxTemperature": 1.2,
"vision": true,
"toolChoice": true,
"functionCall": false,
"functionCall": true,
"defaultSystemChatPrompt": "",
"datasetProcess": true,
"usedInClassify": true,

View File

@ -12,6 +12,7 @@ import {
} from '@fastgpt/global/core/ai/model.d';
import { debounce } from 'lodash';
import { ModelProviderType } from '@fastgpt/global/core/ai/provider';
import { findModelFromAlldata } from '../model';
/*
TODO: 分优先级读取
@ -95,7 +96,7 @@ export const loadSystemModels = async (init = false) => {
const modelData: any = {
...fileModel,
...dbModel?.metadata,
provider: fileContent.provider,
provider: dbModel?.metadata?.provider || fileContent.provider,
type: dbModel?.metadata?.type || fileModel.type,
isCustom: false
};
@ -140,6 +141,28 @@ export const loadSystemModels = async (init = false) => {
}
};
export const getSystemModelConfig = async (model: string): Promise<SystemModelItemType> => {
const modelData = findModelFromAlldata(model);
if (!modelData) return Promise.reject('Model is not found');
if (modelData.isCustom) return Promise.reject('Custom model not data');
// Read file
const fileContent = (await import(`./provider/${modelData.provider}`))?.default as {
provider: ModelProviderType;
list: SystemModelItemType[];
};
const config = fileContent.list.find((item) => item.model === model);
if (!config) return Promise.reject('Model config is not found');
return {
...config,
provider: modelData.provider,
isCustom: false
};
};
export const watchSystemModelUpdate = () => {
const changeStream = MongoSystemModel.watch();

View File

@ -2,6 +2,7 @@ import { addLog } from '../../../common/system/log';
import { POST } from '../../../common/api/serverRequest';
import { getDefaultRerankModel } from '../model';
import { getAxiosConfig } from '../config';
import { ReRankModelItemType } from '@fastgpt/global/core/ai/model.d';
type PostReRankResponse = {
id: string;
@ -13,15 +14,15 @@ type PostReRankResponse = {
type ReRankCallResult = { id: string; score?: number }[];
export function reRankRecall({
model = getDefaultRerankModel(),
query,
documents
}: {
model?: ReRankModelItemType;
query: string;
documents: { id: string; text: string }[];
}): Promise<ReRankCallResult> {
const model = getDefaultRerankModel();
if (!model || !model?.requestUrl) {
if (!model) {
return Promise.reject('no rerank model');
}
@ -29,7 +30,7 @@ export function reRankRecall({
let start = Date.now();
return POST<PostReRankResponse>(
model.requestUrl ? model.requestUrl : `${baseUrl}/v1/rerank`,
model.requestUrl ? model.requestUrl : `${baseUrl}/rerank`,
{
model: model.model,
query,
@ -57,6 +58,6 @@ export function reRankRecall({
.catch((err) => {
addLog.error('rerank error', err);
return [];
return Promise.reject(err);
});
}

View File

@ -26,11 +26,12 @@ const MyNumberInput = (props: Props) => {
{...restProps}
onChange={(e) => {
if (!onChange) return;
if (e === '') {
const numE = Number(e);
if (isNaN(numE)) {
// @ts-ignore
onChange('');
} else {
onChange(Number(e));
onChange(numE);
}
}}
>

View File

@ -58,7 +58,6 @@ export const MultipleRowSelect = ({
const selectedValue = cloneValue[index];
const selectedIndex = list.findIndex((item) => item.value === selectedValue);
const children = list[selectedIndex]?.children || [];
const hasChildren = list.some((item) => item.children && item.children?.length > 0);
// Store current scroll position before update
const currentScrollTop = MenuRef.current[index]?.scrollTop;
@ -84,54 +83,58 @@ export const MultipleRowSelect = ({
overflowY={'auto'}
whiteSpace={'nowrap'}
>
{list.map((item) => (
<Flex
key={item.value}
ref={(ref) => {
if (item.value === selectedValue) {
SelectedItemRef.current[index] = ref;
}
}}
py={1.5}
_notLast={{ mb: 1 }}
cursor={'pointer'}
px={1.5}
borderRadius={'sm'}
_hover={{
bg: 'primary.50'
}}
onClick={() => {
const newValue = [...cloneValue];
{list.map((item) => {
const hasChildren = item.children && item.children.length > 0;
if (item.value === selectedValue) {
for (let i = index; i < newValue.length; i++) {
newValue[i] = undefined;
return (
<Flex
key={item.value}
ref={(ref) => {
if (item.value === selectedValue) {
SelectedItemRef.current[index] = ref;
}
setCloneValue(newValue);
onSelect(newValue);
} else {
newValue[index] = item.value;
setCloneValue(newValue);
}}
py={1.5}
_notLast={{ mb: 1 }}
cursor={'pointer'}
px={1.5}
borderRadius={'sm'}
_hover={{
bg: 'primary.50'
}}
onClick={() => {
const newValue = [...cloneValue];
if (changeOnEverySelect || !hasChildren) {
if (item.value === selectedValue) {
for (let i = index; i < newValue.length; i++) {
newValue[i] = undefined;
}
setCloneValue(newValue);
onSelect(newValue);
}
} else {
newValue[index] = item.value;
setCloneValue(newValue);
if (!hasChildren) {
onClose();
if (changeOnEverySelect || !hasChildren) {
onSelect(newValue);
}
if (!hasChildren) {
onClose();
}
}
}
}}
{...(item.value === selectedValue
? {
bg: 'primary.50',
color: 'primary.600'
}
: {})}
>
{item.label}
</Flex>
))}
}}
{...(item.value === selectedValue
? {
bg: 'primary.50',
color: 'primary.600'
}
: {})}
>
{item.label}
</Flex>
);
})}
{list.length === 0 && (
<EmptyTip
text={emptyTip ?? t('common:common.MultipleRowSelect.No data')}

View File

@ -70,6 +70,7 @@
"personal_information": "Personal",
"personalization": "Personalization",
"promotion_records": "Promotions",
"reset_default": "Restore the default configuration",
"team": "Team",
"third_party": "Third Party",
"usage_records": "Usage"

View File

@ -146,6 +146,9 @@
"transition_to_workflow": "Convert to Workflow",
"transition_to_workflow_create_new_placeholder": "Create a new app instead of modifying the current app",
"transition_to_workflow_create_new_tip": "Once converted to a workflow, it cannot be reverted to simple mode. Please confirm!",
"tts_ai_model": "Use a speech synthesis model",
"tts_browser": "Browser's own (free)",
"tts_close": "Close",
"type.All": "All",
"type.Create http plugin tip": "Batch create plugins through OpenAPI Schema, compatible with GPTs format.",
"type.Create one plugin tip": "Customizable input and output workflows, usually used to encapsulate reusable workflows.",

View File

@ -375,12 +375,10 @@
"core.app.tool_label.github": "GitHub Address",
"core.app.tool_label.price": "Pricing",
"core.app.tool_label.view_doc": "View Documentation",
"core.app.tts.Close": "Do Not Use",
"core.app.tts.Speech model": "Speech Model",
"core.app.tts.Speech speed": "Speech Speed",
"core.app.tts.Test Listen": "Test Listen",
"core.app.tts.Test Listen Text": "Hello, this is a voice test. If you can hear this sentence, the voice playback function is normal.",
"core.app.tts.Web": "Browser Built-in (Free)",
"core.app.whisper.Auto send": "Auto Send",
"core.app.whisper.Auto send tip": "Automatically send after voice input is completed, no need to click the send button manually",
"core.app.whisper.Auto tts response": "Auto Voice Response",
@ -922,10 +920,10 @@
"model.name": "Model name",
"model.provider": "Provider",
"model.search_name_placeholder": "Search by model name",
"model.type.chat": "language model",
"model.type.chat": "LLM",
"model.type.embedding": "Embedding",
"model.type.reRank": "ReRank",
"model.type.stt": "speech recognition",
"model.type.stt": "STT",
"model.type.tts": "TTS",
"model_alicloud": "Ali Cloud",
"model_baai": "BAAI",

View File

@ -71,6 +71,7 @@
"personal_information": "个人信息",
"personalization": "个性化",
"promotion_records": "促销记录",
"reset_default": "恢复默认配置",
"team": "团队管理",
"third_party": "第三方账号",
"usage_records": "使用记录"

View File

@ -146,6 +146,9 @@
"transition_to_workflow": "转成工作流",
"transition_to_workflow_create_new_placeholder": "创建一个新的应用,而不是修改当前应用",
"transition_to_workflow_create_new_tip": "转化成工作流后,将无法转化回简易模式,请确认!",
"tts_ai_model": "使用语音合成模型",
"tts_browser": "浏览器自带(免费)",
"tts_close": "关闭",
"type.All": "全部",
"type.Create http plugin tip": "通过 OpenAPI Schema 批量创建插件,兼容 GPTs 格式",
"type.Create one plugin tip": "可以自定义输入和输出的工作流,通常用于封装重复使用的工作流",

View File

@ -378,12 +378,10 @@
"core.app.tool_label.github": "GitHub地址",
"core.app.tool_label.price": "计费说明",
"core.app.tool_label.view_doc": "查看说明文档",
"core.app.tts.Close": "不使用",
"core.app.tts.Speech model": "语音模型",
"core.app.tts.Speech speed": "语速",
"core.app.tts.Test Listen": "试听",
"core.app.tts.Test Listen Text": "你好,这是语音测试,如果你能听到这句话,说明语音播放功能正常",
"core.app.tts.Web": "浏览器自带(免费)",
"core.app.whisper.Auto send": "自动发送",
"core.app.whisper.Auto send tip": "语音输入完毕后直接发送,不需要再手动点击发送按键",
"core.app.whisper.Auto tts response": "自动语音回复",

View File

@ -69,6 +69,7 @@
"personal_information": "個人資訊",
"personalization": "個人化",
"promotion_records": "促銷記錄",
"reset_default": "恢復默認配置",
"team": "團隊管理",
"third_party": "第三方账号",
"usage_records": "使用記錄"

View File

@ -146,6 +146,9 @@
"transition_to_workflow": "轉換成工作流程",
"transition_to_workflow_create_new_placeholder": "建立新的應用程式,而不是修改目前應用程式",
"transition_to_workflow_create_new_tip": "轉換成工作流程後,將無法轉換回簡易模式,請確認!",
"tts_ai_model": "使用語音合成模型",
"tts_browser": "瀏覽器自帶(免費)",
"tts_close": "關閉",
"type.All": "全部",
"type.Create http plugin tip": "透過 OpenAPI Schema 批次建立外掛,相容 GPTs 格式",
"type.Create one plugin tip": "可以自訂輸入和輸出的工作流程,通常用於封裝重複使用的工作流程",

View File

@ -374,12 +374,10 @@
"core.app.tool_label.github": "GitHub 網址",
"core.app.tool_label.price": "收費說明",
"core.app.tool_label.view_doc": "檢視說明文件",
"core.app.tts.Close": "不使用",
"core.app.tts.Speech model": "語音模型",
"core.app.tts.Speech speed": "語速",
"core.app.tts.Test Listen": "測試聆聽",
"core.app.tts.Test Listen Text": "您好,這是語音測試。如果您能聽到這句話,表示語音播放功能正常",
"core.app.tts.Web": "瀏覽器內建(免費)",
"core.app.whisper.Auto send": "自動傳送",
"core.app.whisper.Auto send tip": "語音輸入完成後自動傳送,無需手動點選傳送按鈕",
"core.app.whisper.Auto tts response": "自動語音回應",

162
pnpm-lock.yaml generated
View File

@ -22,7 +22,7 @@ importers:
version: 13.3.0
next-i18next:
specifier: 15.3.0
version: 15.3.0(i18next@23.11.5)(next@14.2.5(@babel/core@7.24.9)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1)
version: 15.3.0(i18next@23.11.5)(next@14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1)
prettier:
specifier: 3.2.4
version: 3.2.4
@ -67,7 +67,7 @@ importers:
version: 4.0.2
next:
specifier: 14.2.5
version: 14.2.5(@babel/core@7.24.9)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8)
version: 14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8)
openai:
specifier: 4.61.0
version: 4.61.0(encoding@0.1.13)
@ -210,7 +210,7 @@ importers:
version: 1.4.5-lts.1
next:
specifier: 14.2.5
version: 14.2.5(@babel/core@7.24.9)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8)
version: 14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8)
nextjs-cors:
specifier: ^2.2.0
version: 2.2.0(next@14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))
@ -295,7 +295,7 @@ importers:
version: 2.1.1(@chakra-ui/system@2.6.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(react@18.3.1))(react@18.3.1)
'@chakra-ui/next-js':
specifier: 2.1.5
version: 2.1.5(@chakra-ui/react@2.8.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(framer-motion@9.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(next@14.2.5(@babel/core@7.24.9)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react@18.3.1)
version: 2.1.5(@chakra-ui/react@2.8.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(framer-motion@9.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(next@14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react@18.3.1)
'@chakra-ui/react':
specifier: 2.8.1
version: 2.8.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(framer-motion@9.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
@ -358,7 +358,7 @@ importers:
version: 4.17.21
next-i18next:
specifier: 15.3.0
version: 15.3.0(i18next@23.11.5)(next@14.2.5(@babel/core@7.24.9)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1)
version: 15.3.0(i18next@23.11.5)(next@14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1)
papaparse:
specifier: ^5.4.1
version: 5.4.1
@ -531,6 +531,9 @@ importers:
nprogress:
specifier: ^0.2.0
version: 0.2.0
qrcode:
specifier: ^1.5.4
version: 1.5.4
react:
specifier: 18.3.1
version: 18.3.1
@ -616,6 +619,9 @@ importers:
'@types/node':
specifier: ^20.14.2
version: 20.14.11
'@types/qrcode':
specifier: ^1.5.5
version: 1.5.5
'@types/react':
specifier: 18.3.1
version: 18.3.1
@ -3490,6 +3496,9 @@ packages:
'@types/prop-types@15.7.12':
resolution: {integrity: sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==}
'@types/qrcode@1.5.5':
resolution: {integrity: sha512-CdfBi/e3Qk+3Z/fXYShipBT13OJ2fDO2Q2w5CIP5anLTLIndQG9z6P1cnm+8zCWSpm5dnxMFd/uREtb0EXuQzg==}
'@types/qs@6.9.15':
resolution: {integrity: sha512-uXHQKES6DQKKCLh441Xv/dwxOq1TVS3JPUMlEqoEglvlhR6Mxnlew/Xq/LRVHpLyk7iK3zODe1qYHIMltO7XGg==}
@ -4325,6 +4334,9 @@ packages:
client-only@0.0.1:
resolution: {integrity: sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==}
cliui@6.0.0:
resolution: {integrity: sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==}
cliui@8.0.1:
resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==}
engines: {node: '>=12'}
@ -4767,6 +4779,10 @@ packages:
supports-color:
optional: true
decamelize@1.2.0:
resolution: {integrity: sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==}
engines: {node: '>=0.10.0'}
decimal.js-light@2.5.1:
resolution: {integrity: sha512-qIMFpTMZmny+MMIitAB6D7iVPEorVw6YQRWkvarTkT4tBeSLLiHzcwj6q0MmYSFCiVpiqPJTJEYIrpcPzVEIvg==}
@ -4897,6 +4913,9 @@ packages:
resolution: {integrity: sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==}
engines: {node: '>=0.3.1'}
dijkstrajs@1.0.3:
resolution: {integrity: sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA==}
dingbat-to-unicode@1.0.1:
resolution: {integrity: sha512-98l0sW87ZT58pU4i61wa2OHwxbiYSbuxsCBozaVnYX2iCnr3bLM3fIes1/ej7h1YdOKuKt/MLs706TVnALA65w==}
@ -7571,6 +7590,10 @@ packages:
resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==}
engines: {node: '>=4'}
pngjs@5.0.0:
resolution: {integrity: sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==}
engines: {node: '>=10.13.0'}
possible-typed-array-names@1.0.0:
resolution: {integrity: sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q==}
engines: {node: '>= 0.4'}
@ -7701,6 +7724,11 @@ packages:
pure-rand@6.1.0:
resolution: {integrity: sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==}
qrcode@1.5.4:
resolution: {integrity: sha512-1ca71Zgiu6ORjHqFBDpnSMTR2ReToX4l1Au1VFLyVeBTFavzQnv5JxMFr3ukHVKpSrSA2MCk0lNJSykjUfz7Zg==}
engines: {node: '>=10.13.0'}
hasBin: true
qs@6.11.0:
resolution: {integrity: sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==}
engines: {node: '>=0.6'}
@ -8003,6 +8031,9 @@ packages:
resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==}
engines: {node: '>=0.10.0'}
require-main-filename@2.0.0:
resolution: {integrity: sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==}
resize-observer-polyfill@1.5.1:
resolution: {integrity: sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==}
@ -9160,6 +9191,9 @@ packages:
resolution: {integrity: sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==}
engines: {node: '>= 0.4'}
which-module@2.0.1:
resolution: {integrity: sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==}
which-typed-array@1.1.15:
resolution: {integrity: sha512-oV0jmFtUky6CXfkqehVvBP/LSWJ2sy4vWMioiENyJLePrBO/yKyV9OyJySfAKosh+RYkIl5zJCNZ8/4JncrpdA==}
engines: {node: '>= 0.4'}
@ -9231,6 +9265,9 @@ packages:
resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==}
engines: {node: '>=0.4'}
y18n@4.0.3:
resolution: {integrity: sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==}
y18n@5.0.8:
resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==}
engines: {node: '>=10'}
@ -9249,10 +9286,18 @@ packages:
resolution: {integrity: sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==}
engines: {node: '>= 14'}
yargs-parser@18.1.3:
resolution: {integrity: sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==}
engines: {node: '>=6'}
yargs-parser@21.1.1:
resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==}
engines: {node: '>=12'}
yargs@15.4.1:
resolution: {integrity: sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==}
engines: {node: '>=8'}
yargs@17.7.2:
resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==}
engines: {node: '>=12'}
@ -10537,6 +10582,14 @@ snapshots:
next: 14.2.5(@babel/core@7.24.9)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8)
react: 18.3.1
'@chakra-ui/next-js@2.1.5(@chakra-ui/react@2.8.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(framer-motion@9.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(next@14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react@18.3.1)':
dependencies:
'@chakra-ui/react': 2.8.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(framer-motion@9.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
'@emotion/cache': 11.11.0
'@emotion/react': 11.11.1(@types/react@18.3.1)(react@18.3.1)
next: 14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8)
react: 18.3.1
'@chakra-ui/number-input@2.1.1(@chakra-ui/system@2.6.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(react@18.3.1))(react@18.3.1)':
dependencies:
'@chakra-ui/counter': 2.1.0(react@18.3.1)
@ -12623,6 +12676,10 @@ snapshots:
'@types/prop-types@15.7.12': {}
'@types/qrcode@1.5.5':
dependencies:
'@types/node': 20.14.11
'@types/qs@6.9.15': {}
'@types/qs@6.9.16': {}
@ -13276,7 +13333,7 @@ snapshots:
axios@1.7.7:
dependencies:
follow-redirects: 1.15.9(debug@4.3.7)
follow-redirects: 1.15.9
form-data: 4.0.1
proxy-from-env: 1.1.0
transitivePeerDependencies:
@ -13674,6 +13731,12 @@ snapshots:
client-only@0.0.1: {}
cliui@6.0.0:
dependencies:
string-width: 4.2.3
strip-ansi: 6.0.1
wrap-ansi: 6.2.0
cliui@8.0.1:
dependencies:
string-width: 4.2.3
@ -14125,6 +14188,8 @@ snapshots:
dependencies:
ms: 2.1.3
decamelize@1.2.0: {}
decimal.js-light@2.5.1: {}
decode-named-character-reference@1.0.2:
@ -14269,6 +14334,8 @@ snapshots:
diff@5.2.0: {}
dijkstrajs@1.0.3: {}
dingbat-to-unicode@1.0.1: {}
dir-glob@3.0.1:
@ -15070,6 +15137,8 @@ snapshots:
follow-redirects@1.15.6: {}
follow-redirects@1.15.9: {}
follow-redirects@1.15.9(debug@4.3.4):
optionalDependencies:
debug: 4.3.4
@ -17417,6 +17486,18 @@ snapshots:
react: 18.3.1
react-i18next: 14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
next-i18next@15.3.0(i18next@23.11.5)(next@14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1):
dependencies:
'@babel/runtime': 7.24.8
'@types/hoist-non-react-statics': 3.3.5
core-js: 3.37.1
hoist-non-react-statics: 3.3.2
i18next: 23.11.5
i18next-fs-backend: 2.3.1
next: 14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8)
react: 18.3.1
react-i18next: 14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
next@14.2.5(@babel/core@7.24.9)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8):
dependencies:
'@next/env': 14.2.5
@ -17443,10 +17524,36 @@ snapshots:
- '@babel/core'
- babel-plugin-macros
next@14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8):
dependencies:
'@next/env': 14.2.5
'@swc/helpers': 0.5.5
busboy: 1.6.0
caniuse-lite: 1.0.30001669
graceful-fs: 4.2.11
postcss: 8.4.31
react: 18.3.1
react-dom: 18.3.1(react@18.3.1)
styled-jsx: 5.1.1(react@18.3.1)
optionalDependencies:
'@next/swc-darwin-arm64': 14.2.5
'@next/swc-darwin-x64': 14.2.5
'@next/swc-linux-arm64-gnu': 14.2.5
'@next/swc-linux-arm64-musl': 14.2.5
'@next/swc-linux-x64-gnu': 14.2.5
'@next/swc-linux-x64-musl': 14.2.5
'@next/swc-win32-arm64-msvc': 14.2.5
'@next/swc-win32-ia32-msvc': 14.2.5
'@next/swc-win32-x64-msvc': 14.2.5
sass: 1.77.8
transitivePeerDependencies:
- '@babel/core'
- babel-plugin-macros
nextjs-cors@2.2.0(next@14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8)):
dependencies:
cors: 2.8.5
next: 14.2.5(@babel/core@7.24.9)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8)
next: 14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8)
nextjs-node-loader@1.1.5(webpack@5.92.1):
dependencies:
@ -17870,6 +17977,8 @@ snapshots:
pluralize@8.0.0: {}
pngjs@5.0.0: {}
possible-typed-array-names@1.0.0: {}
postcss@8.4.31:
@ -17998,6 +18107,12 @@ snapshots:
pure-rand@6.1.0: {}
qrcode@1.5.4:
dependencies:
dijkstrajs: 1.0.3
pngjs: 5.0.0
yargs: 15.4.1
qs@6.11.0:
dependencies:
side-channel: 1.0.6
@ -18417,6 +18532,8 @@ snapshots:
require-from-string@2.0.2: {}
require-main-filename@2.0.0: {}
resize-observer-polyfill@1.5.1: {}
resolve-cwd@3.0.0:
@ -18597,8 +18714,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
set-blocking@2.0.0:
optional: true
set-blocking@2.0.0: {}
set-cookie-parser@2.6.0: {}
@ -18883,6 +18999,11 @@ snapshots:
'@babel/core': 7.24.9
babel-plugin-macros: 3.1.0
styled-jsx@5.1.1(react@18.3.1):
dependencies:
client-only: 0.0.1
react: 18.3.1
stylis@4.2.0: {}
stylis@4.3.2: {}
@ -19662,6 +19783,8 @@ snapshots:
is-weakmap: 2.0.2
is-weakset: 2.0.3
which-module@2.0.1: {}
which-typed-array@1.1.15:
dependencies:
available-typed-arrays: 1.0.7
@ -19749,6 +19872,8 @@ snapshots:
xtend@4.0.2: {}
y18n@4.0.3: {}
y18n@5.0.8: {}
yallist@3.1.1: {}
@ -19759,8 +19884,27 @@ snapshots:
yaml@2.3.1: {}
yargs-parser@18.1.3:
dependencies:
camelcase: 5.3.1
decamelize: 1.2.0
yargs-parser@21.1.1: {}
yargs@15.4.1:
dependencies:
cliui: 6.0.0
decamelize: 1.2.0
find-up: 4.1.0
get-caller-file: 2.0.5
require-directory: 2.1.1
require-main-filename: 2.0.0
set-blocking: 2.0.0
string-width: 4.2.3
which-module: 2.0.1
y18n: 4.0.3
yargs-parser: 18.1.3
yargs@17.7.2:
dependencies:
cliui: 8.0.1

View File

@ -51,6 +51,7 @@
"next-i18next": "15.3.0",
"nextjs-node-loader": "^1.1.5",
"nprogress": "^0.2.0",
"qrcode": "^1.5.4",
"react": "18.3.1",
"react-day-picker": "^8.7.1",
"react-dom": "18.3.1",
@ -81,6 +82,7 @@
"@types/jsonwebtoken": "^9.0.3",
"@types/lodash": "^4.14.191",
"@types/node": "^20.14.2",
"@types/qrcode": "^1.5.5",
"@types/react": "18.3.1",
"@types/react-dom": "18.3.0",
"@types/react-syntax-highlighter": "^15.5.6",

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,31 @@
import React, { useEffect } from 'react';
import { Box } from '@chakra-ui/react';
import { useMarkdownWidth } from '../hooks';
const AudioBlock = ({ code: audioUrl }: { code: string }) => {
const { width, Ref } = useMarkdownWidth();
useEffect(() => {
fetch(audioUrl?.trim(), {
mode: 'cors',
credentials: 'omit'
})
.then((response) => response.blob())
.then((blob) => {
const url = URL.createObjectURL(blob);
const audio = document.getElementById('player');
audio?.setAttribute('src', url);
})
.catch((err) => {
console.log(err);
});
}, [audioUrl]);
return (
<Box w={width} ref={Ref}>
<audio id="player" controls style={{ width: '100%' }} />
</Box>
);
};
export default AudioBlock;

View File

@ -0,0 +1,31 @@
import React, { useEffect } from 'react';
import { Box } from '@chakra-ui/react';
import { useMarkdownWidth } from '../hooks';
const VideoBlock = ({ code: videoUrl }: { code: string }) => {
const { width, Ref } = useMarkdownWidth();
useEffect(() => {
fetch(videoUrl?.trim(), {
mode: 'cors',
credentials: 'omit'
})
.then((response) => response.blob())
.then((blob) => {
const url = URL.createObjectURL(blob);
const video = document.getElementById('player');
video?.setAttribute('src', url);
})
.catch((err) => {
console.log(err);
});
}, [videoUrl]);
return (
<Box w={width} ref={Ref}>
<video id="player" controls />
</Box>
);
};
export default VideoBlock;

View File

@ -16,7 +16,7 @@ import { useCopyData } from '@fastgpt/web/hooks/useCopyData';
import { useTranslation } from 'next-i18next';
import { useMarkdownWidth } from '../hooks';
import type { IconNameType } from '@fastgpt/web/components/common/Icon/type.d';
import { codeLight } from '../CodeLight';
import { codeLight } from './CodeLight';
import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
const StyledButton = ({

View File

@ -13,12 +13,14 @@ import dynamic from 'next/dynamic';
import { Box } from '@chakra-ui/react';
import { CodeClassNameEnum } from './utils';
const CodeLight = dynamic(() => import('./CodeLight'), { ssr: false });
const CodeLight = dynamic(() => import('./codeBlock/CodeLight'), { ssr: false });
const MermaidCodeBlock = dynamic(() => import('./img/MermaidCodeBlock'), { ssr: false });
const MdImage = dynamic(() => import('./img/Image'), { ssr: false });
const EChartsCodeBlock = dynamic(() => import('./img/EChartsCodeBlock'), { ssr: false });
const IframeCodeBlock = dynamic(() => import('./codeBlock/Iframe'), { ssr: false });
const IframeHtmlCodeBlock = dynamic(() => import('./codeBlock/iframe-html'), { ssr: false });
const VideoBlock = dynamic(() => import('./codeBlock/Video'), { ssr: false });
const AudioBlock = dynamic(() => import('./codeBlock/Audio'), { ssr: false });
const ChatGuide = dynamic(() => import('./chat/Guide'), { ssr: false });
const QuestionGuide = dynamic(() => import('./chat/QuestionGuide'), { ssr: false });
@ -139,6 +141,12 @@ function Code(e: any) {
</IframeHtmlCodeBlock>
);
}
if (codeType === CodeClassNameEnum.video) {
return <VideoBlock code={strChildren} />;
}
if (codeType === CodeClassNameEnum.audio) {
return <AudioBlock code={strChildren} />;
}
return (
<CodeLight className={className} codeBlock={codeBlock} match={match}>

View File

@ -7,7 +7,9 @@ export enum CodeClassNameEnum {
files = 'files',
latex = 'latex',
iframe = 'iframe',
html = 'html'
html = 'html',
video = 'video',
audio = 'audio'
}
function htmlTableToLatex(html: string) {

View File

@ -80,7 +80,9 @@ const AIChatSettingsModal = ({
const temperature = watch('temperature');
const useVision = watch('aiChatVision');
const selectedModel = getWebLLMModel(model);
const selectedModel = useMemo(() => {
return getWebLLMModel(model);
}, [model]);
const llmSupportVision = !!selectedModel?.vision;
const tokenLimit = useMemo(() => {
@ -244,7 +246,7 @@ const AIChatSettingsModal = ({
</Box>
<Box flex={'1 0 0'}>
<InputSlider
min={100}
min={0}
max={tokenLimit}
step={200}
isDisabled={maxToken === undefined}

View File

@ -7,8 +7,8 @@ import AISettingModal, { AIChatSettingsModalProps } from '@/components/core/ai/A
import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
import { useTranslation } from 'next-i18next';
import MyIcon from '@fastgpt/web/components/common/Icon';
import { useMount } from 'ahooks';
import AIModelSelector from '@/components/Select/AIModelSelector';
import { getWebDefaultModel } from '@/web/common/system/utils';
type Props = {
llmModelType?: `${LLMModelTypeEnum}`;
@ -24,7 +24,7 @@ const SettingLLMModel = ({
...props
}: AIChatSettingsModalProps & Props) => {
const { t } = useTranslation();
const { llmModelList, defaultModels } = useSystemStore();
const { llmModelList } = useSystemStore();
const model = defaultData.model;
@ -39,16 +39,19 @@ const SettingLLMModel = ({
}),
[llmModelList, llmModelType]
);
const defaultModel = useMemo(() => {
return getWebDefaultModel(modelList).model;
}, [modelList]);
// Set default model
useEffect(() => {
if (!llmModelList.find((item) => item.model === model) && !!defaultModels.llm) {
if (!modelList.find((item) => item.model === model) && !!defaultModel) {
onChange({
...defaultData,
model: defaultModels.llm.model
model: defaultModel
});
}
}, [model, defaultData, llmModelList, defaultModels.llm, onChange]);
}, [modelList, model, defaultModel, onChange]);
const {
isOpen: isOpenAIChatSetting,

View File

@ -65,7 +65,7 @@ const DatasetParamsModal = ({
const theme = useTheme();
const { toast } = useToast();
const { teamPlanStatus } = useUserStore();
const { reRankModelList, llmModelList } = useSystemStore();
const { reRankModelList, llmModelList, defaultModels } = useSystemStore();
const [refresh, setRefresh] = useState(false);
const [currentTabType, setCurrentTabType] = useState(SearchSettingTabEnum.searchMode);
@ -82,7 +82,7 @@ const DatasetParamsModal = ({
searchMode,
usingReRank: !!usingReRank && teamPlanStatus?.standardConstants?.permissionReRank !== false,
datasetSearchUsingExtensionQuery,
datasetSearchExtensionModel: datasetSearchExtensionModel || chatModelSelectList[0]?.value,
datasetSearchExtensionModel: datasetSearchExtensionModel || defaultModels.llm?.model,
datasetSearchExtensionBg
}
});

View File

@ -1,6 +1,6 @@
import MyIcon from '@fastgpt/web/components/common/Icon';
import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
import { Box, Button, Flex, ModalBody, useDisclosure, Image } from '@chakra-ui/react';
import { Box, Button, Flex, ModalBody, useDisclosure, Image, HStack } from '@chakra-ui/react';
import React, { useCallback, useMemo } from 'react';
import { useTranslation } from 'next-i18next';
import { TTSTypeEnum } from '@/web/core/app/constants';
@ -9,13 +9,15 @@ import { useAudioPlay } from '@/web/common/utils/voice';
import { useSystemStore } from '@/web/common/system/useSystemStore';
import MyModal from '@fastgpt/web/components/common/MyModal';
import MySlider from '@/components/Slider';
import MySelect from '@fastgpt/web/components/common/MySelect';
import { defaultTTSConfig } from '@fastgpt/global/core/app/constants';
import ChatFunctionTip from './Tip';
import FormLabel from '@fastgpt/web/components/common/MyBox/FormLabel';
import MyImage from '@fastgpt/web/components/common/Image/MyImage';
import { useContextSelector } from 'use-context-selector';
import { AppContext } from '@/pageComponents/app/detail/context';
import Avatar from '@fastgpt/web/components/common/Avatar';
import { getModelProvider } from '@fastgpt/global/core/ai/provider';
import MultipleRowSelect from '@fastgpt/web/components/common/MySelect/MultipleRowSelect';
const TTSSelect = ({
value = defaultTTSConfig,
@ -30,28 +32,57 @@ const TTSSelect = ({
const appId = useContextSelector(AppContext, (v) => v.appId);
const list = useMemo(
const selectorList = useMemo(
() => [
{ label: t('common:core.app.tts.Close'), value: TTSTypeEnum.none },
{ label: t('common:core.app.tts.Web'), value: TTSTypeEnum.web },
...ttsModelList.map((item) => item?.voices || []).flat()
{ label: t('app:tts_close'), value: TTSTypeEnum.none, children: [] },
{ label: t('app:tts_browser'), value: TTSTypeEnum.web, children: [] },
...ttsModelList.map((model) => {
const providerData = getModelProvider(model.provider);
return {
label: (
<HStack>
<Avatar borderRadius={'0'} w={'1.25rem'} src={providerData.avatar} />
<Box>{t(providerData.name)}</Box>
</HStack>
),
value: model.model,
children: model.voices.map((voice) => ({
label: voice.label,
value: voice.value
}))
};
})
],
[ttsModelList, t]
);
const formatValue = useMemo(() => {
if (!value || !value.type) {
return TTSTypeEnum.none;
return [TTSTypeEnum.none, undefined];
}
if (value.type === TTSTypeEnum.none || value.type === TTSTypeEnum.web) {
return value.type;
return [value.type, undefined];
}
return value.voice;
return [value.model, value.voice];
}, [value]);
const formLabel = useMemo(
() => list.find((item) => item.value === formatValue)?.label || t('common:common.UnKnow'),
[formatValue, list, t]
);
const formLabel = useMemo(() => {
const provider = selectorList.find((item) => item.value === formatValue[0]) || selectorList[0];
const voice = provider.children.find((item) => item.value === formatValue[1]);
return (
<Box minW={'150px'} maxW={'220px'} className="textEllipsis">
{voice ? (
<Flex alignItems={'center'}>
<Box>{provider.label}</Box>
<Box>-</Box>
<Box>{voice.label}</Box>
</Flex>
) : (
provider.label
)}
</Box>
);
}, [formatValue, selectorList, t]);
const { playAudioByText, cancelAudio, audioLoading, audioPlaying } = useAudioPlay({
appId,
@ -59,21 +90,16 @@ const TTSSelect = ({
});
const onclickChange = useCallback(
(e: string) => {
if (e === TTSTypeEnum.none || e === TTSTypeEnum.web) {
onChange({ type: e as `${TTSTypeEnum}` });
(e: string[]) => {
console.log(e, '-=');
if (e[0] === TTSTypeEnum.none || e[0] === TTSTypeEnum.web) {
onChange({ type: e[0] });
} else {
const audioModel = ttsModelList.find((item) =>
item.voices?.find((voice) => voice.value === e)
);
if (!audioModel) {
return;
}
onChange({
...value,
type: TTSTypeEnum.model,
model: audioModel.model,
voice: e
model: e[0],
voice: e[1]
});
}
},
@ -113,7 +139,13 @@ const TTSSelect = ({
<ModalBody px={[5, 16]} py={[4, 8]}>
<Flex justifyContent={'space-between'} alignItems={'center'}>
<FormLabel>{t('common:core.app.tts.Speech model')}</FormLabel>
<MySelect w={'220px'} value={formatValue} list={list} onchange={onclickChange} />
<MultipleRowSelect
rowMinWidth="160px"
label={formLabel}
value={formatValue}
list={selectorList}
onSelect={onclickChange}
/>
</Flex>
<Flex mt={8} justifyContent={'space-between'}>
<FormLabel>{t('common:core.app.tts.Speech speed')}</FormLabel>
@ -135,7 +167,7 @@ const TTSSelect = ({
}}
/>
</Flex>
{formatValue !== TTSTypeEnum.none && (
{formatValue[0] !== TTSTypeEnum.none && (
<Flex mt={10} justifyContent={'end'}>
{audioPlaying ? (
<Flex>

View File

@ -25,7 +25,7 @@ const WelcomeTextConfig = (props: TextareaProps) => {
mt={1.5}
rows={6}
fontSize={'sm'}
bg={'white'}
bg={'myGray.50'}
minW={'384px'}
placeholder={t('common:core.app.tip.welcomeTextTip')}
autoHeight

View File

@ -1,14 +1,12 @@
import MyModal from '@fastgpt/web/components/common/MyModal';
import React, { useCallback, useEffect, useRef } from 'react';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { useTranslation } from 'next-i18next';
import { Box, ModalBody } from '@chakra-ui/react';
import { checkBalancePayResult } from '@/web/support/wallet/bill/api';
import { useToast } from '@fastgpt/web/hooks/useToast';
import { useRouter } from 'next/router';
import { getErrText } from '@fastgpt/global/common/error/utils';
import LightTip from '@fastgpt/web/components/common/LightTip';
import Script from 'next/script';
import { getWebReqUrl } from '@fastgpt/web/common/system/utils';
import QRCode from 'qrcode';
export type QRPayProps = {
readPrice: number;
@ -27,21 +25,35 @@ const QRCodePayModal = ({
}: QRPayProps & { tip?: string; onSuccess?: () => any }) => {
const { t } = useTranslation();
const { toast } = useToast();
const dom = useRef<HTMLDivElement>(null);
const canvasRef = useRef<HTMLDivElement>(null);
const drawCode = useCallback(() => {
if (dom.current && window.QRCode && !dom.current.innerHTML) {
new window.QRCode(dom.current, {
text: codeUrl,
width: qrCodeSize,
height: qrCodeSize,
colorDark: '#000000',
colorLight: '#ffffff',
correctLevel: window.QRCode.CorrectLevel.H
const canvas = document.createElement('canvas');
QRCode.toCanvas(canvas, codeUrl, {
width: qrCodeSize,
margin: 0,
color: {
dark: '#000000',
light: '#ffffff'
}
})
.then(() => {
if (canvasRef.current) {
canvasRef.current.innerHTML = '';
canvasRef.current.appendChild(canvas);
} else {
drawCode();
}
})
.catch((err) => {
console.error('QRCode generation error:', err);
});
}
}, [codeUrl]);
useEffect(() => {
drawCode();
}, [drawCode]);
useEffect(() => {
let timer: NodeJS.Timeout;
const check = async () => {
@ -54,7 +66,7 @@ const QRCodePayModal = ({
title: res,
status: 'success'
});
return;
return clearTimeout(timer);
} catch (error) {
toast({
title: getErrText(error),
@ -63,9 +75,7 @@ const QRCodePayModal = ({
}
}
} catch (error) {}
drawCode();
clearTimeout(timer);
timer = setTimeout(check, 2000);
};
@ -75,23 +85,15 @@ const QRCodePayModal = ({
}, [billId, drawCode, onSuccess, toast]);
return (
<>
<Script
src={getWebReqUrl('/js/qrcode.min.js')}
strategy="lazyOnload"
onLoad={drawCode}
></Script>
<MyModal isOpen title={t('common:user.Pay')} iconSrc="/imgs/modal/pay.svg">
<ModalBody textAlign={'center'} pb={10} whiteSpace={'pre-wrap'}>
{tip && <LightTip text={tip} mb={8} textAlign={'left'} />}
<Box ref={dom} id={'payQRCode'} display={'inline-block'} h={`${qrCodeSize}px`}></Box>
<Box mt={5} textAlign={'center'}>
{t('common:pay.wechat', { price: readPrice })}
</Box>
</ModalBody>
</MyModal>
</>
<MyModal isOpen title={t('common:user.Pay')} iconSrc="/imgs/modal/pay.svg">
<ModalBody textAlign={'center'} pb={10} whiteSpace={'pre-wrap'}>
{tip && <LightTip text={tip} mb={8} textAlign={'left'} />}
<Box ref={canvasRef} display={'inline-block'} h={`${qrCodeSize}px`}></Box>
<Box mt={5} textAlign={'center'}>
{t('common:pay.wechat', { price: readPrice })}
</Box>
</ModalBody>
</MyModal>
);
};

View File

@ -33,6 +33,7 @@ import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
import {
deleteSystemModel,
getModelConfigJson,
getSystemModelDefaultConfig,
getSystemModelDetail,
getSystemModelList,
getTestModel,
@ -56,6 +57,7 @@ import { putUpdateWithJson } from '@/web/core/ai/config';
import CopyBox from '@fastgpt/web/components/common/String/CopyBox';
import MyIcon from '@fastgpt/web/components/common/Icon';
import AIModelSelector from '@/components/Select/AIModelSelector';
import { useRefresh } from '../../../../../../packages/web/hooks/useRefresh';
const MyModal = dynamic(() => import('@fastgpt/web/components/common/MyModal'));
@ -173,7 +175,7 @@ const ModelTable = ({ Tab }: { Tab: React.ReactNode }) => {
priceLabel: (
<Flex color={'myGray.700'}>
<Box fontWeight={'bold'} color={'myGray.900'} mr={0.5}>
{item.charsPointsPrice}
{item.charsPointsPrice || 0}
</Box>
{` ${t('common:support.wallet.subscription.point')} / 60${t('common:unit.seconds')}`}
</Flex>
@ -526,9 +528,10 @@ const ModelEditModal = ({
const { t } = useTranslation();
const { feConfigs } = useSystemStore();
const { register, getValues, setValue, handleSubmit, watch } = useForm<SystemModelItemType>({
defaultValues: modelData
});
const { register, getValues, setValue, handleSubmit, watch, reset } =
useForm<SystemModelItemType>({
defaultValues: modelData
});
const isCustom = !!modelData.isCustom;
const isLLMModel = modelData?.type === ModelTypeEnum.llm;
@ -575,6 +578,22 @@ const ModelEditModal = ({
}
);
const [key, setKey] = useState(0);
const { runAsync: loadDefaultConfig, loading: loadingDefaultConfig } = useRequest2(
getSystemModelDefaultConfig,
{
onSuccess(res) {
reset({
...getValues(),
...res
});
setTimeout(() => {
setKey((prev) => prev + 1);
}, 0);
}
}
);
return (
<MyModal
iconSrc={'modal/edit'}
@ -586,7 +605,7 @@ const ModelEditModal = ({
h={'100%'}
>
<ModalBody>
<Flex gap={4}>
<Flex gap={4} key={key}>
<TableContainer flex={'1'}>
<Table>
<Thead>
@ -1007,6 +1026,16 @@ const ModelEditModal = ({
</Flex>
</ModalBody>
<ModalFooter>
{!modelData.isCustom && (
<Button
isLoading={loadingDefaultConfig}
variant={'whiteBase'}
mr={4}
onClick={() => loadDefaultConfig(modelData.model)}
>
{t('account:reset_default')}
</Button>
)}
<Button variant={'whiteBase'} mr={4} onClick={onClose}>
{t('common:common.Cancel')}
</Button>

View File

@ -44,33 +44,10 @@ const UsageTableList = ({
const { dateRange, selectTmbIds, isSelectAllTmb, usageSources, isSelectAllSource, projectName } =
filterParams;
const requestParams = useMemo(() => {
const appNameMap = {
['core.app.Question Guide']: t('common:core.app.Question Guide'),
['common:support.wallet.usage.Audio Speech']: t('common:support.wallet.usage.Audio Speech'),
['support.wallet.usage.Whisper']: t('common:support.wallet.usage.Whisper'),
['support.wallet.moduleName.index']: t('common:support.wallet.moduleName.index'),
['support.wallet.moduleName.qa']: t('common:support.wallet.moduleName.qa'),
['core.dataset.training.Auto mode']: t('common:core.dataset.training.Auto mode'),
['common:core.module.template.ai_chat']: t('common:core.module.template.ai_chat')
};
const sourcesMap = Object.fromEntries(
Object.entries(UsageSourceMap).map(([key, config]) => [
key,
{
label: t(config.label as any)
}
])
);
const title = t('account_usage:export_title');
return {
dateStart: dateRange.from || new Date(),
dateEnd: addDays(dateRange.to || new Date(), 1),
sources: isSelectAllSource ? undefined : usageSources,
sourcesMap,
appNameMap,
title,
teamMemberIds: isSelectAllTmb ? undefined : selectTmbIds,
projectName
};
@ -81,8 +58,7 @@ const UsageTableList = ({
isSelectAllTmb,
projectName,
selectTmbIds,
usageSources,
t
usageSources
]);
const {
@ -103,7 +79,29 @@ const UsageTableList = ({
await downloadFetch({
url: `/api/proApi/support/wallet/usage/exportUsage`,
filename: `usage.csv`,
body: requestParams
body: {
...requestParams,
appNameMap: {
['core.app.Question Guide']: t('common:core.app.Question Guide'),
['common:support.wallet.usage.Audio Speech']: t(
'common:support.wallet.usage.Audio Speech'
),
['support.wallet.usage.Whisper']: t('common:support.wallet.usage.Whisper'),
['support.wallet.moduleName.index']: t('common:support.wallet.moduleName.index'),
['support.wallet.moduleName.qa']: t('common:support.wallet.moduleName.qa'),
['core.dataset.training.Auto mode']: t('common:core.dataset.training.Auto mode'),
['common:core.module.template.ai_chat']: t('common:core.module.template.ai_chat')
},
sourcesMap: Object.fromEntries(
Object.entries(UsageSourceMap).map(([key, config]) => [
key,
{
label: t(config.label as any)
}
])
),
title: t('account_usage:export_title')
}
});
},
{

View File

@ -5,6 +5,7 @@ import { llmModelTypeFilterMap } from '@fastgpt/global/core/ai/constants';
import AIModelSelector from '@/components/Select/AIModelSelector';
import { useContextSelector } from 'use-context-selector';
import { WorkflowContext } from '@/pageComponents/app/detail/WorkflowComponents/context';
import { getWebDefaultModel } from '@/web/common/system/utils';
const SelectAiModelRender = ({ item, nodeId }: RenderInputProps) => {
const { llmModelList } = useSystemStore();
@ -21,6 +22,9 @@ const SelectAiModelRender = ({ item, nodeId }: RenderInputProps) => {
}),
[llmModelList, item.llmModelType]
);
const defaultModel = useMemo(() => {
return getWebDefaultModel(modelList).model;
}, [modelList]);
const onChangeModel = useCallback(
(e: string) => {
@ -38,10 +42,10 @@ const SelectAiModelRender = ({ item, nodeId }: RenderInputProps) => {
);
useEffect(() => {
if (!item.value && modelList.length > 0) {
onChangeModel(modelList[0].model);
if (!modelList.find((model) => model.model === item.value) && !!defaultModel) {
onChangeModel(defaultModel);
}
}, []);
}, [defaultModel, item.value, modelList, onChangeModel]);
const Render = useMemo(() => {
return (

View File

@ -69,7 +69,7 @@ const Test = ({ datasetId }: { datasetId: string }) => {
usingReRank: false,
limit: 5000,
similarity: 0,
datasetSearchUsingExtensionQuery: true,
datasetSearchUsingExtensionQuery: false,
datasetSearchExtensionModel: defaultModels.llm?.model,
datasetSearchExtensionBg: ''
}

View File

@ -21,6 +21,7 @@ import MyIcon from '@fastgpt/web/components/common/Icon';
import { getDocPath } from '@/web/common/system/doc';
import { datasetTypeCourseMap } from '@/web/core/dataset/constants';
import ApiDatasetForm from '../ApiDatasetForm';
import { getWebDefaultModel } from '@/web/common/system/utils';
export type CreateDatasetType =
| DatasetTypeEnum.dataset
@ -79,7 +80,7 @@ const CreateModal = ({
name: '',
intro: '',
vectorModel: defaultModels.embedding?.model,
agentModel: defaultModels.llm?.model
agentModel: getWebDefaultModel(datasetModelList)?.model
}
});
const { register, setValue, handleSubmit, watch } = form;

View File

@ -38,7 +38,7 @@ async function handler(
return TrackModel.create(data);
}
export default NextAPI(useIPFrequencyLimit(1, 5), handler);
export default NextAPI(useIPFrequencyLimit({ id: 'push-tracks', seconds: 1, limit: 5 }), handler);
export const config = {
api: {

View File

@ -0,0 +1,22 @@
import type { ApiRequestProps, ApiResponseType } from '@fastgpt/service/type/next';
import { NextAPI } from '@/service/middleware/entry';
import { authSystemAdmin } from '@fastgpt/service/support/permission/user/auth';
import { getSystemModelConfig } from '@fastgpt/service/core/ai/config/utils';
import { SystemModelItemType } from '@fastgpt/service/core/ai/type';
export type getDefaultQuery = { model: string };
export type getDefaultBody = {};
async function handler(
req: ApiRequestProps<getDefaultBody, getDefaultQuery>,
res: ApiResponseType<any>
): Promise<SystemModelItemType> {
await authSystemAdmin({ req });
const model = req.query.model;
return getSystemModelConfig(model);
}
export default NextAPI(handler);

View File

@ -1,7 +1,7 @@
import type { ApiRequestProps, ApiResponseType } from '@fastgpt/service/type/next';
import { NextAPI } from '@/service/middleware/entry';
import { authSystemAdmin } from '@fastgpt/service/support/permission/user/auth';
import { findModelFromAlldata } from '@fastgpt/service/core/ai/model';
import { findModelFromAlldata, getReRankModel } from '@fastgpt/service/core/ai/model';
import {
EmbeddingModelItemType,
LLMModelItemType,
@ -120,6 +120,7 @@ const testSTTModel = async (model: STTModelType) => {
const testReRankModel = async (model: ReRankModelItemType) => {
await reRankRecall({
model,
query: 'Hi',
documents: [{ id: '1', text: 'Hi' }]
});

View File

@ -5,6 +5,7 @@ import { MongoSystemModel } from '@fastgpt/service/core/ai/config/schema';
import { loadSystemModels } from '@fastgpt/service/core/ai/config/utils';
import { updateFastGPTConfigBuffer } from '@fastgpt/service/common/system/config/controller';
import { ModelTypeEnum } from '@fastgpt/global/core/ai/model';
import { authSystemAdmin } from '@fastgpt/service/support/permission/user/auth';
export type updateDefaultQuery = {};
@ -22,10 +23,12 @@ async function handler(
req: ApiRequestProps<updateDefaultBody, updateDefaultQuery>,
res: ApiResponseType<any>
): Promise<updateDefaultResponse> {
await authSystemAdmin({ req });
const { llm, embedding, tts, stt, rerank } = req.body;
await mongoSessionRun(async (session) => {
await MongoSystemModel.updateMany({}, { $set: { 'metadata.isDefault': false } }, { session });
await MongoSystemModel.updateMany({}, { $unset: { 'metadata.isDefault': 1 } }, { session });
if (llm) {
await MongoSystemModel.updateOne(

View File

@ -100,4 +100,4 @@ async function handler(req: NextApiRequest) {
};
}
export default NextAPI(useIPFrequencyLimit(1, 15), handler);
export default NextAPI(useIPFrequencyLimit({ id: 'search-test', seconds: 1, limit: 15 }), handler);

View File

@ -70,4 +70,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
};
}
export default NextAPI(useIPFrequencyLimit(120, 10, true), handler);
export default NextAPI(
useIPFrequencyLimit({ id: 'login-by-password', seconds: 120, limit: 10, force: true }),
handler
);

View File

@ -90,7 +90,10 @@ async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
removeFilesByPaths(filePaths);
}
export default NextAPI(useIPFrequencyLimit(1, 1), handler);
export default NextAPI(
useIPFrequencyLimit({ id: 'transcriptions', seconds: 1, limit: 1 }),
handler
);
export const config = {
api: {

View File

@ -1,3 +1,4 @@
import { LLMModelItemType } from '@fastgpt/global/core/ai/model.d';
import { useSystemStore } from './useSystemStore';
export const downloadFetch = async ({
@ -43,5 +44,15 @@ export const downloadFetch = async ({
export const getWebLLMModel = (model?: string) => {
const list = useSystemStore.getState().llmModelList;
return list.find((item) => item.model === model || item.name === model) ?? list[0];
const defaultModels = useSystemStore.getState().defaultModels;
return list.find((item) => item.model === model || item.name === model) ?? defaultModels.llm!;
};
export const getWebDefaultModel = (llmList: LLMModelItemType[] = []) => {
const list = llmList.length > 0 ? llmList : useSystemStore.getState().llmModelList;
const defaultModels = useSystemStore.getState().defaultModels;
return defaultModels.llm && list.find((item) => item.model === defaultModels.llm?.model)
? defaultModels.llm
: list[0];
};

View File

@ -69,10 +69,6 @@ export const useAudioPlay = (
if (!response.body || !response.ok) {
const data = await response.json();
toast({
status: 'error',
title: getErrText(data, t('common:core.chat.Audio Speech Error'))
});
return Promise.reject(data);
}
return response.body;

View File

@ -10,6 +10,9 @@ export const getSystemModelList = () => GET<listResponse>('/core/ai/model/list')
export const getSystemModelDetail = (model: string) =>
GET<SystemModelItemType>('/core/ai/model/detail', { model });
export const getSystemModelDefaultConfig = (model: string) =>
GET<SystemModelItemType>('/core/ai/model/getDefaultConfig', { model });
export const putSystemModel = (data: updateBody) => PUT('/core/ai/model/update', data);
export const deleteSystemModel = (data: deleteQuery) => DELETE('/core/ai/model/delete', data);