mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-07-04 10:52:17 +02:00
Implement cost calculator for Tuber (#471)
* Adding cost calculation in tuner for BYOK * fix * implement cost calculator for Tuner * Update api/services/integrations/tuner/completion.py Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> * feat: expose render_options in node spec * Update api/services/integrations/registry.py Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --------- Co-authored-by: mohamed salem <259547077+mohamedsalem-bot@users.noreply.github.com> Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> Co-authored-by: Abhishek Kumar <abhishek@a6k.me>
This commit is contained in:
parent
97803b8121
commit
65d46bc313
16 changed files with 479 additions and 188 deletions
|
|
@ -14,7 +14,10 @@ from api.services.workflow.node_specs._base import (
|
|||
NodeCategory,
|
||||
NodeExample,
|
||||
NodeSpec,
|
||||
NumberInputOptions,
|
||||
PropertyLayoutOptions,
|
||||
PropertyOption,
|
||||
PropertyRendererOptions,
|
||||
PropertySpec,
|
||||
PropertyType,
|
||||
evaluate_display_options,
|
||||
|
|
@ -65,7 +68,10 @@ __all__ = [
|
|||
"NodeCategory",
|
||||
"NodeExample",
|
||||
"NodeSpec",
|
||||
"NumberInputOptions",
|
||||
"PropertyLayoutOptions",
|
||||
"PropertyOption",
|
||||
"PropertyRendererOptions",
|
||||
"PropertySpec",
|
||||
"PropertyType",
|
||||
"all_specs",
|
||||
|
|
|
|||
|
|
@ -133,6 +133,42 @@ class PropertyOption(BaseModel):
|
|||
return out
|
||||
|
||||
|
||||
class PropertyLayoutOptions(BaseModel):
|
||||
"""Renderer layout hints for a property in the node editor."""
|
||||
|
||||
column_span: Optional[int] = Field(
|
||||
default=None,
|
||||
ge=1,
|
||||
le=12,
|
||||
description="Number of columns to occupy in the editor's 12-column grid.",
|
||||
)
|
||||
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
|
||||
class NumberInputOptions(BaseModel):
|
||||
"""Renderer hints for numeric inputs."""
|
||||
|
||||
fractional: bool = Field(
|
||||
default=False,
|
||||
description="Allow arbitrary fractional values via step='any'.",
|
||||
)
|
||||
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
|
||||
class PropertyRendererOptions(BaseModel):
|
||||
"""Typed renderer metadata for node properties.
|
||||
|
||||
Add new renderer behavior here instead of using free-form property metadata.
|
||||
"""
|
||||
|
||||
layout: Optional[PropertyLayoutOptions] = None
|
||||
number_input: Optional[NumberInputOptions] = None
|
||||
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
|
||||
class PropertySpec(BaseModel):
|
||||
"""Single field on a node.
|
||||
|
||||
|
|
@ -180,8 +216,9 @@ class PropertySpec(BaseModel):
|
|||
# Renderer hint, e.g. "textarea" vs single-line for `string`.
|
||||
editor: Optional[str] = None
|
||||
|
||||
# Free-form metadata for renderer-specific behavior. Use sparingly.
|
||||
extra: dict[str, Any] = Field(default_factory=dict)
|
||||
# Typed metadata for renderer-specific behavior. Extend
|
||||
# `PropertyRendererOptions` when the renderer needs a new hint.
|
||||
renderer_options: Optional[PropertyRendererOptions] = None
|
||||
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
|
|
@ -192,7 +229,7 @@ class PropertySpec(BaseModel):
|
|||
description, llm_hint, requiredness, default, enum options, nested
|
||||
row properties, and validation bounds. UI-rendering concerns
|
||||
(`display_name`, `placeholder`, `display_options`, `editor`,
|
||||
`extra`) and null/empty fields are omitted — they're noise in the
|
||||
`renderer_options`) and null/empty fields are omitted — they're noise in the
|
||||
model's context and never appear in authored SDK code.
|
||||
"""
|
||||
out: dict[str, Any] = {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ from api.services.workflow.node_specs._base import (
|
|||
NodeExample,
|
||||
NodeSpec,
|
||||
PropertyOption,
|
||||
PropertyRendererOptions,
|
||||
PropertySpec,
|
||||
PropertyType,
|
||||
)
|
||||
|
|
@ -50,7 +51,7 @@ def spec_field(
|
|||
display_options: DisplayOptions | None = None,
|
||||
options: list[PropertyOption] | None = None,
|
||||
editor: str | None = None,
|
||||
extra: dict[str, Any] | None = None,
|
||||
renderer_options: PropertyRendererOptions | None = None,
|
||||
spec_exclude: bool = False,
|
||||
min_value: float | None = None,
|
||||
max_value: float | None = None,
|
||||
|
|
@ -69,7 +70,7 @@ def spec_field(
|
|||
"display_options": display_options,
|
||||
"options": options,
|
||||
"editor": editor,
|
||||
"extra": extra or {},
|
||||
"renderer_options": renderer_options,
|
||||
"spec_exclude": spec_exclude,
|
||||
"min_value": min_value,
|
||||
"max_value": max_value,
|
||||
|
|
@ -206,7 +207,7 @@ def _build_property_spec(
|
|||
max_length=max_length,
|
||||
pattern=pattern,
|
||||
editor=meta.get("editor"),
|
||||
extra=meta.get("extra") or {},
|
||||
renderer_options=meta.get("renderer_options"),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue