from typing import ClassVar, TypeVar
from pydantic import BaseModel
from metalworks.llm.protocol import ChatCapabilities, TextResult, Usage
T = TypeVar("T", bound=BaseModel)
class MyChatModel:
protocol_version: ClassVar[str] = "1.0"
model_id = "myprovider/my-model"
capabilities = ChatCapabilities(
native_structured=False, # set True if your provider enforces JSON schema
tool_calls=True,
native_grounding=False,
thinking=False,
)
def complete_text(self, *, system, user, max_tokens=1024, temperature=0.7,
thinking_budget=0, timeout_s=120.0) -> TextResult:
text = ... # call your provider
return TextResult(text=text, usage=Usage(input_tokens=0, output_tokens=0))
def complete_structured(self, *, system, user, output_model, max_tokens=1024,
temperature=0.7, thinking_budget=0, timeout_s=120.0):
... # see the ladder below