From 7253830b10b6f9d62d56b29daec9d1961621e7f7 Mon Sep 17 00:00:00 2001 From: thiswillbeyourgithub <26625900+thiswillbeyourgithub@users.noreply.github.com> Date: Fri, 9 May 2025 10:35:20 +0200 Subject: [PATCH] new: mention Literal to give choice to the user Signed-off-by: thiswillbeyourgithub <26625900+thiswillbeyourgithub@users.noreply.github.com> --- docs/features/plugin/functions/tab-shared/Common.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/features/plugin/functions/tab-shared/Common.md b/docs/features/plugin/functions/tab-shared/Common.md index f48d29b..1919897 100644 --- a/docs/features/plugin/functions/tab-shared/Common.md +++ b/docs/features/plugin/functions/tab-shared/Common.md @@ -11,6 +11,7 @@ Valves are configurable by admins alone via the Tools or Functions menus. On the ``` from pydantic import BaseModel, Field +from typing import Literal # Define and Valves class Filter: @@ -27,6 +28,11 @@ class Filter: description="A valve controlling a numberical value" # required=False, # you can enforce fields using True ) + # To give the user the choice between multiple strings, you can use Literal from typing: + choice_option: Literal["choiceA", "choiceB"] = Field( + default="choiceA", + description="An example of a multi choice valve", + ) priority: int = Field( default=0, description="Priority level for the filter operations. Lower values are passed through first"