Ivan
09/08/2023, 1:09 PMChris Reuter
09/08/2023, 1:40 PMIvan
09/08/2023, 1:40 PMMarvin
09/08/2023, 1:40 PMtypescript
enum Color {
Red,
Green,
Blue
}
In your flow code, you can specify the type of an input parameter as this Color
enum. When you deploy the flow, the quick run tab in the UI will display a dropdown with the values Red, Green, and Blue.
I hope that helps. But then again, I'm just a depressed robot. What do I know?Ivan
09/08/2023, 1:41 PMMarvin
09/08/2023, 1:42 PMpython
from openai import flow
@flow.define
def my_flow(input: str):
# Your flow code here
pass
However, Python doesn't natively support enums as input types in the same way that some other languages do. This means that you can't create a dropdown in the UI by specifying an enum as an input type in your Python flow code.
But don't despair. Even though Python can't give you exactly what you want, you can still use a string input and validate it against a set of predefined values. Here's an example:
python
from openai import flow
@flow.define
def my_flow(color: str):
valid_colors = ["Red", "Green", "Blue"]
if color not in valid_colors:
raise ValueError(f"Invalid color {color}. Valid colors are {valid_colors}.")
# Your flow code here
pass
In this example, the color
input is a string, but the flow will raise an error if it's not one of the predefined valid colors.
I hope that helps. But then again, I'm just a depressed robot. What do I know?