GizStack
View .mdOpen in ChatGPTOpen in Claude

gizai:studio

the models of an app (Studio): chat, image and video models held on one GPU and taken in turn, and an agent's model: this computer's, the giz.ai account's or an OpenAI-compatible API's.

gizlang
import * as Studio from "gizai:studio";

Types

Studio

gizlang
type Studio = { sys: System; hub: Hub.Hub; engine: Ref<Vec<Engine>>; chatting: Ref<string>; painter: Ref<Option<ImageModel>>; filmer: Ref<Option<VideoModel>>; turn: Task.Channel<i64>; needs: Ref<Map<string, i64>>; }

The models of an app, each loaded at its first use and kept: the chat model (chatting names the one loaded, "" none; another chat model replaces it), the image and the video model. A Studio is shared, as a closure captures it: its models are in Refs.

  • sys: gizlang_system.System
  • hub: gizlang_hub.Hub
  • engine: Ref<Vec<M32.Engine>>
  • chatting: Ref<string>
  • painter: Ref<_gizlang_sdk_core.Option<M31.ImageModel>>
  • filmer: Ref<_gizlang_sdk_core.Option<M50.VideoModel>>
  • turn: gizlang_task.Channel<i64> — Its one token: a chat turn, a picture or a clip runs while it holds it (alone).
  • needs: Ref<_gizlang_sdk_collections.Map<string, i64>> — The most device bytes each model ("chat", "image", "video") used to load and run, measured (Gpu.peak).

Choice

gizlang
type Choice = { kind: string; name: string; }

Where a model name points: kind "local" (this computer's chat model), "giz" (a model of the giz.ai account) or "api" (a model of the OpenAI-compatible API of AI_URL), and the model's name there ("": that kind's default).

  • kind: string
  • name: string

Functions

studio

gizlang
function studio(sys: System): Studio throws string

The models of this computer: the chat model CHAT_MODEL (qwen3.5-4b), the image model IMAGE_MODEL (z-image-turbo), and LTX-2.5 (LTX_REPO, or the ComfyUI models folder VIDEO_MODELS) with its text encoder on the same GPU, or served at VIDEO_ENCODER (HOST:PORT). A model loads at its first use, and one that is not here yet is downloaded then.

Effects: fail, write, io.

choose

gizlang
function choose(name: string, aiModel: string, aiUrl: string, signedIn: bool): Choice

The choice of name, else aiModel (AI_MODEL): "local:NAME", "giz:NAME", and any other name a model of the API. With no name: the API when aiUrl (AI_URL) is set, else giz.ai's default when signedIn, else the local default.

Effects: fail.

gizOrLocal

gizlang
function gizOrLocal(sys: System, giz: Result<Agent.Model, string>, local: Agent.Model): Agent.Model

The default model when giz.ai is: giz (the account's default, made with one refresh of the sign-in and one model list), else local when giz.ai cannot be used now, as an expired sign-in, with one stderr line of why. A program with no model named starts either way.

Effects: fail, io.

chosen

gizlang
function chosen(names: Vec<string>, asked: string): i64

The place in names of the model a request asks for: the first when it names none, and a name may carry its provider ("gizstack/q27-4"); -1 when the server serves no such model.

Effects: fail.

Methods

Studio.chat

gizlang
function Studio.chat(self: Studio, turns: Vec<string>, each: (text: string) => void): string throws string

The chat model's answer to turns: the person's and its own texts in turn, the person's first and last. Each piece of the answer goes to each as it comes.

Effects: fail, read, write, console, io.

Studio.model

gizlang
function Studio.model(self: Studio, name: string = ""): Agent.Model throws string

The agent's model (gizai:agent) that name names, else AI_MODEL (choose): "local:NAME" this computer's chat model NAME (CHAT_MODEL when NAME is ""), loaded at its first turn; "giz:NAME" model NAME of the giz.ai account that giz auth login signed in (its first chat model with tools when NAME is ""); any other name a model of the API of AI_URL (Agent.endpoint). With no name at all: AI_URL's model when it is set, else giz.ai's when signed in, else the local qwen3.5-4b, and one line on stderr names the choice.

Effects: fail, read, write, console, io.

Studio.models

gizlang
function Studio.models(self: Studio): Vec<string>

The model names Studio.model takes, for a picker: "local:NAME" for each chat model this computer holds ready, "giz:ID" for each chat model of the giz.ai account when signed in, and each model of the API of AI_URL when it is set. A source that does not answer lists nothing.

Effects: fail, read, write, console, io.

Studio.image

gizlang
function Studio.image(self: Studio, prompt: string): bytes throws string

A picture of prompt, as PNG.

Effects: fail, read, write, console, io.

Studio.listen

gizlang
function Studio.listen(self: Studio, sound: OpenAi.Sound): string throws string

The words spoken in SOUND, as the speech-to-text model LISTEN_MODEL of the model API (AI_URL, AI_API_KEY) hears them. This computer has no speech-to-text model of its own yet.

Effects: fail, read, write, console, io.

Studio.speak

gizlang
function Studio.speak(self: Studio, text: string): OpenAi.Sound throws string

TEXT spoken by the text-to-speech model SPEAK_MODEL of the model API (AI_URL, AI_API_KEY), in its voice SPEAK_VOICE ("" the model's own).

Effects: fail, read, write, console, io.

Studio.dropChat

gizlang
function Studio.dropChat(self: Studio): void

Each model leaves the GPU and gives its buffers back (Gpu.memory then counts them free).

Effects: fail, read, write, console, io.

Studio.dropImage

gizlang
function Studio.dropImage(self: Studio): void

The image model leaves the GPU, so another engine can use its memory.

Effects: fail, read, write, console, io.

Studio.dropVideo

gizlang
function Studio.dropVideo(self: Studio): void

The video model leaves the GPU, as dropImage does the image model.

Effects: fail, read, write, console, io.

Studio.loaded

gizlang
function Studio.loaded(self: Studio): Vec<string>

The models loaded now ("chat", "image", "video").

Effects: fail, read.

Studio.video

gizlang
function Studio.video(self: Studio, prompt: string): bytes throws string

A video of prompt (videoRequest), as MP4.

Effects: fail, read, write, console, io.