Skip to content

Commit

Permalink
Merge pull request #330 from XpressAI/fahreza/any-args
Browse files Browse the repository at this point in the history
✨ Add `Any` Argument general component
  • Loading branch information
MFA-X-AI authored Jun 11, 2024
2 parents 989be69 + 6ab86bc commit 8eec6c6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
4 changes: 3 additions & 1 deletion src/components/XircuitsBodyWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export const BodyWidget: FC<BodyWidgetProps> = ({
const [intNodes, setIntNodes] = useState<string[]>([]);
const [floatNodes, setFloatNodes] = useState<string[]>([]);
const [boolNodes, setBoolNodes] = useState<string[]>([]);
const [anyNodes, setAnyNodes] = useState<string[]>([]);
const [componentList, setComponentList] = useState([]);
const [isLoading, setIsLoading] = useState(false);
const [loadingMessage, setLoadingMessage] = useState('Xircuits loading...');
Expand Down Expand Up @@ -720,7 +721,8 @@ export const BodyWidget: FC<BodyWidgetProps> = ({
'string': setStringNodes,
'int': setIntNodes,
'float': setFloatNodes,
'boolean': setBoolNodes
'boolean': setBoolNodes,
'any': setAnyNodes
}


Expand Down
2 changes: 1 addition & 1 deletion src/components/port/CustomPortModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/tray_library/GeneralComponentLib.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
6 changes: 4 additions & 2 deletions xircuits/compiler/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ def execute(self, ctx):
"int": "int",
"string": "str",
"boolean": "bool",
"float": "float"
"float": "float",
"any": "any"
}


Expand Down Expand Up @@ -406,7 +407,8 @@ def _generate_argument_parsing(self):
"int": "int",
"string": "str",
"boolean": "bool",
"float": "float"
"float": "float",
"any": "any"
}

code = """
Expand Down
21 changes: 11 additions & 10 deletions xircuits/handlers/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down

0 comments on commit 8eec6c6

Please sign in to comment.