2023-04-06 04:06:05 +00:00
|
|
|
# Copyright (c) 2023 Kyle Schouviller (https://github.com/kyle0654)
|
|
|
|
|
2023-05-11 10:31:48 +00:00
|
|
|
import numpy as np
|
|
|
|
|
2023-08-14 09:41:29 +00:00
|
|
|
from invokeai.app.invocations.primitives import IntegerOutput
|
2023-04-06 04:06:05 +00:00
|
|
|
|
feat(nodes): move all invocation metadata (type, title, tags, category) to decorator
All invocation metadata (type, title, tags and category) are now defined in decorators.
The decorators add the `type: Literal["invocation_type"]: "invocation_type"` field to the invocation.
Category is a new invocation metadata, but it is not used by the frontend just yet.
- `@invocation()` decorator for invocations
```py
@invocation(
"sdxl_compel_prompt",
title="SDXL Prompt",
tags=["sdxl", "compel", "prompt"],
category="conditioning",
)
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
...
```
- `@invocation_output()` decorator for invocation outputs
```py
@invocation_output("clip_skip_output")
class ClipSkipInvocationOutput(BaseInvocationOutput):
...
```
- update invocation docs
- add category to decorator
- regen frontend types
2023-08-30 08:35:12 +00:00
|
|
|
from .baseinvocation import BaseInvocation, FieldDescriptions, InputField, InvocationContext, invocation
|
2023-04-06 04:06:05 +00:00
|
|
|
|
|
|
|
|
feat(nodes): move all invocation metadata (type, title, tags, category) to decorator
All invocation metadata (type, title, tags and category) are now defined in decorators.
The decorators add the `type: Literal["invocation_type"]: "invocation_type"` field to the invocation.
Category is a new invocation metadata, but it is not used by the frontend just yet.
- `@invocation()` decorator for invocations
```py
@invocation(
"sdxl_compel_prompt",
title="SDXL Prompt",
tags=["sdxl", "compel", "prompt"],
category="conditioning",
)
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
...
```
- `@invocation_output()` decorator for invocation outputs
```py
@invocation_output("clip_skip_output")
class ClipSkipInvocationOutput(BaseInvocationOutput):
...
```
- update invocation docs
- add category to decorator
- regen frontend types
2023-08-30 08:35:12 +00:00
|
|
|
@invocation("add", title="Add Integers", tags=["math", "add"], category="math")
|
2023-08-14 03:23:09 +00:00
|
|
|
class AddInvocation(BaseInvocation):
|
2023-04-06 04:06:05 +00:00
|
|
|
"""Adds two numbers"""
|
2023-05-16 00:48:22 +00:00
|
|
|
|
2023-08-14 03:23:09 +00:00
|
|
|
a: int = InputField(default=0, description=FieldDescriptions.num_1)
|
|
|
|
b: int = InputField(default=0, description=FieldDescriptions.num_2)
|
2023-07-18 14:26:45 +00:00
|
|
|
|
2023-08-14 09:41:29 +00:00
|
|
|
def invoke(self, context: InvocationContext) -> IntegerOutput:
|
2023-08-18 10:17:21 +00:00
|
|
|
return IntegerOutput(value=self.a + self.b)
|
2023-04-06 04:06:05 +00:00
|
|
|
|
|
|
|
|
feat(nodes): move all invocation metadata (type, title, tags, category) to decorator
All invocation metadata (type, title, tags and category) are now defined in decorators.
The decorators add the `type: Literal["invocation_type"]: "invocation_type"` field to the invocation.
Category is a new invocation metadata, but it is not used by the frontend just yet.
- `@invocation()` decorator for invocations
```py
@invocation(
"sdxl_compel_prompt",
title="SDXL Prompt",
tags=["sdxl", "compel", "prompt"],
category="conditioning",
)
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
...
```
- `@invocation_output()` decorator for invocation outputs
```py
@invocation_output("clip_skip_output")
class ClipSkipInvocationOutput(BaseInvocationOutput):
...
```
- update invocation docs
- add category to decorator
- regen frontend types
2023-08-30 08:35:12 +00:00
|
|
|
@invocation("sub", title="Subtract Integers", tags=["math", "subtract"], category="math")
|
2023-08-14 03:23:09 +00:00
|
|
|
class SubtractInvocation(BaseInvocation):
|
2023-04-06 04:06:05 +00:00
|
|
|
"""Subtracts two numbers"""
|
2023-05-16 00:48:22 +00:00
|
|
|
|
2023-08-14 03:23:09 +00:00
|
|
|
a: int = InputField(default=0, description=FieldDescriptions.num_1)
|
|
|
|
b: int = InputField(default=0, description=FieldDescriptions.num_2)
|
2023-07-18 14:26:45 +00:00
|
|
|
|
2023-08-14 09:41:29 +00:00
|
|
|
def invoke(self, context: InvocationContext) -> IntegerOutput:
|
2023-08-18 10:17:21 +00:00
|
|
|
return IntegerOutput(value=self.a - self.b)
|
2023-04-06 04:06:05 +00:00
|
|
|
|
|
|
|
|
feat(nodes): move all invocation metadata (type, title, tags, category) to decorator
All invocation metadata (type, title, tags and category) are now defined in decorators.
The decorators add the `type: Literal["invocation_type"]: "invocation_type"` field to the invocation.
Category is a new invocation metadata, but it is not used by the frontend just yet.
- `@invocation()` decorator for invocations
```py
@invocation(
"sdxl_compel_prompt",
title="SDXL Prompt",
tags=["sdxl", "compel", "prompt"],
category="conditioning",
)
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
...
```
- `@invocation_output()` decorator for invocation outputs
```py
@invocation_output("clip_skip_output")
class ClipSkipInvocationOutput(BaseInvocationOutput):
...
```
- update invocation docs
- add category to decorator
- regen frontend types
2023-08-30 08:35:12 +00:00
|
|
|
@invocation("mul", title="Multiply Integers", tags=["math", "multiply"], category="math")
|
2023-08-14 03:23:09 +00:00
|
|
|
class MultiplyInvocation(BaseInvocation):
|
2023-04-06 04:06:05 +00:00
|
|
|
"""Multiplies two numbers"""
|
2023-05-16 00:48:22 +00:00
|
|
|
|
2023-08-14 03:23:09 +00:00
|
|
|
a: int = InputField(default=0, description=FieldDescriptions.num_1)
|
|
|
|
b: int = InputField(default=0, description=FieldDescriptions.num_2)
|
2023-07-18 14:26:45 +00:00
|
|
|
|
2023-08-14 09:41:29 +00:00
|
|
|
def invoke(self, context: InvocationContext) -> IntegerOutput:
|
2023-08-18 10:17:21 +00:00
|
|
|
return IntegerOutput(value=self.a * self.b)
|
2023-04-06 04:06:05 +00:00
|
|
|
|
|
|
|
|
feat(nodes): move all invocation metadata (type, title, tags, category) to decorator
All invocation metadata (type, title, tags and category) are now defined in decorators.
The decorators add the `type: Literal["invocation_type"]: "invocation_type"` field to the invocation.
Category is a new invocation metadata, but it is not used by the frontend just yet.
- `@invocation()` decorator for invocations
```py
@invocation(
"sdxl_compel_prompt",
title="SDXL Prompt",
tags=["sdxl", "compel", "prompt"],
category="conditioning",
)
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
...
```
- `@invocation_output()` decorator for invocation outputs
```py
@invocation_output("clip_skip_output")
class ClipSkipInvocationOutput(BaseInvocationOutput):
...
```
- update invocation docs
- add category to decorator
- regen frontend types
2023-08-30 08:35:12 +00:00
|
|
|
@invocation("div", title="Divide Integers", tags=["math", "divide"], category="math")
|
2023-08-14 03:23:09 +00:00
|
|
|
class DivideInvocation(BaseInvocation):
|
2023-04-06 04:06:05 +00:00
|
|
|
"""Divides two numbers"""
|
2023-05-16 00:48:22 +00:00
|
|
|
|
2023-08-14 03:23:09 +00:00
|
|
|
a: int = InputField(default=0, description=FieldDescriptions.num_1)
|
|
|
|
b: int = InputField(default=0, description=FieldDescriptions.num_2)
|
2023-07-18 14:26:45 +00:00
|
|
|
|
2023-08-14 09:41:29 +00:00
|
|
|
def invoke(self, context: InvocationContext) -> IntegerOutput:
|
2023-08-18 10:17:21 +00:00
|
|
|
return IntegerOutput(value=int(self.a / self.b))
|
2023-05-11 10:31:48 +00:00
|
|
|
|
|
|
|
|
feat(nodes): move all invocation metadata (type, title, tags, category) to decorator
All invocation metadata (type, title, tags and category) are now defined in decorators.
The decorators add the `type: Literal["invocation_type"]: "invocation_type"` field to the invocation.
Category is a new invocation metadata, but it is not used by the frontend just yet.
- `@invocation()` decorator for invocations
```py
@invocation(
"sdxl_compel_prompt",
title="SDXL Prompt",
tags=["sdxl", "compel", "prompt"],
category="conditioning",
)
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
...
```
- `@invocation_output()` decorator for invocation outputs
```py
@invocation_output("clip_skip_output")
class ClipSkipInvocationOutput(BaseInvocationOutput):
...
```
- update invocation docs
- add category to decorator
- regen frontend types
2023-08-30 08:35:12 +00:00
|
|
|
@invocation("rand_int", title="Random Integer", tags=["math", "random"], category="math")
|
2023-05-11 10:31:48 +00:00
|
|
|
class RandomIntInvocation(BaseInvocation):
|
|
|
|
"""Outputs a single random integer."""
|
2023-05-16 00:48:22 +00:00
|
|
|
|
2023-08-14 03:23:09 +00:00
|
|
|
low: int = InputField(default=0, description="The inclusive low value")
|
|
|
|
high: int = InputField(default=np.iinfo(np.int32).max, description="The exclusive high value")
|
2023-07-18 14:26:45 +00:00
|
|
|
|
2023-08-14 09:41:29 +00:00
|
|
|
def invoke(self, context: InvocationContext) -> IntegerOutput:
|
2023-08-18 10:17:21 +00:00
|
|
|
return IntegerOutput(value=np.random.randint(self.low, self.high))
|