Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
eaeabf82
authored
Dec 10, 2025
by
Archer
Committed by
GitHub
Dec 10, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: value type (#6076)
* fix: value type * perf: empty val check
parent
2da73a65
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
133 deletions
+21
-133
packages/global/core/workflow/runtime/utils.ts
+2
-19
packages/service/core/ai/llm/request.ts
+1
-1
packages/service/core/ai/utils.ts
+1
-1
packages/service/core/workflow/dispatch/tools/http468.ts
+5
-4
test/cases/service/core/app/workflow/dispatch/http.test.ts
+12
-2
test/cases/service/core/app/workflow/dispatch/utils.test.ts
+0
-106
No files found.
packages/global/core/workflow/runtime/utils.ts
View file @
eaeabf82
...
...
@@ -67,25 +67,8 @@ export const valueTypeFormat = (value: any, valueType?: WorkflowIOValueTypeEnum)
};
// Handle null/undefined, return default value by type
if
(
value
===
undefined
||
value
===
null
)
{
if
(
!
valueType
||
valueType
===
WorkflowIOValueTypeEnum
.
any
)
return
value
;
// Default value map (use function to ensure new reference each time)
const
defaultValueMap
:
Partial
<
Record
<
WorkflowIOValueTypeEnum
,
()
=>
any
>>
=
{
[
WorkflowIOValueTypeEnum
.
string
]:
()
=>
''
,
[
WorkflowIOValueTypeEnum
.
number
]:
()
=>
0
,
[
WorkflowIOValueTypeEnum
.
boolean
]:
()
=>
false
,
[
WorkflowIOValueTypeEnum
.
arrayString
]:
()
=>
[],
[
WorkflowIOValueTypeEnum
.
arrayNumber
]:
()
=>
[],
[
WorkflowIOValueTypeEnum
.
arrayBoolean
]:
()
=>
[],
[
WorkflowIOValueTypeEnum
.
arrayObject
]:
()
=>
[],
[
WorkflowIOValueTypeEnum
.
arrayAny
]:
()
=>
[],
[
WorkflowIOValueTypeEnum
.
object
]:
()
=>
({})
};
const
getDefaultValue
=
defaultValueMap
[
valueType
];
return
getDefaultValue
?
getDefaultValue
()
:
value
;
}
if
(
value
===
undefined
||
value
===
null
)
return
value
;
if
(
!
valueType
||
valueType
===
WorkflowIOValueTypeEnum
.
any
)
return
value
;
// Password check
if
(
valueType
===
WorkflowIOValueTypeEnum
.
string
&&
isSecretValue
(
value
))
return
value
;
...
...
packages/service/core/ai/llm/request.ts
View file @
eaeabf82
...
...
@@ -537,7 +537,7 @@ const llmCompletionsBodyFormat = async <T extends CompletionsBodyType>({
:
undefined
,
...
modelData
?.
defaultConfig
,
response_format
,
stop
:
stop
?.
split
(
'|'
),
stop
:
stop
?.
split
(
'|'
)
.
filter
((
item
)
=>
!!
item
.
trim
())
,
...(
toolCallMode
===
'toolChoice'
&&
{
tools
,
tool_choice
,
...
...
packages/service/core/ai/utils.ts
View file @
eaeabf82
...
...
@@ -20,7 +20,7 @@ export const computedMaxToken = ({
if
(
maxToken
===
undefined
)
return
;
maxToken
=
Math
.
min
(
maxToken
,
model
.
maxResponse
);
return
Math
.
max
(
maxToken
,
min
||
0
);
return
Math
.
max
(
maxToken
,
min
||
1
);
};
// FastGPT temperature range: [0,10], ai temperature:[0,2],{0,1]……
...
...
packages/service/core/workflow/dispatch/tools/http468.ts
View file @
eaeabf82
...
...
@@ -62,14 +62,13 @@ const UNDEFINED_SIGN = 'UNDEFINED_SIGN';
export
const
dispatchHttp468Request
=
async
(
props
:
HttpRequestProps
):
Promise
<
HttpResponse
>
=>
{
let
{
runningAppInfo
:
{
id
:
appId
,
teamId
,
tmbId
},
runningAppInfo
:
{
id
:
appId
},
chatId
,
responseChatItemId
,
variables
,
node
,
runtimeNodes
,
histories
,
workflowStreamResponse
,
params
:
{
system_httpMethod
:
httpMethod
=
'POST'
,
system_httpReqUrl
:
httpReqUrl
,
...
...
@@ -332,8 +331,10 @@ export const replaceJsonBodyString = (
};
const
valToStr
=
(
val
:
any
,
isQuoted
=
false
)
=>
{
if
(
val
===
undefined
)
return
'null'
;
if
(
val
===
null
)
return
'null'
;
if
(
val
===
undefined
||
val
===
null
)
{
if
(
isQuoted
)
return
''
;
return
'null'
;
}
if
(
typeof
val
===
'object'
)
{
const
jsonStr
=
JSON
.
stringify
(
val
);
...
...
test/cases/service/core/app/workflow/dispatch/http.test.ts
View file @
eaeabf82
...
...
@@ -19,6 +19,8 @@ describe('replaceJsonBodyString', () => {
]
as
unknown
as
RuntimeNodeItemType
[];
const
mockVariables
=
{
undefinedVar
:
undefined
,
nullVar
:
null
,
userName
:
'John Doe'
,
userAge
:
30
,
isActive
:
true
,
...
...
@@ -43,6 +45,14 @@ describe('replaceJsonBodyString', () => {
};
describe
(
'Basic variable replacement functionality'
,
()
=>
{
it
(
'字符串为空'
,
()
=>
{
const
input
=
'{"name": "{{undefinedVar}}"}'
;
const
expected
=
'{"name": ""}'
;
const
result
=
replaceJsonBodyString
({
text
:
input
},
mockProps
);
expect
(
result
).
toBe
(
expected
);
});
it
(
'should correctly replace string variables'
,
()
=>
{
const
input
=
'{"name": "{{userName}}", "greeting": "Hello {{userName}}"}'
;
const
expected
=
'{"name": "John Doe", "greeting": "Hello John Doe"}'
;
...
...
@@ -241,7 +251,7 @@ describe('replaceJsonBodyString', () => {
it
(
'should handle non-existent variables'
,
()
=>
{
const
input
=
'{"missing": "{{nonExistentVar}}", "static": "value"}'
;
const
expected
=
'{"missing": "
null
", "static": "value"}'
;
const
expected
=
'{"missing": "", "static": "value"}'
;
const
result
=
replaceJsonBodyString
({
text
:
input
},
mockProps
);
expect
(
result
).
toBe
(
expected
);
...
...
@@ -626,7 +636,7 @@ describe('replaceJsonBodyString', () => {
// Verify no code execution occurred (template injection variable was replaced with null because it doesn't exist)
expect
(
typeof
parsed
.
templateTests
.
inject
).
toBe
(
'string'
);
expect
(
parsed
.
templateTests
.
inject
).
toBe
(
'
null
'
);
// Non-existent variables become "null"
expect
(
parsed
.
templateTests
.
inject
).
toBe
(
''
);
// Non-existent variables become "null"
});
});
});
test/cases/service/core/app/workflow/dispatch/utils.test.ts
View file @
eaeabf82
...
...
@@ -311,109 +311,3 @@ describe('valueTypeFormat', () => {
// });
// });
});
import
{
getHistories
}
from
'@fastgpt/service/core/workflow/dispatch/utils'
;
import
{
ChatItemValueTypeEnum
,
ChatRoleEnum
}
from
'@fastgpt/global/core/chat/constants'
;
import
type
{
ChatItemType
}
from
'@fastgpt/global/core/chat/type'
;
describe
(
'getHistories test'
,
async
()
=>
{
const
MockHistories
:
ChatItemType
[]
=
[
{
obj
:
ChatRoleEnum
.
System
,
value
:
[
{
type
:
ChatItemValueTypeEnum
.
text
,
text
:
{
content
:
'你好'
}
}
]
},
{
obj
:
ChatRoleEnum
.
Human
,
value
:
[
{
type
:
ChatItemValueTypeEnum
.
text
,
text
:
{
content
:
'你好'
}
}
]
},
{
obj
:
ChatRoleEnum
.
AI
,
value
:
[
{
type
:
ChatItemValueTypeEnum
.
text
,
text
:
{
content
:
'你好2'
}
}
]
},
{
obj
:
ChatRoleEnum
.
Human
,
value
:
[
{
type
:
ChatItemValueTypeEnum
.
text
,
text
:
{
content
:
'你好3'
}
}
]
},
{
obj
:
ChatRoleEnum
.
AI
,
value
:
[
{
type
:
ChatItemValueTypeEnum
.
text
,
text
:
{
content
:
'你好4'
}
}
]
}
];
it
(
'getHistories'
,
async
()
=>
{
// Number
expect
(
getHistories
(
1
,
MockHistories
)).
toEqual
([
...
MockHistories
.
slice
(
0
,
1
),
...
MockHistories
.
slice
(
-
2
)
]);
expect
(
getHistories
(
2
,
MockHistories
)).
toEqual
([...
MockHistories
.
slice
(
0
)]);
expect
(
getHistories
(
4
,
MockHistories
)).
toEqual
([...
MockHistories
.
slice
(
0
)]);
// Array
expect
(
getHistories
(
[
{
obj
:
ChatRoleEnum
.
Human
,
value
:
[
{
type
:
ChatItemValueTypeEnum
.
text
,
text
:
{
content
:
'你好'
}
}
]
}
],
MockHistories
)
).
toEqual
([
{
obj
:
ChatRoleEnum
.
Human
,
value
:
[
{
type
:
ChatItemValueTypeEnum
.
text
,
text
:
{
content
:
'你好'
}
}
]
}
]);
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment