2023-04-14 06:41:06 +00:00
|
|
|
# Copyright (c) 2023 Kyle Schouviller (https://github.com/kyle0654)
|
|
|
|
|
|
|
|
from typing import Literal
|
|
|
|
from pydantic import Field
|
|
|
|
from .baseinvocation import BaseInvocation, BaseInvocationOutput, InvocationContext
|
2023-05-26 18:06:37 +00:00
|
|
|
from .math import IntOutput, FloatOutput
|
2023-04-14 06:41:06 +00:00
|
|
|
|
|
|
|
# Pass-through parameter nodes - used by subgraphs
|
|
|
|
|
|
|
|
class ParamIntInvocation(BaseInvocation):
|
|
|
|
"""An integer parameter"""
|
|
|
|
#fmt: off
|
|
|
|
type: Literal["param_int"] = "param_int"
|
|
|
|
a: int = Field(default=0, description="The integer value")
|
|
|
|
#fmt: on
|
|
|
|
|
|
|
|
def invoke(self, context: InvocationContext) -> IntOutput:
|
|
|
|
return IntOutput(a=self.a)
|
2023-05-26 18:06:37 +00:00
|
|
|
|
|
|
|
class ParamFloatInvocation(BaseInvocation):
|
|
|
|
"""A float parameter"""
|
|
|
|
#fmt: off
|
|
|
|
type: Literal["param_float"] = "param_float"
|
|
|
|
param: float = Field(default=0.0, description="The float value")
|
|
|
|
#fmt: on
|
|
|
|
|
|
|
|
def invoke(self, context: InvocationContext) -> FloatOutput:
|
|
|
|
return FloatOutput(param=self.param)
|