Feature/Custom Function to Seq Agent (#3612)

* add custom function to seq agent

* add seqExecuteFlow node
This commit is contained in:
Henry Heng
2025-01-23 13:04:40 +00:00
committed by GitHub
parent 50a7339299
commit e26fc63be0
17 changed files with 36048 additions and 35393 deletions
@@ -58,6 +58,7 @@ export const AsyncDropdown = ({
onCreateNew,
credentialNames = [],
disabled = false,
freeSolo = false,
disableClearable = false
}) => {
const customization = useSelector((state) => state.customization)
@@ -114,6 +115,7 @@ export const AsyncDropdown = ({
<>
<Autocomplete
id={name}
freeSolo={freeSolo}
disabled={disabled}
disableClearable={disableClearable}
size='small'
@@ -176,6 +178,7 @@ AsyncDropdown.propTypes = {
onSelect: PropTypes.func,
onCreateNew: PropTypes.func,
disabled: PropTypes.bool,
freeSolo: PropTypes.bool,
credentialNames: PropTypes.array,
disableClearable: PropTypes.bool,
isCreateNewOption: PropTypes.bool
@@ -18,7 +18,7 @@ const StyledPopper = styled(Popper)({
}
})
export const Dropdown = ({ name, value, loading, options, onSelect, disabled = false, disableClearable = false }) => {
export const Dropdown = ({ name, value, loading, options, onSelect, disabled = false, freeSolo = false, disableClearable = false }) => {
const customization = useSelector((state) => state.customization)
const findMatchingOptions = (options = [], value) => options.find((option) => option.name === value)
const getDefaultOptionValue = () => ''
@@ -29,6 +29,7 @@ export const Dropdown = ({ name, value, loading, options, onSelect, disabled = f
<Autocomplete
id={name}
disabled={disabled}
freeSolo={freeSolo}
disableClearable={disableClearable}
size='small'
loading={loading}
@@ -101,6 +102,7 @@ Dropdown.propTypes = {
value: PropTypes.string,
loading: PropTypes.bool,
options: PropTypes.array,
freeSolo: PropTypes.bool,
onSelect: PropTypes.func,
disabled: PropTypes.bool,
disableClearable: PropTypes.bool
+1 -1
View File
@@ -435,7 +435,7 @@ export const getAvailableNodesForVariable = (nodes, edges, target, targetHandle)
collectParentNodes(parentNode.id, nodes, edges)
// Check and add the parent node to the list if it does not include specific names
const excludeNodeNames = ['seqAgent', 'seqLLMNode', 'seqToolNode']
const excludeNodeNames = ['seqAgent', 'seqLLMNode', 'seqToolNode', 'seqCustomFunction', 'seqExecuteFlow']
if (excludeNodeNames.includes(parentNode.data.name)) {
parentNodes.push(parentNode)
}
@@ -319,6 +319,26 @@ const NodeInputHandler = ({
return colDef
}
const getDropdownOptions = (inputParam) => {
const preLoadOptions = []
if (inputParam.loadPreviousNodes) {
const nodes = getAvailableNodesForVariable(
reactFlowInstance?.getNodes() || [],
reactFlowInstance?.getEdges() || [],
data.id,
inputParam.id
)
for (const node of nodes) {
preLoadOptions.push({
name: `{{ ${node.data.id} }}`,
label: `{{ ${node.data.id} }}`,
description: `Output from ${node.data.id}`
})
}
}
return [...preLoadOptions, ...inputParam.options]
}
const getTabValue = (inputParam) => {
return inputParam.tabs.findIndex((item) => item.name === data.inputs[`${inputParam.tabIdentifier}_${data.id}`]) >= 0
? inputParam.tabs.findIndex((item) => item.name === data.inputs[`${inputParam.tabIdentifier}_${data.id}`])
@@ -515,6 +535,20 @@ const NodeInputHandler = ({
{inputParam.description && <TooltipWithParser style={{ marginLeft: 10 }} title={inputParam.description} />}
</Typography>
<div style={{ flexGrow: 1 }}></div>
{inputParam.hint && !isAdditionalParams && (
<IconButton
size='small'
sx={{
height: 25,
width: 25
}}
title={inputParam.hint.label}
color='secondary'
onClick={() => onInputHintDialogClicked(inputParam.hint)}
>
<IconBulb />
</IconButton>
)}
{inputParam.hint && isAdditionalParams && (
<Button
sx={{ p: 0, px: 2 }}
@@ -721,7 +755,8 @@ const NodeInputHandler = ({
<Dropdown
disabled={disabled}
name={inputParam.name}
options={inputParam.options}
options={getDropdownOptions(inputParam)}
freeSolo={inputParam.freeSolo}
onSelect={(newValue) => (data.inputs[inputParam.name] = newValue)}
value={data.inputs[inputParam.name] ?? inputParam.default ?? 'choose an option'}
/>
@@ -730,7 +765,7 @@ const NodeInputHandler = ({
<MultiDropdown
disabled={disabled}
name={inputParam.name}
options={inputParam.options}
options={getDropdownOptions(inputParam)}
onSelect={(newValue) => (data.inputs[inputParam.name] = newValue)}
value={data.inputs[inputParam.name] ?? inputParam.default ?? 'choose an option'}
/>
@@ -744,6 +779,7 @@ const NodeInputHandler = ({
name={inputParam.name}
nodeData={data}
value={data.inputs[inputParam.name] ?? inputParam.default ?? 'choose an option'}
freeSolo={inputParam.freeSolo}
isCreateNewOption={EDITABLE_OPTIONS.includes(inputParam.name)}
onSelect={(newValue) => (data.inputs[inputParam.name] = newValue)}
onCreateNew={() => addAsyncOption(inputParam.name)}