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-2/

Gradio Sentiment Analyzer Client

Build a command-line tool that uses a Gradio application to analyze the sentiment of text input. The tool should connect to a Gradio sentiment analysis API and return the predicted sentiment along with confidence scores.

Requirements

Your tool should:

  1. Accept a Gradio application URL and text input as command-line arguments
  2. Connect to the specified Gradio application
  3. Send the text to the sentiment analysis endpoint for prediction
  4. Display the prediction results in a clean, readable format
  5. Handle connection errors gracefully with appropriate error messages

Input Format

The tool should be invocable as follows:

node sentiment-cli.js <gradio-url> <text>

For example:

node sentiment-cli.js "https://example-sentiment.hf.space" "I love this product!"

Output Format

The tool should output the sentiment prediction result. For example:

Sentiment: positive
Confidence: 0.95

Test Cases

  • When connecting to a valid Gradio app and submitting "This is amazing!", the tool returns a sentiment prediction @test
  • When provided with invalid connection details, the tool handles errors gracefully and displays an error message @test
  • When submitting an empty string, the tool still processes the request and returns a result @test

Implementation

@generates

API

/**
 * Connects to a Gradio application and makes a sentiment prediction
 * @param {string} gradioUrl - The URL of the Gradio application
 * @param {string} text - The text to analyze
 * @returns {Promise<Object>} The prediction result with sentiment and confidence
 */
async function analyzeSentiment(gradioUrl, text) {
  // IMPLEMENTATION HERE
}

module.exports = { analyzeSentiment };

Dependencies { .dependencies }

@gradio/client { .dependency }

Provides client library for interacting with Gradio applications.

Install with Tessl CLI

npx tessl i tessl/npm-gradio--client

tile.json