import { type LocalRequestOptions } from "../stdlib/localRequest.js"; import { type Result } from "./result.js"; /** The functions that call the server `agency local serve` runs, for a * TypeScript program. Each sends the request its `std::image` or * `std::vision` twin sends, and differs from it in three ways: it raises * no interrupt, it takes an image as a path or as bytes, and it takes the * server's address as an option. */ /** What every call function takes. * * baseUrl the server's address, such as `server.url` from `serve`. * Absent: `client.baseUrl.mlx` in agency.json, then the * `MLX_BASE_URL` environment variable, then port 8080 on this * machine * signal aborting it ends the call with the failure "Cancelled" */ export type CallOptions = LocalRequestOptions; /** An image to send: the path of a file on this machine, or the image's * bytes. */ export type ImageInput = string | Uint8Array; export type GeneratedImage = { bytes: Uint8Array; mimeType: string; seed: number | null; }; export type GenerateImageOptions = CallOptions & { model: string; prompt: string; size?: string; steps?: number; guidance?: number; seed?: number; negativePrompt?: string; format?: "png" | "jpeg" | "webp"; lora?: string; loraScale?: number; controlnet?: string; controlImage?: ImageInput; controlScale?: number; invertControlImage?: boolean; images?: ImageInput[]; startImage?: ImageInput; strength?: number; mask?: ImageInput; }; /** Generate one image with a local image model. The twin of * `generateImageLocal` in `std::image`, and it takes the same settings. */ export declare function generateImage(options: GenerateImageOptions): Promise>; /** A box in an image, each number a fraction of the image's width or * height, measured from the top left. */ export type BoundingBox = { x: number; y: number; width: number; height: number; }; /** One thing a detector found. `id` is its index in the reply. */ export type Detection = { id: number; label: string; score: number; box: BoundingBox; }; /** One box around a thing in a picture, found with no name. */ export type Region = { id: number; score: number; box: BoundingBox; }; /** One tag a tagger gave, with how sure it was, 0 to 1. */ export type Tag = { tag: string; score: number; }; /** What every vision function takes besides its own settings. */ export type VisionOptions = CallOptions & { model: string; image: ImageInput; }; /** The settings each vision function uses when the caller gives none. * The stdlib's are the parameter defaults in `stdlib/vision.agency`, and a * test compares the two. */ export declare const VISION_DEFAULTS: { readonly detectObjects: { readonly threshold: null; }; readonly tagImage: { readonly threshold: 0.35; readonly limit: 30; }; readonly captionImage: { readonly detail: "short"; }; readonly embedImage: { readonly boxes: null; }; readonly findRegions: { readonly limit: 50; readonly threshold: null; }; }; /** Find the named things in an image with a local detector. A threshold * left out is the model's own default. */ export declare function detectObjects(options: VisionOptions & { labels: string[]; threshold?: number; }): Promise>; /** Describe an image as tags with a local tagger, best first. */ export declare function tagImage(options: VisionOptions & { threshold?: number; limit?: number; }): Promise>; /** Write a sentence about an image with a local model. */ export declare function captionImage(options: VisionOptions & { detail?: string; }): Promise>; /** Turn an image into embeddings: one for the whole image, or one for * each box given. */ export declare function embedImage(options: VisionOptions & { boxes?: BoundingBox[]; }): Promise>; /** Box every thing in an image with a local model, with no names. A * threshold left out is the server's default. */ export declare function findRegions(options: VisionOptions & { limit?: number; threshold?: number; }): Promise>;