mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-01 20:27:45 +00:00

* New chatinput (#4995) * feat: Change border style * refactor: Improve layout and styling of ChatInput component * style: Update ChatInput component styling and mobile layout * fix: update key detection for Enter key in ChatInput component * feat: 添加 WelcomePage 组件,支持变量输入和欢迎信息展示 * style: Updated the PC voice input interface of the VoiceInput component and optimized the layout and style * style: Optimize the layout and style of the WelcomePage component, and adjust the responsive design * feat: Dynamically load the WelcomePage component and optimize the welcome information display logic * refactor: Adjust the style and behavior of the ChatInput component and delete the WelcomePage component * style: Modify the minimum height setting of the ChatInput component to simplify responsive design * style: Optimize the layout and style of PC voice input components, and enhance the processing and drawing logic of waveform data * style: Adjust ChatInput component's margin and textarea height logic for improved layout and responsiveness; refine PCVoiceInput component's positioning and display elements * style: Enhance PCVoiceInput component's time display styling with custom font properties * feat: Change border style * refactor: Improve layout and styling of ChatInput component * style: Update ChatInput component styling and mobile layout * fix: update key detection for Enter key in ChatInput component * feat: 添加 WelcomePage 组件,支持变量输入和欢迎信息展示 * style: Updated the PC voice input interface of the VoiceInput component and optimized the layout and style * style: Optimize the layout and style of the WelcomePage component, and adjust the responsive design * feat: Dynamically load the WelcomePage component and optimize the welcome information display logic * refactor: Adjust the style and behavior of the ChatInput component and delete the WelcomePage component * style: Modify the minimum height setting of the ChatInput component to simplify responsive design * style: Optimize the layout and style of PC voice input components, and enhance the processing and drawing logic of waveform data * style: Adjust ChatInput component's margin and textarea height logic for improved layout and responsiveness; refine PCVoiceInput component's positioning and display elements * style: Enhance PCVoiceInput component's time display styling with custom font properties * style: Add new 'xxl' size to theme spacing for improved layout options * style: Update close icon fill color to use currentColor for better theming support * style: Enhance voice input functionality and UI responsiveness; improve waveform sensitivity and amplitude * style: Conditionally render file preview based on voice input state * style: 优化移动端音频波形渲染,增强清晰度和敏感度 * style: Update comments to English to enhance code readability and consistency * style: Adjust the mobile audio waveform update frequency and optimize rendering performance * style: Optimize the file preview rendering logic in voice input mode to enhance user experience * style: Optimize the file preview rendering logic in voice input mode to enhance user experience * style: Adjust the chat input box placeholder color and border color to enhance visual effects * fix: pg test * Test secret (#5011) * add http header auth config (#4982) * add http header auth config * optimize code * add mcp tools header auth * fix build * fix ui * fix * teamid * secret value encrypt (#5002) * perf: secret code * header auth ui (#5012) * header auth ui * fix i18n * doc * perf: type * header secret ui * reset ui * perf: check secret invalid --------- Co-authored-by: heheer <heheer@sealos.io> * feat: cq and extrat AI memory (#5013) * fix: login xss * feat: Users can download the invoice by self (#5015) * Users can download the invoice by themselves * Direct file stream implementation for transmission presentation * i18n * Chatbox-fix (#5018) * feat: Change border style * refactor: Improve layout and styling of ChatInput component * style: Update ChatInput component styling and mobile layout * fix: update key detection for Enter key in ChatInput component * feat: 添加 WelcomePage 组件,支持变量输入和欢迎信息展示 * style: Updated the PC voice input interface of the VoiceInput component and optimized the layout and style * style: Optimize the layout and style of the WelcomePage component, and adjust the responsive design * feat: Dynamically load the WelcomePage component and optimize the welcome information display logic * refactor: Adjust the style and behavior of the ChatInput component and delete the WelcomePage component * style: Modify the minimum height setting of the ChatInput component to simplify responsive design * style: Optimize the layout and style of PC voice input components, and enhance the processing and drawing logic of waveform data * style: Adjust ChatInput component's margin and textarea height logic for improved layout and responsiveness; refine PCVoiceInput component's positioning and display elements * style: Enhance PCVoiceInput component's time display styling with custom font properties * feat: Change border style * refactor: Improve layout and styling of ChatInput component * style: Update ChatInput component styling and mobile layout * fix: update key detection for Enter key in ChatInput component * feat: 添加 WelcomePage 组件,支持变量输入和欢迎信息展示 * style: Updated the PC voice input interface of the VoiceInput component and optimized the layout and style * style: Optimize the layout and style of the WelcomePage component, and adjust the responsive design * feat: Dynamically load the WelcomePage component and optimize the welcome information display logic * refactor: Adjust the style and behavior of the ChatInput component and delete the WelcomePage component * style: Modify the minimum height setting of the ChatInput component to simplify responsive design * style: Optimize the layout and style of PC voice input components, and enhance the processing and drawing logic of waveform data * style: Adjust ChatInput component's margin and textarea height logic for improved layout and responsiveness; refine PCVoiceInput component's positioning and display elements * style: Enhance PCVoiceInput component's time display styling with custom font properties * style: Add new 'xxl' size to theme spacing for improved layout options * style: Update close icon fill color to use currentColor for better theming support * style: Enhance voice input functionality and UI responsiveness; improve waveform sensitivity and amplitude * style: Conditionally render file preview based on voice input state * style: 优化移动端音频波形渲染,增强清晰度和敏感度 * style: Update comments to English to enhance code readability and consistency * style: Adjust the mobile audio waveform update frequency and optimize rendering performance * style: Optimize the file preview rendering logic in voice input mode to enhance user experience * style: Optimize the file preview rendering logic in voice input mode to enhance user experience * style: Adjust the chat input box placeholder color and border color to enhance visual effects * New chatinput (#4995) * feat: Change border style * refactor: Improve layout and styling of ChatInput component * style: Update ChatInput component styling and mobile layout * fix: update key detection for Enter key in ChatInput component * feat: 添加 WelcomePage 组件,支持变量输入和欢迎信息展示 * style: Updated the PC voice input interface of the VoiceInput component and optimized the layout and style * style: Optimize the layout and style of the WelcomePage component, and adjust the responsive design * feat: Dynamically load the WelcomePage component and optimize the welcome information display logic * refactor: Adjust the style and behavior of the ChatInput component and delete the WelcomePage component * style: Modify the minimum height setting of the ChatInput component to simplify responsive design * style: Optimize the layout and style of PC voice input components, and enhance the processing and drawing logic of waveform data * style: Adjust ChatInput component's margin and textarea height logic for improved layout and responsiveness; refine PCVoiceInput component's positioning and display elements * style: Enhance PCVoiceInput component's time display styling with custom font properties * feat: Change border style * refactor: Improve layout and styling of ChatInput component * style: Update ChatInput component styling and mobile layout * fix: update key detection for Enter key in ChatInput component * feat: 添加 WelcomePage 组件,支持变量输入和欢迎信息展示 * style: Updated the PC voice input interface of the VoiceInput component and optimized the layout and style * style: Optimize the layout and style of the WelcomePage component, and adjust the responsive design * feat: Dynamically load the WelcomePage component and optimize the welcome information display logic * refactor: Adjust the style and behavior of the ChatInput component and delete the WelcomePage component * style: Modify the minimum height setting of the ChatInput component to simplify responsive design * style: Optimize the layout and style of PC voice input components, and enhance the processing and drawing logic of waveform data * style: Adjust ChatInput component's margin and textarea height logic for improved layout and responsiveness; refine PCVoiceInput component's positioning and display elements * style: Enhance PCVoiceInput component's time display styling with custom font properties * style: Add new 'xxl' size to theme spacing for improved layout options * style: Update close icon fill color to use currentColor for better theming support * style: Enhance voice input functionality and UI responsiveness; improve waveform sensitivity and amplitude * style: Conditionally render file preview based on voice input state * style: 优化移动端音频波形渲染,增强清晰度和敏感度 * style: Update comments to English to enhance code readability and consistency * style: Adjust the mobile audio waveform update frequency and optimize rendering performance * style: Optimize the file preview rendering logic in voice input mode to enhance user experience * style: Optimize the file preview rendering logic in voice input mode to enhance user experience * style: Adjust the chat input box placeholder color and border color to enhance visual effects * fix: pg test * Test secret (#5011) * add http header auth config (#4982) * add http header auth config * optimize code * add mcp tools header auth * fix build * fix ui * fix * teamid * secret value encrypt (#5002) * perf: secret code * header auth ui (#5012) * header auth ui * fix i18n * doc * perf: type * header secret ui * reset ui * perf: check secret invalid --------- Co-authored-by: heheer <heheer@sealos.io> * feat: cq and extrat AI memory (#5013) * refactor: Refactored the ChatInput component, optimized the layout of the text area and button group, and improved the user experience * refactor: Updated ChatInput component, optimized layout and style, and enhanced user experience * feat: update docs --------- Co-authored-by: archer <545436317@qq.com> Co-authored-by: heheer <heheer@sealos.io> * input ui * fix: chat input ux * Return in JSON format to handle checkres (#5019) * Users can download the invoice by themselves * Direct file stream implementation for transmission presentation * Return in JSON format to handle checkres * fix: invoice * fix: ui * doc * update package * fix: ts * fix: login checker * fix: team plan * perf: aiproxy ux --------- Co-authored-by: Theresa <63280168+sd0ric4@users.noreply.github.com> Co-authored-by: heheer <heheer@sealos.io> Co-authored-by: Zhuangzai fa <143257420+ctrlz526@users.noreply.github.com>
171 lines
5.1 KiB
TypeScript
171 lines
5.1 KiB
TypeScript
import { MongoDataset } from '../dataset/schema';
|
|
import { getEmbeddingModel } from '../ai/model';
|
|
import { FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant';
|
|
import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants';
|
|
import type { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node';
|
|
import { getChildAppPreviewNode, splitCombineToolId } from './plugin/controller';
|
|
import { PluginSourceEnum } from '@fastgpt/global/core/plugin/constants';
|
|
import { authAppByTmbId } from '../../support/permission/app/auth';
|
|
import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
|
|
import { getErrText } from '@fastgpt/global/common/error/utils';
|
|
|
|
export async function listAppDatasetDataByTeamIdAndDatasetIds({
|
|
teamId,
|
|
datasetIdList
|
|
}: {
|
|
teamId?: string;
|
|
datasetIdList: string[];
|
|
}) {
|
|
const myDatasets = await MongoDataset.find({
|
|
_id: { $in: datasetIdList },
|
|
...(teamId && { teamId })
|
|
}).lean();
|
|
|
|
return myDatasets.map((item) => ({
|
|
datasetId: String(item._id),
|
|
avatar: item.avatar,
|
|
name: item.name,
|
|
vectorModel: getEmbeddingModel(item.vectorModel)
|
|
}));
|
|
}
|
|
|
|
export async function rewriteAppWorkflowToDetail({
|
|
nodes,
|
|
teamId,
|
|
isRoot,
|
|
ownerTmbId
|
|
}: {
|
|
nodes: StoreNodeItemType[];
|
|
teamId: string;
|
|
isRoot: boolean;
|
|
ownerTmbId: string;
|
|
}) {
|
|
const datasetIdSet = new Set<string>();
|
|
|
|
/* Add node(App Type) versionlabel and latest sign ==== */
|
|
await Promise.all(
|
|
nodes.map(async (node) => {
|
|
if (!node.pluginId) return;
|
|
const { source } = splitCombineToolId(node.pluginId);
|
|
|
|
try {
|
|
const [preview] = await Promise.all([
|
|
getChildAppPreviewNode({
|
|
appId: node.pluginId,
|
|
versionId: node.version
|
|
}),
|
|
...(source === PluginSourceEnum.personal
|
|
? [
|
|
authAppByTmbId({
|
|
tmbId: ownerTmbId,
|
|
appId: node.pluginId,
|
|
per: ReadPermissionVal
|
|
})
|
|
]
|
|
: [])
|
|
]);
|
|
|
|
node.pluginData = {
|
|
diagram: preview.diagram,
|
|
userGuide: preview.userGuide,
|
|
courseUrl: preview.courseUrl,
|
|
name: preview.name,
|
|
avatar: preview.avatar
|
|
};
|
|
node.versionLabel = preview.versionLabel;
|
|
node.isLatestVersion = preview.isLatestVersion;
|
|
node.version = preview.version;
|
|
} catch (error) {
|
|
node.pluginData = {
|
|
error: getErrText(error)
|
|
};
|
|
}
|
|
})
|
|
);
|
|
|
|
// Get all dataset ids from nodes
|
|
nodes.forEach((node) => {
|
|
if (node.flowNodeType !== FlowNodeTypeEnum.datasetSearchNode) return;
|
|
|
|
const input = node.inputs.find((item) => item.key === NodeInputKeyEnum.datasetSelectList);
|
|
if (!input) return;
|
|
|
|
const rawValue = input.value as undefined | { datasetId: string }[] | { datasetId: string };
|
|
if (!rawValue) return;
|
|
|
|
const datasetIds = Array.isArray(rawValue)
|
|
? rawValue.map((v) => v?.datasetId).filter((id) => !!id && typeof id === 'string')
|
|
: rawValue?.datasetId
|
|
? [String(rawValue.datasetId)]
|
|
: [];
|
|
|
|
datasetIds.forEach((id) => datasetIdSet.add(id));
|
|
});
|
|
|
|
if (datasetIdSet.size === 0) return;
|
|
|
|
// Load dataset list
|
|
const datasetList = await listAppDatasetDataByTeamIdAndDatasetIds({
|
|
teamId: isRoot ? undefined : teamId,
|
|
datasetIdList: Array.from(datasetIdSet)
|
|
});
|
|
const datasetMap = new Map(datasetList.map((ds) => [String(ds.datasetId), ds]));
|
|
|
|
// Rewrite dataset ids, add dataset info to nodes
|
|
if (datasetList.length > 0) {
|
|
nodes.forEach((node) => {
|
|
if (node.flowNodeType !== FlowNodeTypeEnum.datasetSearchNode) return;
|
|
|
|
node.inputs.forEach((item) => {
|
|
if (item.key !== NodeInputKeyEnum.datasetSelectList) return;
|
|
|
|
const val = item.value as undefined | { datasetId: string }[] | { datasetId: string };
|
|
|
|
if (Array.isArray(val)) {
|
|
item.value = val
|
|
.map((v) => {
|
|
const data = datasetMap.get(String(v.datasetId));
|
|
if (!data)
|
|
return {
|
|
datasetId: v.datasetId,
|
|
avatar: '',
|
|
name: 'Dataset not found',
|
|
vectorModel: ''
|
|
};
|
|
return {
|
|
datasetId: data.datasetId,
|
|
avatar: data.avatar,
|
|
name: data.name,
|
|
vectorModel: data.vectorModel
|
|
};
|
|
})
|
|
.filter(Boolean);
|
|
} else if (typeof val === 'object' && val !== null) {
|
|
const data = datasetMap.get(String(val.datasetId));
|
|
if (!data) {
|
|
item.value = [
|
|
{
|
|
datasetId: val.datasetId,
|
|
avatar: '',
|
|
name: 'Dataset not found',
|
|
vectorModel: ''
|
|
}
|
|
];
|
|
} else {
|
|
item.value = [
|
|
{
|
|
datasetId: data.datasetId,
|
|
avatar: data.avatar,
|
|
name: data.name,
|
|
vectorModel: data.vectorModel
|
|
}
|
|
];
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
return nodes;
|
|
}
|