mirror of
https://github.com/labring/FastGPT.git
synced 2026-05-05 01:02:59 +08:00
V4.14.1 feature (#5880)
* feat: app split (#5858) * feat: app split script * fix: app split * chore: app split script try-catch * adjust dashborad page (#5872) * create page * create page * create button * router name * bot * template * create page * mobile * toolfolder * fix * fix * fix build * split tool select * img * doc * rename enum * fix page adjust (#5883) * fix page adjust * fix ad store * fix: initv4141 (#5886) * fix: create app * doc * hide api * doc * feat: payment pause interactive (#5892) * fix: copy clbs (#5889) * fix: copy clbs * fix: copy clbs * fix: http protocol handling in baseURL (#5890) * fix: http protocol handling in baseURL * ui fix * auto saved version * fix * auto save * fix: model permission modal (#5895) * folder * fix: del app * navbar * fix: plugin file selector (#5893) * fix: plugin file selector * fix: plugin file selector * workflow tool inputform * pick --------- Co-authored-by: archer <545436317@qq.com> * fix: workflow tool time * doc * fix workorder button (#5896) * add inform track (#5897) * remove invalid track * comment * feat: marketplace refresh api (#5884) * marketplace refresh * fix: helper bot menu button (#5898) --------- Co-authored-by: Finley Ge <32237950+FinleyGe@users.noreply.github.com> Co-authored-by: heheer <heheer@sealos.io> Co-authored-by: 伍闲犬 <whoeverimf5@gmail.com>
This commit is contained in:
@@ -55,6 +55,8 @@ import type { RequireOnlyOne } from '@fastgpt/global/common/type/utils';
|
||||
import { getS3ChatSource } from '../../../common/s3/sources/chat';
|
||||
import { addPreviewUrlToChatItems } from '../../chat/utils';
|
||||
import type { MCPClient } from '../../app/mcp';
|
||||
import { TeamErrEnum } from '@fastgpt/global/common/error/code/team';
|
||||
import { i18nT } from '../../../../web/i18n/utils';
|
||||
|
||||
type Props = Omit<ChatDispatchProps, 'workflowDispatchDeep' | 'timezone' | 'externalProvider'> & {
|
||||
runtimeNodes: RuntimeNodeItemType[];
|
||||
@@ -132,7 +134,7 @@ export async function dispatchWorkFlow({
|
||||
}
|
||||
|
||||
// Add preview url to chat items
|
||||
await addPreviewUrlToChatItems(histories);
|
||||
await addPreviewUrlToChatItems(histories, 'chatFlow');
|
||||
for (const item of query) {
|
||||
if (item.type !== ChatItemValueTypeEnum.file || !item.file?.key) continue;
|
||||
item.file.url = await getS3ChatSource().createGetChatFileURL({
|
||||
@@ -620,6 +622,23 @@ export const runWorkflow = async (data: RunWorkflowProps): Promise<DispatchFlowR
|
||||
}
|
||||
};
|
||||
}
|
||||
private async checkTeamBlance(): Promise<NodeResponseCompleteType | undefined> {
|
||||
try {
|
||||
await checkTeamAIPoints(data.runningUserInfo.teamId);
|
||||
} catch (error) {
|
||||
// Next time you enter the system, you will still start from the current node(Current check team blance node).
|
||||
if (error === TeamErrEnum.aiPointsNotEnough) {
|
||||
return {
|
||||
[DispatchNodeResponseKeyEnum.interactive]: {
|
||||
type: 'paymentPause',
|
||||
params: {
|
||||
description: i18nT('chat:balance_not_enough_pause')
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Check node run/skip or wait */
|
||||
private async checkNodeCanRun(
|
||||
node: RuntimeNodeItemType,
|
||||
@@ -652,6 +671,7 @@ export const runWorkflow = async (data: RunWorkflowProps): Promise<DispatchFlowR
|
||||
this.chatResponses.push(responseData);
|
||||
}
|
||||
|
||||
// Push usage in real time. Avoid a workflow usage a large number of points
|
||||
if (nodeDispatchUsages) {
|
||||
if (usageId) {
|
||||
pushChatItemUsage({
|
||||
@@ -763,6 +783,7 @@ export const runWorkflow = async (data: RunWorkflowProps): Promise<DispatchFlowR
|
||||
};
|
||||
};
|
||||
|
||||
// Check queue status
|
||||
if (data.maxRunTimes <= 0) {
|
||||
addLog.error('Max run times is 0', {
|
||||
appId: data.runningAppInfo.id
|
||||
@@ -790,8 +811,17 @@ export const runWorkflow = async (data: RunWorkflowProps): Promise<DispatchFlowR
|
||||
runtimeEdges
|
||||
});
|
||||
|
||||
const nodeRunResult = await (() => {
|
||||
const nodeRunResult = await (async () => {
|
||||
if (status === 'run') {
|
||||
const blanceCheckResult = await this.checkTeamBlance();
|
||||
if (blanceCheckResult) {
|
||||
return {
|
||||
node,
|
||||
runStatus: 'pause' as const,
|
||||
result: blanceCheckResult
|
||||
};
|
||||
}
|
||||
|
||||
// All source edges status to waiting
|
||||
runtimeEdges.forEach((item) => {
|
||||
if (item.target === node.nodeId) {
|
||||
@@ -870,10 +900,21 @@ export const runWorkflow = async (data: RunWorkflowProps): Promise<DispatchFlowR
|
||||
this.debugNextStepRunNodes = this.debugNextStepRunNodes.concat([nodeRunResult.node]);
|
||||
}
|
||||
|
||||
this.nodeInteractiveResponse = {
|
||||
entryNodeIds: [nodeRunResult.node.nodeId],
|
||||
interactiveResponse
|
||||
};
|
||||
// For the pause interactive response, there may be multiple nodes triggered at the same time, so multiple entry nodes need to be recorded.
|
||||
// For other interactive nodes, only one will be triggered at the same time.
|
||||
if (interactiveResponse.type === 'paymentPause') {
|
||||
this.nodeInteractiveResponse = {
|
||||
entryNodeIds: this.nodeInteractiveResponse?.entryNodeIds
|
||||
? this.nodeInteractiveResponse.entryNodeIds.concat(nodeRunResult.node.nodeId)
|
||||
: [nodeRunResult.node.nodeId],
|
||||
interactiveResponse
|
||||
};
|
||||
} else {
|
||||
this.nodeInteractiveResponse = {
|
||||
entryNodeIds: [nodeRunResult.node.nodeId],
|
||||
interactiveResponse
|
||||
};
|
||||
}
|
||||
return;
|
||||
} else if (isDebugMode) {
|
||||
// Debug 模式下一步时候,会自己增加 activeNode
|
||||
|
||||
@@ -6,6 +6,7 @@ import type {
|
||||
DispatchNodeResultType,
|
||||
ModuleDispatchProps
|
||||
} from '@fastgpt/global/core/workflow/runtime/type';
|
||||
import { getS3ChatSource } from '../../../../common/s3/sources/chat';
|
||||
|
||||
export type PluginInputProps = ModuleDispatchProps<{
|
||||
[key: string]: any;
|
||||
@@ -21,12 +22,12 @@ export const dispatchPluginInput = async (
|
||||
const { params, query } = props;
|
||||
const { files } = chatValue2RuntimePrompt(query);
|
||||
|
||||
/*
|
||||
/*
|
||||
对 params 中文件类型数据进行处理
|
||||
* 插件单独运行时,这里会是一个特殊的数组
|
||||
* 插件调用的话,这个参数是一个 string[] 不会进行处理
|
||||
* 硬性要求:API 单独调用插件时,要避免这种特殊类型冲突
|
||||
|
||||
|
||||
TODO: 需要 filter max files
|
||||
*/
|
||||
for (const key in params) {
|
||||
@@ -37,6 +38,17 @@ export const dispatchPluginInput = async (
|
||||
(item) => item.type === ChatFileTypeEnum.file || item.type === ChatFileTypeEnum.image
|
||||
)
|
||||
) {
|
||||
// 为文件对象重新签发 URL(如果有 key 但没有 url)
|
||||
for (let i = 0; i < val.length; i++) {
|
||||
const fileItem = val[i];
|
||||
if (fileItem.key && !fileItem.url) {
|
||||
val[i].url = await getS3ChatSource().createGetChatFileURL({
|
||||
key: fileItem.key,
|
||||
external: true,
|
||||
expiredHours: 1
|
||||
});
|
||||
}
|
||||
}
|
||||
params[key] = val.map((item) => item.url);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user