Parameters
Graphbook supports a variety of parameter types that can be used to define the inputs and outputs of your steps.
Available Parameters
Below is a list of the available values that can be passed as a parameter type in Graphbook:
string
number
boolean
function
list[string]
list[number]
list[boolean]
list[function]
dict
resource*
* Any type that is not (string..dict) will default to resource. A resource does not correspond to a widget type but is used to indicate that the parameter accepts resource nodes.
Examples
Below shows an example for string and number parameters. Multiple parameters can be used at the same time:
from graphbook.steps import Step
class MyStep(Step):
RequiresInput = True
Parameters = {
"message": {
"type": "string",
"default": "Hello, World!"
},
"offset": {
"type": "number",
"default": 0
}
}
Outputs = ["out"]
Category = ""
def __init__(self, message, offset):
super().__init__()
self.message = message
self.offset = offset
def on_data(self, data: dict) -> str:
data["message"] = self.message
data["offset"] = self.offset
Below shows an example for a list of strings:
Below shows an example for a dictionary:
from graphbook.steps import Step
class MyStep(Step):
RequiresInput = True
Parameters = {
"car": {
"type": "dict",
"default": {
"make": "Toyota",
"model": "Camry",
"price": 25000,
"in_stock": True
}
},
}
Outputs = ["out"]
Category = ""
def __init__(self, car):
super().__init__()
self.car = car
def on_data(self, data: dict):
...