From 6ab86bce73bd9524b865b776fe088b6a74afa264 Mon Sep 17 00:00:00 2001 From: MFA-X-AI Date: Wed, 12 Jun 2024 01:06:24 +0800 Subject: [PATCH] add argument any --- src/components/XircuitsBodyWidget.tsx | 4 +++- src/components/port/CustomPortModel.ts | 2 +- src/tray_library/GeneralComponentLib.tsx | 2 +- xircuits/compiler/generator.py | 6 ++++-- xircuits/handlers/components.py | 21 +++++++++++---------- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/components/XircuitsBodyWidget.tsx b/src/components/XircuitsBodyWidget.tsx index 8deda1a1..3a097fe6 100644 --- a/src/components/XircuitsBodyWidget.tsx +++ b/src/components/XircuitsBodyWidget.tsx @@ -100,6 +100,7 @@ export const BodyWidget: FC = ({ const [intNodes, setIntNodes] = useState([]); const [floatNodes, setFloatNodes] = useState([]); const [boolNodes, setBoolNodes] = useState([]); + const [anyNodes, setAnyNodes] = useState([]); const [componentList, setComponentList] = useState([]); const [isLoading, setIsLoading] = useState(false); const [loadingMessage, setLoadingMessage] = useState('Xircuits loading...'); @@ -720,7 +721,8 @@ export const BodyWidget: FC = ({ 'string': setStringNodes, 'int': setIntNodes, 'float': setFloatNodes, - 'boolean': setBoolNodes + 'boolean': setBoolNodes, + 'any': setAnyNodes } diff --git a/src/components/port/CustomPortModel.ts b/src/components/port/CustomPortModel.ts index 2b833946..dadda2c5 100644 --- a/src/components/port/CustomPortModel.ts +++ b/src/components/port/CustomPortModel.ts @@ -10,7 +10,7 @@ import {PortModel} from "@projectstorm/react-diagrams-core"; export const PARAMETER_NODE_TYPES = [ 'boolean', 'int', 'float', 'string', 'list', 'tuple', - 'dict', 'secret', 'chat' + 'dict', 'secret', 'chat', 'any' ]; export interface CustomPortModelOptions extends DefaultPortModelOptions { diff --git a/src/tray_library/GeneralComponentLib.tsx b/src/tray_library/GeneralComponentLib.tsx index b4be0ffd..9f7987ad 100644 --- a/src/tray_library/GeneralComponentLib.tsx +++ b/src/tray_library/GeneralComponentLib.tsx @@ -17,7 +17,7 @@ export function cancelDialog(dialogResult) { } const TYPE_LITERALS = ['string', 'int', 'float', 'boolean', 'list', 'tuple', 'dict', 'secret', 'chat']; -const TYPE_ARGUMENTS = ['string', 'int', 'float', 'boolean']; +const TYPE_ARGUMENTS = ['string', 'int', 'float', 'boolean', 'any']; const SPECIAL_LITERALS = ['chat']; export async function handleLiteralInput(nodeName, nodeData, inputValue = "", type, title = "New Literal Input") { diff --git a/xircuits/compiler/generator.py b/xircuits/compiler/generator.py index 1f484e5a..93b55f0e 100644 --- a/xircuits/compiler/generator.py +++ b/xircuits/compiler/generator.py @@ -119,7 +119,8 @@ def execute(self, ctx): "int": "int", "string": "str", "boolean": "bool", - "float": "float" + "float": "float", + "any": "any" } @@ -406,7 +407,8 @@ def _generate_argument_parsing(self): "int": "int", "string": "str", "boolean": "bool", - "float": "float" + "float": "float", + "any": "any" } code = """ diff --git a/xircuits/handlers/components.py b/xircuits/handlers/components.py index c63e1a9b..226471e8 100644 --- a/xircuits/handlers/components.py +++ b/xircuits/handlers/components.py @@ -28,16 +28,17 @@ 2: { "name": "Get Argument Integer Name", "returnType": "int","color":"blue"}, 3: { "name": "Get Argument Float Name", "returnType": "float","color":"green"}, 4: { "name": "Get Argument Boolean Name", "returnType": "boolean","color":"red"}, - 5: { "name": "Literal String", "returnType": "string","color":"lightpink"}, - 6:{ "name": "Literal Integer", "returnType": "int","color":"blue"}, - 7:{ "name": "Literal Float", "returnType": "float","color":"green"}, - 8:{ "name": "Literal True", "returnType": "boolean","color":"red"}, - 9:{ "name": "Literal False", "returnType": "boolean","color":"red"}, - 10:{ "name": "Literal List", "returnType": "list","color":"yellow"}, - 11:{ "name": "Literal Tuple", "returnType": "tuple","color":"purple"}, - 12:{ "name": "Literal Dict", "returnType": "dict","color":"orange"}, - 13:{ "name": "Literal Secret", "returnType": "secret","color":"black"}, - 14:{ "name": "Literal Chat", "returnType": "chat","color":"green"}, + 5: { "name": "Get Argument Any Name", "returnType": "any","color":"red"}, + 6: { "name": "Literal String", "returnType": "string","color":"lightpink"}, + 7:{ "name": "Literal Integer", "returnType": "int","color":"blue"}, + 8:{ "name": "Literal Float", "returnType": "float","color":"green"}, + 9:{ "name": "Literal True", "returnType": "boolean","color":"red"}, + 10:{ "name": "Literal False", "returnType": "boolean","color":"red"}, + 11:{ "name": "Literal List", "returnType": "list","color":"yellow"}, + 12:{ "name": "Literal Tuple", "returnType": "tuple","color":"purple"}, + 13:{ "name": "Literal Dict", "returnType": "dict","color":"orange"}, + 14:{ "name": "Literal Secret", "returnType": "secret","color":"black"}, + 15:{ "name": "Literal Chat", "returnType": "chat","color":"green"}, # Comment this first since we don't use it # 1: { "name": "Math Operation", "returnType": "math"},