diff --git a/docSite/content/zh-cn/docs/development/upgrading/492.md b/docSite/content/zh-cn/docs/development/upgrading/492.md index 73d156129..96f8b5304 100644 --- a/docSite/content/zh-cn/docs/development/upgrading/492.md +++ b/docSite/content/zh-cn/docs/development/upgrading/492.md @@ -25,7 +25,11 @@ weight: 799 2. 邀请链接交互。 3. 无 SSL 证书时复制失败,会提示弹窗用于手动复制。 4. FastGPT 未内置 ai proxy 渠道时,也能正常展示其名称。 +5. 升级 nextjs 版本至 14.2.25。 ## 🐛 修复 -1. 飞书和语雀知识库无法同步。 \ No newline at end of file +1. 飞书和语雀知识库无法同步。 +2. 渠道测试时,如果配置了模型自定义请求地址,会走自定义请求地址,而不是渠道请求地址。 +3. 语音识别模型测试未启用的模型时,无法正常测试。 +4. 管理员配置系统插件时,如果插件包含其他系统应用,无法正常鉴权。 \ No newline at end of file diff --git a/packages/global/core/plugin/type.d.ts b/packages/global/core/plugin/type.d.ts index 925e4549b..b38930ffe 100644 --- a/packages/global/core/plugin/type.d.ts +++ b/packages/global/core/plugin/type.d.ts @@ -41,6 +41,8 @@ export type PluginTemplateType = PluginRuntimeType & { export type PluginRuntimeType = { id: string; teamId?: string; + tmbId?: string; + name: string; avatar: string; showStatus?: boolean; diff --git a/packages/global/package.json b/packages/global/package.json index 70f7f1db4..c71c9d445 100644 --- a/packages/global/package.json +++ b/packages/global/package.json @@ -10,7 +10,7 @@ "js-yaml": "^4.1.0", "jschardet": "3.1.1", "nanoid": "^5.1.3", - "next": "14.2.24", + "next": "14.2.25", "openai": "4.61.0", "openapi-types": "^12.1.3", "json5": "^2.2.3", diff --git a/packages/service/core/ai/audio/transcriptions.ts b/packages/service/core/ai/audio/transcriptions.ts index 9d93ede9f..4cf7dc70f 100644 --- a/packages/service/core/ai/audio/transcriptions.ts +++ b/packages/service/core/ai/audio/transcriptions.ts @@ -3,21 +3,25 @@ import { getAxiosConfig } from '../config'; import axios from 'axios'; import FormData from 'form-data'; import { getSTTModel } from '../model'; +import { STTModelType } from '@fastgpt/global/core/ai/model.d'; export const aiTranscriptions = async ({ - model, + model: modelData, fileStream, headers }: { - model: string; + model: STTModelType; fileStream: fs.ReadStream; headers?: Record; }) => { + if (!modelData) { + return Promise.reject('no model'); + } + const data = new FormData(); - data.append('model', model); + data.append('model', modelData.model); data.append('file', fileStream); - const modelData = getSTTModel(model); const aiAxiosConfig = getAxiosConfig(); const { data: result } = await axios<{ text: string }>({ diff --git a/packages/service/core/app/plugin/controller.ts b/packages/service/core/app/plugin/controller.ts index 2d185686d..dbbb7e273 100644 --- a/packages/service/core/app/plugin/controller.ts +++ b/packages/service/core/app/plugin/controller.ts @@ -37,11 +37,12 @@ export async function splitCombinePluginId(id: string) { return { source, pluginId: id }; } -type ChildAppType = SystemPluginTemplateItemType & { teamId?: string }; +type ChildAppType = SystemPluginTemplateItemType & { teamId?: string; tmbId?: string }; + const getSystemPluginTemplateById = async ( pluginId: string, versionId?: string -): Promise => { +): Promise => { const item = getSystemPluginTemplates().find((plugin) => plugin.id === pluginId); if (!item) return Promise.reject(PluginErrEnum.unAuth); @@ -67,12 +68,17 @@ const getSystemPluginTemplateById = async ( : await getAppLatestVersion(plugin.associatedPluginId, app); if (!version.versionId) return Promise.reject('App version not found'); - plugin.workflow = { - nodes: version.nodes, - edges: version.edges, - chatConfig: version.chatConfig + return { + ...plugin, + workflow: { + nodes: version.nodes, + edges: version.edges, + chatConfig: version.chatConfig + }, + version: versionId || String(version.versionId), + teamId: String(app.teamId), + tmbId: String(app.tmbId) }; - plugin.version = versionId || String(version.versionId); } return plugin; }; @@ -168,6 +174,7 @@ export async function getChildAppRuntimeById( return { id: String(item._id), teamId: String(item.teamId), + tmbId: String(item.tmbId), name: item.name, avatar: item.avatar, intro: item.intro, @@ -187,6 +194,7 @@ export async function getChildAppRuntimeById( pluginOrder: 0 }; } else { + // System return getSystemPluginTemplateById(pluginId, versionId); } })(); @@ -194,6 +202,7 @@ export async function getChildAppRuntimeById( return { id: app.id, teamId: app.teamId, + tmbId: app.tmbId, name: app.name, avatar: app.avatar, showStatus: app.showStatus, diff --git a/packages/service/core/workflow/dispatch/plugin/run.ts b/packages/service/core/workflow/dispatch/plugin/run.ts index a81a6a867..b50995200 100644 --- a/packages/service/core/workflow/dispatch/plugin/run.ts +++ b/packages/service/core/workflow/dispatch/plugin/run.ts @@ -88,9 +88,9 @@ export const dispatchRunPlugin = async (props: RunPluginProps): Promise= 10'} cpu: [arm64] os: [darwin] - '@next/swc-darwin-x64@14.2.24': - resolution: {integrity: sha512-lXR2WQqUtu69l5JMdTwSvQUkdqAhEWOqJEYUQ21QczQsAlNOW2kWZCucA6b3EXmPbcvmHB1kSZDua/713d52xg==} + '@next/swc-darwin-x64@14.2.25': + resolution: {integrity: sha512-V+iYM/QR+aYeJl3/FWWU/7Ix4b07ovsQ5IbkwgUK29pTHmq+5UxeDr7/dphvtXEq5pLB/PucfcBNh9KZ8vWbug==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] - '@next/swc-linux-arm64-gnu@14.2.24': - resolution: {integrity: sha512-nxvJgWOpSNmzidYvvGDfXwxkijb6hL9+cjZx1PVG6urr2h2jUqBALkKjT7kpfurRWicK6hFOvarmaWsINT1hnA==} + '@next/swc-linux-arm64-gnu@14.2.25': + resolution: {integrity: sha512-LFnV2899PJZAIEHQ4IMmZIgL0FBieh5keMnriMY1cK7ompR+JUd24xeTtKkcaw8QmxmEdhoE5Mu9dPSuDBgtTg==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] - '@next/swc-linux-arm64-musl@14.2.24': - resolution: {integrity: sha512-PaBgOPhqa4Abxa3y/P92F3kklNPsiFjcjldQGT7kFmiY5nuFn8ClBEoX8GIpqU1ODP2y8P6hio6vTomx2Vy0UQ==} + '@next/swc-linux-arm64-musl@14.2.25': + resolution: {integrity: sha512-QC5y5PPTmtqFExcKWKYgUNkHeHE/z3lUsu83di488nyP0ZzQ3Yse2G6TCxz6nNsQwgAx1BehAJTZez+UQxzLfw==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] - '@next/swc-linux-x64-gnu@14.2.24': - resolution: {integrity: sha512-vEbyadiRI7GOr94hd2AB15LFVgcJZQWu7Cdi9cWjCMeCiUsHWA0U5BkGPuoYRnTxTn0HacuMb9NeAmStfBCLoQ==} + '@next/swc-linux-x64-gnu@14.2.25': + resolution: {integrity: sha512-y6/ML4b9eQ2D/56wqatTJN5/JR8/xdObU2Fb1RBidnrr450HLCKr6IJZbPqbv7NXmje61UyxjF5kvSajvjye5w==} engines: {node: '>= 10'} cpu: [x64] os: [linux] - '@next/swc-linux-x64-musl@14.2.24': - resolution: {integrity: sha512-df0FC9ptaYsd8nQCINCzFtDWtko8PNRTAU0/+d7hy47E0oC17tI54U/0NdGk7l/76jz1J377dvRjmt6IUdkpzQ==} + '@next/swc-linux-x64-musl@14.2.25': + resolution: {integrity: sha512-sPX0TSXHGUOZFvv96GoBXpB3w4emMqKeMgemrSxI7A6l55VBJp/RKYLwZIB9JxSqYPApqiREaIIap+wWq0RU8w==} engines: {node: '>= 10'} cpu: [x64] os: [linux] - '@next/swc-win32-arm64-msvc@14.2.24': - resolution: {integrity: sha512-ZEntbLjeYAJ286eAqbxpZHhDFYpYjArotQ+/TW9j7UROh0DUmX7wYDGtsTPpfCV8V+UoqHBPU7q9D4nDNH014Q==} + '@next/swc-win32-arm64-msvc@14.2.25': + resolution: {integrity: sha512-ReO9S5hkA1DU2cFCsGoOEp7WJkhFzNbU/3VUF6XxNGUCQChyug6hZdYL/istQgfT/GWE6PNIg9cm784OI4ddxQ==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] - '@next/swc-win32-ia32-msvc@14.2.24': - resolution: {integrity: sha512-9KuS+XUXM3T6v7leeWU0erpJ6NsFIwiTFD5nzNg8J5uo/DMIPvCp3L1Ao5HjbHX0gkWPB1VrKoo/Il4F0cGK2Q==} + '@next/swc-win32-ia32-msvc@14.2.25': + resolution: {integrity: sha512-DZ/gc0o9neuCDyD5IumyTGHVun2dCox5TfPQI/BJTYwpSNYM3CZDI4i6TOdjeq1JMo+Ug4kPSMuZdwsycwFbAw==} engines: {node: '>= 10'} cpu: [ia32] os: [win32] - '@next/swc-win32-x64-msvc@14.2.24': - resolution: {integrity: sha512-cXcJ2+x0fXQ2CntaE00d7uUH+u1Bfp/E0HsNQH79YiLaZE5Rbm7dZzyAYccn3uICM7mw+DxoMqEfGXZtF4Fgaw==} + '@next/swc-win32-x64-msvc@14.2.25': + resolution: {integrity: sha512-KSznmS6eFjQ9RJ1nEc66kJvtGIL1iZMYmGEXsZPh2YtnLtqrgdVvKXJY2ScjjoFnG6nGLyPFR0UiEvDwVah4Tw==} engines: {node: '>= 10'} cpu: [x64] os: [win32] @@ -7191,8 +7191,8 @@ packages: react: '>= 17.0.2' react-i18next: '>= 13.5.0' - next@14.2.24: - resolution: {integrity: sha512-En8VEexSJ0Py2FfVnRRh8gtERwDRaJGNvsvad47ShkC2Yi8AXQPXEA2vKoDJlGFSj5WE5SyF21zNi4M5gyi+SQ==} + next@14.2.25: + resolution: {integrity: sha512-N5M7xMc4wSb4IkPvEV5X2BRRXUmhVHNyaXwEM86+voXthSZz8ZiRyQW4p9mwAoAPIm6OzuVZtn7idgEJeAJN3Q==} engines: {node: '>=18.17.0'} hasBin: true peerDependencies: @@ -10652,12 +10652,12 @@ snapshots: '@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@2.4.2(@chakra-ui/react@2.10.7(@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.24(@babel/core@7.26.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.85.1))(react@18.3.1)': + '@chakra-ui/next-js@2.4.2(@chakra-ui/react@2.10.7(@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.25(@babel/core@7.26.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.85.1))(react@18.3.1)': dependencies: '@chakra-ui/react': 2.10.7(@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.14.0 '@emotion/react': 11.11.1(@types/react@18.3.1)(react@18.3.1) - next: 14.2.24(@babel/core@7.26.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.85.1) + next: 14.2.25(@babel/core@7.26.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.85.1) react: 18.3.1 '@chakra-ui/object-utils@2.1.0': {} @@ -11665,37 +11665,37 @@ snapshots: '@nestjs/core': 10.4.15(@nestjs/common@10.4.15(reflect-metadata@0.2.2)(rxjs@7.8.2))(encoding@0.1.13)(reflect-metadata@0.2.2)(rxjs@7.8.2) tslib: 2.8.1 - '@next/env@14.2.24': {} + '@next/env@14.2.25': {} '@next/eslint-plugin-next@14.2.24': dependencies: glob: 10.3.10 - '@next/swc-darwin-arm64@14.2.24': + '@next/swc-darwin-arm64@14.2.25': optional: true - '@next/swc-darwin-x64@14.2.24': + '@next/swc-darwin-x64@14.2.25': optional: true - '@next/swc-linux-arm64-gnu@14.2.24': + '@next/swc-linux-arm64-gnu@14.2.25': optional: true - '@next/swc-linux-arm64-musl@14.2.24': + '@next/swc-linux-arm64-musl@14.2.25': optional: true - '@next/swc-linux-x64-gnu@14.2.24': + '@next/swc-linux-x64-gnu@14.2.25': optional: true - '@next/swc-linux-x64-musl@14.2.24': + '@next/swc-linux-x64-musl@14.2.25': optional: true - '@next/swc-win32-arm64-msvc@14.2.24': + '@next/swc-win32-arm64-msvc@14.2.25': optional: true - '@next/swc-win32-ia32-msvc@14.2.24': + '@next/swc-win32-ia32-msvc@14.2.25': optional: true - '@next/swc-win32-x64-msvc@14.2.24': + '@next/swc-win32-x64-msvc@14.2.25': optional: true '@node-rs/jieba-android-arm-eabi@2.0.1': @@ -17532,7 +17532,7 @@ snapshots: transitivePeerDependencies: - supports-color - next-i18next@15.4.2(i18next@23.16.8)(next@14.2.24(@babel/core@7.26.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.85.1))(react-i18next@14.1.2(i18next@23.16.8)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1): + next-i18next@15.4.2(i18next@23.16.8)(next@14.2.25(@babel/core@7.26.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.85.1))(react-i18next@14.1.2(i18next@23.16.8)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1): dependencies: '@babel/runtime': 7.26.10 '@types/hoist-non-react-statics': 3.3.6 @@ -17540,13 +17540,13 @@ snapshots: hoist-non-react-statics: 3.3.2 i18next: 23.16.8 i18next-fs-backend: 2.6.0 - next: 14.2.24(@babel/core@7.26.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.85.1) + next: 14.2.25(@babel/core@7.26.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.85.1) react: 18.3.1 react-i18next: 14.1.2(i18next@23.16.8)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) - next@14.2.24(@babel/core@7.26.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.85.1): + next@14.2.25(@babel/core@7.26.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.85.1): dependencies: - '@next/env': 14.2.24 + '@next/env': 14.2.25 '@swc/helpers': 0.5.5 busboy: 1.6.0 caniuse-lite: 1.0.30001704 @@ -17556,24 +17556,24 @@ snapshots: react-dom: 18.3.1(react@18.3.1) styled-jsx: 5.1.1(@babel/core@7.26.10)(react@18.3.1) optionalDependencies: - '@next/swc-darwin-arm64': 14.2.24 - '@next/swc-darwin-x64': 14.2.24 - '@next/swc-linux-arm64-gnu': 14.2.24 - '@next/swc-linux-arm64-musl': 14.2.24 - '@next/swc-linux-x64-gnu': 14.2.24 - '@next/swc-linux-x64-musl': 14.2.24 - '@next/swc-win32-arm64-msvc': 14.2.24 - '@next/swc-win32-ia32-msvc': 14.2.24 - '@next/swc-win32-x64-msvc': 14.2.24 + '@next/swc-darwin-arm64': 14.2.25 + '@next/swc-darwin-x64': 14.2.25 + '@next/swc-linux-arm64-gnu': 14.2.25 + '@next/swc-linux-arm64-musl': 14.2.25 + '@next/swc-linux-x64-gnu': 14.2.25 + '@next/swc-linux-x64-musl': 14.2.25 + '@next/swc-win32-arm64-msvc': 14.2.25 + '@next/swc-win32-ia32-msvc': 14.2.25 + '@next/swc-win32-x64-msvc': 14.2.25 sass: 1.85.1 transitivePeerDependencies: - '@babel/core' - babel-plugin-macros - nextjs-cors@2.2.0(next@14.2.24(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.85.1)): + nextjs-cors@2.2.0(next@14.2.25(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.85.1)): dependencies: cors: 2.8.5 - next: 14.2.24(@babel/core@7.26.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.85.1) + next: 14.2.25(@babel/core@7.26.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.85.1) node-abi@3.74.0: dependencies: diff --git a/projects/app/package.json b/projects/app/package.json index 60a43cdde..b37c1b5ad 100644 --- a/projects/app/package.json +++ b/projects/app/package.json @@ -42,7 +42,7 @@ "lodash": "^4.17.21", "mermaid": "^10.2.3", "nanoid": "^5.1.3", - "next": "14.2.24", + "next": "14.2.25", "next-i18next": "15.4.2", "nprogress": "^0.2.0", "qrcode": "^1.5.4", diff --git a/projects/app/src/components/core/app/DatasetSelectModal.tsx b/projects/app/src/components/core/app/DatasetSelectModal.tsx index 8ec04227a..7010ae218 100644 --- a/projects/app/src/components/core/app/DatasetSelectModal.tsx +++ b/projects/app/src/components/core/app/DatasetSelectModal.tsx @@ -69,31 +69,37 @@ export const DatasetSelectModal = ({ {selectedDatasets.map((item) => (() => { return ( - - - - - {item.name} - - { - setSelectedDatasets((state) => - state.filter((dataset) => dataset.datasetId !== item.datasetId) - ); - }} - /> - - + + + + + + {item.name} + + { + setSelectedDatasets((state) => + state.filter((dataset) => dataset.datasetId !== item.datasetId) + ); + }} + /> + + + ); })() )} @@ -117,7 +123,7 @@ export const DatasetSelectModal = ({ label={ item.type === DatasetTypeEnum.folder ? t('common:dataset.Select Folder') - : t('common:dataset.Select Dataset') + : item.name } > - + {item.name} diff --git a/projects/app/src/components/core/chat/components/AIResponseBox.tsx b/projects/app/src/components/core/chat/components/AIResponseBox.tsx index 9131631aa..45759061f 100644 --- a/projects/app/src/components/core/chat/components/AIResponseBox.tsx +++ b/projects/app/src/components/core/chat/components/AIResponseBox.tsx @@ -268,12 +268,10 @@ const RenderUserFormInteractive = React.memo(function RenderFormInput({ {interactive.params.description && } {interactive.params.inputForm?.map((input) => ( - - - {input.label} - {input.description && } - - + + {input.label} + {input.description && } + {input.type === FlowNodeInputTypeEnum.input && ( - - {activeModule?.searchUsingReRank ? ( - activeModule?.rerankModel ? ( - {`${activeModule.rerankModel}: ${activeModule.rerankWeight}`} + {activeModule?.searchUsingReRank !== undefined && ( + + {activeModule?.searchUsingReRank ? ( + activeModule?.rerankModel ? ( + {`${activeModule.rerankModel}: ${activeModule.rerankWeight}`} + ) : ( + 'True' + ) ) : ( - 'True' - ) - ) : ( - `False` - )} - - } - /> + `False` + )} + + } + /> + )} {activeModule.queryExtensionResult && ( <> import('./EditChannelModal'), { ssr: false }); const ModelTest = dynamic(() => import('./ModelTest'), { ssr: false }); @@ -77,6 +78,9 @@ const ChannelTable = ({ Tab }: { Tab: React.ReactNode }) => { } ); + const { openConfirm, ConfirmModal } = useConfirm({ + type: 'delete' + }); const { runAsync: onDeleteChannel, loading: loadingDeleteChannel } = useRequest2(deleteChannel, { manual: true, onSuccess: () => { @@ -212,7 +216,14 @@ const ChannelTable = ({ Tab }: { Tab: React.ReactNode }) => { type: 'danger', icon: 'delete', label: t('common:common.Delete'), - onClick: () => onDeleteChannel(item.id) + onClick: () => + openConfirm( + () => onDeleteChannel(item.id), + undefined, + t('account_model:confirm_delete_channel', { + name: item.name + }) + )() } ] } @@ -238,6 +249,7 @@ const ChannelTable = ({ Tab }: { Tab: React.ReactNode }) => { {!!modelTestData && ( setTestModelData(undefined)} /> )} + ); }; diff --git a/projects/app/src/pageComponents/account/model/Log/index.tsx b/projects/app/src/pageComponents/account/model/Log/index.tsx index afe811895..f57ad9d69 100644 --- a/projects/app/src/pageComponents/account/model/Log/index.tsx +++ b/projects/app/src/pageComponents/account/model/Log/index.tsx @@ -197,7 +197,7 @@ const ChannelLog = ({ Tab }: { Tab: React.ReactNode }) => { /> - + {t('account_model:channel_name')} @@ -210,7 +210,7 @@ const ChannelLog = ({ Tab }: { Tab: React.ReactNode }) => { /> - + {t('account_model:model_name')} diff --git a/projects/app/src/pageComponents/dataset/detail/Import/commonProgress/PreviewData.tsx b/projects/app/src/pageComponents/dataset/detail/Import/commonProgress/PreviewData.tsx index 37a09bc2c..57eab40ee 100644 --- a/projects/app/src/pageComponents/dataset/detail/Import/commonProgress/PreviewData.tsx +++ b/projects/app/src/pageComponents/dataset/detail/Import/commonProgress/PreviewData.tsx @@ -34,9 +34,9 @@ const PreviewData = () => { const [previewFile, setPreviewFile] = useState(); - const { data = [], loading: isLoading } = useRequest2( + const { data = { chunks: [], total: 0 }, loading: isLoading } = useRequest2( async () => { - if (!previewFile) return; + if (!previewFile) return { chunks: [], total: 0 }; if (importSource === ImportDataSourceEnum.fileCustom) { const chunkSplitter = processParamsForm.getValues('chunkSplitter'); const { chunks } = splitText2Chunks({ @@ -46,10 +46,13 @@ const PreviewData = () => { overlapRatio: chunkOverlapRatio, customReg: chunkSplitter ? [chunkSplitter] : [] }); - return chunks.map((chunk) => ({ - q: chunk, - a: '' - })); + return { + chunks: chunks.map((chunk) => ({ + q: chunk, + a: '' + })), + total: chunks.length + }; } return getPreviewChunks({ @@ -81,7 +84,7 @@ const PreviewData = () => { manual: false, onSuccess(result) { if (!previewFile) return; - if (!result || result.length === 0) { + if (!result || result.total === 0) { toast({ title: t('dataset:preview_chunk_empty'), status: 'error' @@ -130,14 +133,14 @@ const PreviewData = () => { {t('dataset:preview_chunk')} - {t('dataset:preview_chunk_intro')} + {t('dataset:preview_chunk_intro', { total: data.total })} {previewFile ? ( <> - {data.map((item, index) => ( + {data.chunks.map((item, index) => ( = channelId ? { 'Aiproxy-Channel': String(channelId) } : {}; + addLog.debug(`Test model`, modelData); if (modelData.type === 'llm') { return testLLMModel(modelData, headers); @@ -63,10 +69,6 @@ async function handler( export default NextAPI(handler); const testLLMModel = async (model: LLMModelItemType, headers: Record) => { - const ai = getAIApi({ - timeout: 10000 - }); - const requestBody = llmCompletionsBodyFormat( { model: model.model, @@ -75,6 +77,7 @@ const testLLMModel = async (model: LLMModelItemType, headers: Record const testSTTModel = async (model: STTModelType, headers: Record) => { const path = isProduction ? '/app/data/test.mp3' : 'data/test.mp3'; const { text } = await aiTranscriptions({ - model: model.model, + model, fileStream: fs.createReadStream(path), headers }); diff --git a/projects/app/src/pages/api/core/dataset/file/getPreviewChunks.ts b/projects/app/src/pages/api/core/dataset/file/getPreviewChunks.ts index caba7d922..dfa34727f 100644 --- a/projects/app/src/pages/api/core/dataset/file/getPreviewChunks.ts +++ b/projects/app/src/pages/api/core/dataset/file/getPreviewChunks.ts @@ -43,9 +43,12 @@ export type PostPreviewFilesChunksProps = { externalFileId?: string; }; export type PreviewChunksResponse = { - q: string; - a: string; -}[]; + chunks: { + q: string; + a: string; + }[]; + total: number; +}; async function handler( req: ApiRequestProps @@ -123,13 +126,17 @@ async function handler( customPdfParse }); - return rawText2Chunks({ + const chunks = rawText2Chunks({ rawText, chunkSize, maxSize: getLLMMaxChunkSize(getLLMModel(dataset.agentModel)), overlapRatio, customReg: chunkSplitter ? [chunkSplitter] : [], isQAImport: isQAImport - }).slice(0, 10); + }); + return { + chunks: chunks.slice(0, 10), + total: chunks.length + }; } export default NextAPI(handler); diff --git a/projects/app/src/pages/api/v1/audio/transcriptions.ts b/projects/app/src/pages/api/v1/audio/transcriptions.ts index 5f8581595..6a6d896ff 100644 --- a/projects/app/src/pages/api/v1/audio/transcriptions.ts +++ b/projects/app/src/pages/api/v1/audio/transcriptions.ts @@ -66,7 +66,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) { // } const result = await aiTranscriptions({ - model: getDefaultSTTModel().model, + model: getDefaultSTTModel(), fileStream: fs.createReadStream(file.path) });