/** * See default-widget-inputs.ts for the default widget inputs, this files only contains the types */ type TableData = Record; //#region outputs export type WidgetExampleOutputLabels = Array<{ label: string; score: number }>; export interface WidgetExampleOutputAnswerScore { answer: string; score: number; } export interface WidgetExampleOutputText { text: string; } export interface WidgetExampleOutputUrl { url: string; } export type WidgetExampleOutput = | WidgetExampleOutputLabels | WidgetExampleOutputAnswerScore | WidgetExampleOutputText | WidgetExampleOutputUrl; //#endregion export interface WidgetExampleBase { example_title?: string; group?: string; /** * Potential overrides to API parameters for this specific example * (takes precedences over the model card metadata's inference.parameters) */ parameters?: { /// token-classification aggregation_strategy?: string; /// text-generation top_k?: number; top_p?: number; temperature?: number; max_new_tokens?: number; do_sample?: boolean; /// text-to-image negative_prompt?: string; guidance_scale?: number; num_inference_steps?: number; }; /** * Optional output */ output?: TOutput; } export interface WidgetExampleTextInput extends WidgetExampleBase { text: string; } export interface WidgetExampleTextAndContextInput extends WidgetExampleTextInput { context: string; } export interface WidgetExampleTextAndTableInput extends WidgetExampleTextInput { table: TableData; } export interface WidgetExampleAssetInput extends WidgetExampleBase { src: string; } export interface WidgetExampleAssetAndPromptInput extends WidgetExampleAssetInput { prompt: string; } export type WidgetExampleAssetAndTextInput = WidgetExampleAssetInput & WidgetExampleTextInput; export type WidgetExampleAssetAndZeroShotInput = WidgetExampleAssetInput & WidgetExampleZeroShotTextInput; export interface WidgetExampleStructuredDataInput extends WidgetExampleBase { structured_data: TableData; } export interface WidgetExampleTableDataInput extends WidgetExampleBase { table: TableData; } export interface WidgetExampleZeroShotTextInput extends WidgetExampleTextInput { text: string; candidate_labels: string; multi_class: boolean; } export interface WidgetExampleSentenceSimilarityInput extends WidgetExampleBase { source_sentence: string; sentences: string[]; } //#endregion export type WidgetExample = | WidgetExampleTextInput | WidgetExampleTextAndContextInput | WidgetExampleTextAndTableInput | WidgetExampleAssetInput | WidgetExampleAssetAndPromptInput | WidgetExampleAssetAndTextInput | WidgetExampleAssetAndZeroShotInput | WidgetExampleStructuredDataInput | WidgetExampleTableDataInput | WidgetExampleZeroShotTextInput | WidgetExampleSentenceSimilarityInput; type KeysOfUnion = T extends unknown ? keyof T : never; export type WidgetExampleAttribute = KeysOfUnion;