54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from wov_sdk.models import NodeManifest
|
|
|
|
|
|
class NodeCreate(BaseModel):
|
|
id: str = Field(min_length=1)
|
|
name: str = Field(min_length=1)
|
|
version: str = Field(min_length=1)
|
|
capability: str = Field(min_length=1)
|
|
command: list[str] = Field(min_length=1)
|
|
repo_dir: str = "."
|
|
env: dict[str, str] = Field(default_factory=dict)
|
|
input_schema: dict[str, Any] = Field(default_factory=dict)
|
|
output_schema: dict[str, Any] = Field(default_factory=dict)
|
|
max_concurrency: int = Field(default=1, ge=1)
|
|
idle_ttl_seconds: int = Field(default=300, ge=0)
|
|
health_timeout_seconds: int = Field(default=10, ge=1)
|
|
keep_warm: bool = False
|
|
|
|
def to_manifest(self) -> NodeManifest:
|
|
return NodeManifest(
|
|
id=self.id,
|
|
name=self.name,
|
|
version=self.version,
|
|
capability=self.capability,
|
|
command=list(self.command),
|
|
repo_dir=self.repo_dir,
|
|
env=dict(self.env),
|
|
input_schema=dict(self.input_schema),
|
|
output_schema=dict(self.output_schema),
|
|
max_concurrency=self.max_concurrency,
|
|
idle_ttl_seconds=self.idle_ttl_seconds,
|
|
health_timeout_seconds=self.health_timeout_seconds,
|
|
keep_warm=self.keep_warm,
|
|
)
|
|
|
|
|
|
class InvokePayload(BaseModel):
|
|
run_id: str = Field(default_factory=lambda: "run_admin")
|
|
inputs: dict[str, Any] = Field(default_factory=dict)
|
|
params: dict[str, Any] = Field(default_factory=dict)
|
|
|
|
|
|
class WorkflowCreate(BaseModel):
|
|
id: str | None = None
|
|
name: str = Field(min_length=1)
|
|
description: str = ""
|
|
definition: dict[str, Any]
|