Skip to content

Commit a64eec4

Browse files
committed
add input and output mixins
1 parent 8835825 commit a64eec4

File tree

1 file changed

+69
-2
lines changed

1 file changed

+69
-2
lines changed

src/inferencesh/models/base.py

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
from typing import Any, Dict, List
1+
from typing import Any, Dict, List, Optional
22
from pydantic import BaseModel, ConfigDict
33
import inspect
44
import ast
55
import textwrap
66
from collections import OrderedDict
7+
from inferencesh.models.file import File
8+
from pydantic import Field
79

810

911
class OrderedSchemaModel(BaseModel):
@@ -91,4 +93,69 @@ async def run(self, app_input: BaseAppInput) -> BaseAppOutput:
9193
raise NotImplementedError("run method must be implemented")
9294

9395
async def unload(self):
94-
pass
96+
pass
97+
98+
99+
# Mixins
100+
101+
class OptionalImageFieldMixin(BaseModel):
102+
image: Optional[File] = Field(
103+
description="the image to use for the model",
104+
default=None,
105+
contentMediaType="image/*",
106+
)
107+
108+
class RequiredImageFieldMixin(BaseModel):
109+
image: File = Field(
110+
description="the image to use for the model",
111+
contentMediaType="image/*",
112+
)
113+
114+
class OptionalVideoFieldMixin(BaseModel):
115+
video: Optional[File] = Field(
116+
description="the video to use for the model",
117+
default=None,
118+
contentMediaType="video/*",
119+
)
120+
121+
class RequiredVideoFieldMixin(BaseModel):
122+
video: File = Field(
123+
description="the video to use for the model",
124+
contentMediaType="video/*",
125+
)
126+
127+
class OptionalAudioFieldMixin(BaseModel):
128+
audio: Optional[File] = Field(
129+
description="the audio to use for the model",
130+
default=None,
131+
contentMediaType="audio/*",
132+
)
133+
134+
class RequiredAudioFieldMixin(BaseModel):
135+
audio: File = Field(
136+
description="the audio to use for the model",
137+
contentMediaType="audio/*",
138+
)
139+
140+
class OptionalTextFieldMixin(BaseModel):
141+
text: Optional[str] = Field(
142+
description="the text to use for the model",
143+
default=None,
144+
)
145+
146+
class RequiredTextFieldMixin(BaseModel):
147+
text: str = Field(
148+
description="the text to use for the model",
149+
)
150+
151+
class OptionalFileFieldMixin(BaseModel):
152+
file: Optional[File] = Field(
153+
description="the file to use for the model",
154+
default=None,
155+
)
156+
157+
class RequiredFileFieldMixin(BaseModel):
158+
file: Optional[File] = Field(
159+
description="the file to use for the model",
160+
default=None,
161+
)

0 commit comments

Comments
 (0)