CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-gradio--client

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%

Overview
Eval results
Files

task.mdevals/scenario-4/

Space Monitor CLI

Build a command-line tool that monitors the status of a Hugging Face Space and provides real-time updates about its runtime state.

Requirements

Your tool should:

  1. Accept a Hugging Face Space identifier (e.g., "username/space-name") as input
  2. Connect to the specified Space and monitor its status
  3. Display the current status of the Space (e.g., sleeping, running, building, paused, error)
  4. Automatically handle sleeping Spaces by triggering a wake-up
  5. Provide a status callback mechanism that logs status changes with timestamps
  6. Handle authentication using a Hugging Face API token when provided via environment variable HF_TOKEN
  7. Display clear error messages if the Space cannot be reached or is in an error state

Implementation

@generates

Test Cases

Create test cases to verify your implementation:

  • When connecting to a running Space, the tool displays "running" status @test
  • When connecting to a sleeping Space, the tool attempts to wake it up and reports the status change @test
  • When provided with an authentication token, the tool includes it in the connection @test
  • When a status callback is registered, it receives status updates @test

API

/**
 * Monitors a Hugging Face Space and reports its status
 *
 * @param {string} spaceId - The Hugging Face Space identifier (e.g., "user/space-name")
 * @param {Object} options - Configuration options
 * @param {string} [options.hf_token] - Hugging Face API token for authentication
 * @param {Function} [options.onStatusChange] - Callback function called when status changes
 * @returns {Promise<Object>} Status information including current state
 */
async function monitorSpace(spaceId, options = {}) {
  // Implementation here
}

module.exports = { monitorSpace };

Dependencies { .dependencies }

@gradio/client { .dependency }

Provides client connectivity to Gradio applications and Hugging Face Spaces.

Install with Tessl CLI

npx tessl i tessl/npm-gradio--client

tile.json