Skip to content

Commit

Permalink
feat: markdown extension (#3663)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
c121914yu authored Jan 24, 2025
1 parent 02fcb6a commit d2948d7
Show file tree
Hide file tree
Showing 49 changed files with 662 additions and 280 deletions.
5 changes: 3 additions & 2 deletions docSite/content/zh-cn/docs/development/upgrading/4820.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ curl --location --request POST 'https://{{host}}/api/admin/initv4820' \

1. 新增 - 可视化模型参数配置。预设超过 100 个模型配置。同时支持所有类型模型的一键测试。(预计下个版本会完全支持在页面上配置渠道)。
2. 新增 - 使用记录导出和仪表盘。
3. 优化 - 页面组件抽离,减少页面组件路由。
4. 优化 - 全文检索,忽略大小写。
3. 新增 - markdown 语法扩展,支持音视频(代码块 audio 和 video)。
4. 优化 - 页面组件抽离,减少页面组件路由。
5. 优化 - 全文检索,忽略大小写。
17 changes: 13 additions & 4 deletions packages/service/common/middle/reqFrequencyLimit.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -9,22 +8,32 @@ 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)) {
return;
}
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`
});
}
};
Expand Down
10 changes: 9 additions & 1 deletion packages/service/common/response/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
58 changes: 29 additions & 29 deletions packages/service/core/ai/config/provider/Doubao.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -68,14 +68,14 @@
"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": false,
"toolChoice": true,
"vision": true,
"toolChoice": false,
"functionCall": false,
"defaultSystemChatPrompt": "",
"datasetProcess": true,
Expand All @@ -90,11 +90,11 @@
"type": "llm"
},
{
"model": "Doubao-pro-32k",
"name": "Doubao-pro-32k",
"maxContext": 32000,
"model": "Doubao-pro-4k",
"name": "Doubao-pro-4k",
"maxContext": 4000,
"maxResponse": 4000,
"quoteMaxToken": 32000,
"quoteMaxToken": 4000,
"maxTemperature": 1,
"vision": false,
"toolChoice": true,
Expand All @@ -112,11 +112,11 @@
"type": "llm"
},
{
"model": "Doubao-pro-4k",
"name": "Doubao-pro-4k",
"maxContext": 4000,
"model": "Doubao-pro-32k",
"name": "Doubao-pro-32k",
"maxContext": 32000,
"maxResponse": 4000,
"quoteMaxToken": 4000,
"quoteMaxToken": 32000,
"maxTemperature": 1,
"vision": false,
"toolChoice": true,
Expand All @@ -134,14 +134,14 @@
"type": "llm"
},
{
"model": "Doubao-vision-lite-32k",
"name": "Doubao-vision-lite-32k",
"maxContext": 32000,
"model": "Doubao-pro-128k",
"name": "Doubao-pro-128k",
"maxContext": 128000,
"maxResponse": 4000,
"quoteMaxToken": 32000,
"quoteMaxToken": 120000,
"maxTemperature": 1,
"vision": true,
"toolChoice": false,
"vision": false,
"toolChoice": true,
"functionCall": false,
"defaultSystemChatPrompt": "",
"datasetProcess": true,
Expand Down Expand Up @@ -192,4 +192,4 @@
"type": "embedding"
}
]
}
}
Loading

0 comments on commit d2948d7

Please sign in to comment.