import { type SQLWrapper } from 'drizzle-orm'; import { type SQL } from 'drizzle-orm/sql/sql'; export interface MotherDuckJevLabel { label: string; description?: string | null; } export type MotherDuckJevCriteria = readonly string[] | readonly MotherDuckJevLabel[]; export type MotherDuckJevImageFormat = 'png' | 'jpg' | 'jpeg'; export interface MotherDuckJevImage { /** Name the instructions use to refer to the image, in backticks. */ name: string; /** Image bytes, or a SQL expression that yields a BLOB. */ image: Uint8Array | SQLWrapper; /** Still image encoding. MotherDuck assumes `jpg` when omitted. */ format?: MotherDuckJevImageFormat; } /** A text value or expression, or a list of named images. */ export type MotherDuckJevInput = string | SQLWrapper | readonly MotherDuckJevImage[]; export type MotherDuckJevQuestion = { type: 'noul'; instructions: string; criteria?: MotherDuckJevCriteria; } | { type: 'choice'; instructions: string; criteria: MotherDuckJevCriteria; } | { type: 'score'; instructions: string; criteria: MotherDuckJevCriteria; } | { /** Locate a region of an image. Requires image input. */ type: 'box'; instructions: string; criteria?: never; }; export interface MotherDuckJevProbability { value: string; probability: number; } export interface MotherDuckJevChoiceResult { choice: string; probabilities: MotherDuckJevProbability[]; confidence: number; } export interface MotherDuckJevScoreResult { score: number; probabilities: (MotherDuckJevProbability & { index: number; })[]; confidence: number; } export interface MotherDuckJevMultipleChoiceResult { /** Every candidate whose independent probability is above 0.5. */ choices: string[]; probabilities: MotherDuckJevProbability[]; } export interface MotherDuckJevBoxResult { /** Edges of the region as fractions of the image size. */ box: { top: number; bottom: number; left: number; right: number; }; confidence: number; } type NoSelectors = { choice?: never; score?: never; noul?: never; multipleChoice?: never; }; type JevQuestionOptions = NoSelectors & { questions: string | Record; instructions?: never; box?: never; /** Rows per request, from 1 to 64. Not allowed with image input. */ batchSize?: number; }; type JevBoxOptions = NoSelectors & { /** Describe the region to locate. Requires image input. */ box: string; questions?: never; instructions?: never; batchSize?: never; }; type JevSingleQuestionOptions = { questions?: never; box?: never; instructions: string; /** Rows per request, from 1 to 64. Not allowed with image input. */ batchSize?: number; } & (NoSelectors | (Omit & { choice: MotherDuckJevCriteria; }) | (Omit & { score: MotherDuckJevCriteria; }) | (Omit & { noul: MotherDuckJevCriteria; }) | (Omit & { multipleChoice: MotherDuckJevCriteria; })); export type MotherDuckPromptJevOptions = JevQuestionOptions | JevBoxOptions | JevSingleQuestionOptions; type JevQuestionResult = Q extends { type: 'choice'; } ? MotherDuckJevChoiceResult : Q extends { type: 'score'; } ? MotherDuckJevScoreResult : Q extends { type: 'box'; } ? MotherDuckJevBoxResult : Q extends { type: 'noul'; } ? number : unknown; /** The decoded value of a prompt_jev call, keyed by the options it was built with. */ export type MotherDuckPromptJevResult = O extends { questions: infer Q extends string | Record; } ? Q extends string ? Record : { [K in keyof Q]: JevQuestionResult; } : O extends { box: string; } ? MotherDuckJevBoxResult : O extends { choice: MotherDuckJevCriteria; } ? MotherDuckJevChoiceResult : O extends { score: MotherDuckJevCriteria; } ? MotherDuckJevScoreResult : O extends { multipleChoice: MotherDuckJevCriteria; } ? MotherDuckJevMultipleChoiceResult : number; /** * Build prompt_jev with literal question metadata required by MotherDuck's * binder. The input remains a bound value or SQL expression. Pass a list of * named images to classify images or to locate a region with `box`. */ export declare function mdPromptJev(input: MotherDuckJevInput, options: O): SQL | null>; export {};