1. Install the Javascript client (docs) if you don't already have it installed.
copy
$ npm i -D @gradio/client
2. Find the API endpoint below corresponding to your desired function in the app. Copy the code snippet, replacing the placeholder values with your own input data. Or use the
API Recorder
to automatically generate your API requests.
api_name: [color=var(--color-accent)]/load_modelcopy
import { Client } from "@gradio/client";const client = await Client.connect([color=var(--color-accent-base)]"http://127.0.0.1:7860/");const result = await client.predict([color=var(--color-accent)]"/load_model", { model: "情感模型", });console.log(result.data);
Accepts 1 parameter:
model string Default: "请先选择加载模型"
[color=var(--body-text-color-subdued)]The input value that is provided in the "模型" Dropdown component.
Returns list of 2 elements
[0] string
[color=var(--body-text-color-subdued)]The output value that appears in the "状态" Textbox component.
[1] string
[color=var(--body-text-color-subdued)]The output value that appears in the "模型" Dropdown component.
1. Install the Python client (docs) if you don't already have it installed.
copy
$ pip install gradio_client
2. Find the API endpoint below corresponding to your desired function in the app. Copy the code snippet, replacing the placeholder values with your own input data. Or use the
API Recorder
to automatically generate your API requests.
api_name: /load_model
copy
from gradio_client import Client