JavaScript and TypeScript client library for interacting with Gradio APIs, providing methods to connect to, submit predictions to, and manage connections with Gradio applications.
Overall
score
96%
A utility that validates parameters before making predictions to a Gradio API endpoint.
Build a function that validates user-provided parameters against a Gradio API schema before submitting predictions. Use the API introspection capabilities to retrieve endpoint schemas, then validate that all required parameters are present, detect invalid parameters, and support both positional and keyword argument formats. The goal is to catch parameter errors early before making actual API calls.
Retrieves and parses API schema information from a connected Gradio client.
Validates that all required parameters are provided before making API calls.
Detects when users provide parameters not defined in the endpoint schema.
Supports both positional (array) and keyword (object) parameter formats for flexibility.
@generates
import { Client } from "@gradio/client";
/**
* Result of parameter validation
*/
interface ValidationResult {
valid: boolean;
params?: Record<string, any>;
error?: string;
}
/**
* Retrieves API schema information for a specific endpoint
*
* @param client - Connected Gradio client instance
* @param endpoint - Name or index of the endpoint
* @returns Object containing parameter definitions and requirements
*/
export async function getEndpointSchema(
client: Client,
endpoint: string | number
): Promise<any>;
/**
* Validates user-provided parameters against a Gradio endpoint schema
*
* @param client - Connected Gradio client instance
* @param endpoint - Name or index of the endpoint to validate against
* @param userParams - Parameters provided by the user (array for positional, object for keyword)
* @returns Validation result with processed parameters or error message
*/
export async function validateEndpointParams(
client: Client,
endpoint: string | number,
userParams: any[] | Record<string, any>
): Promise<ValidationResult>;JavaScript/TypeScript client library for interacting with Gradio APIs. Provides Client class for connections and view_api() method for API introspection.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-gradio--clientevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10