Skip to main content

A Python package for creating Gradio applications with Hyperbolic AI models

Project description

hyperbolic-gradio

is a Python package that makes it very easy for developers to create machine learning apps that are powered by Hyperbolic AI's API.

Installation

You can install hyperbolic-gradio directly using pip:

pip install hyperbolic-gradio

That's it!

Basic Usage

Just like if you were to use the hyperbolic API, you should first save your Hyperbolic API key to this environment variable:

export HYPERBOLIC_API_KEY=<your token>

Then in a Python file, write:

import gradio as gr
import hyperbolic_gradio

gr.load(
    name='meta-llama/Meta-Llama-3-70B-Instruct',
    src=hyperbolic_gradio.registry,
).launch()

Run the Python file, and you should see a Gradio Interface connected to the model on Hyperbolic AI!

ChatInterface

Customization

Once you can create a Gradio UI from an Hyperbolic API endpoint, you can customize it by setting your own input and output components, or any other arguments to gr.Interface. For example, the screenshot below was generated with:

import gradio as gr
import hyperbolic_gradio

gr.load(
    name='meta-llama/Meta-Llama-3-70B-Instruct',
    src=hyperbolic_gradio.registry,
    title='Hyperbolic-Gradio Integration',
    description="Chat with Meta-Llama-3-70B-Instruct model.",
    examples=["Explain quantum gravity to a 5-year old.", "How many R are there in the word Strawberry?"]
).launch()

ChatInterface with customizations

Composition

Or use your loaded Interface within larger Gradio Web UIs, e.g.

import gradio as gr
import hyperbolic_gradio

with gr.Blocks() as demo:
    with gr.Tab("Meta-Llama-3-70B-Instruct"):
        gr.load('meta-llama/Meta-Llama-3-70B-Instruct', src=hyperbolic_gradio.registry)
    with gr.Tab("Llama-3.2-3B-Instruct"):
        gr.load('meta-llama/Llama-3.2-3B-Instruct', src=hyperbolic_gradio.registry)

demo.launch()

Under the Hood

The hyperbolic-gradio Python library has two dependencies: hyperbolic and gradio. It defines a "registry" function hyperbolic_gradio.registry, which takes in a model name and returns a Gradio app.

Supported Models in Hyperbolic AI

All chat API models supported by Hyperbolic AI are compatible with this integration. For a comprehensive list of available models and their specifications, please refer to the Hyperbolic AI Models documentation.


Note: if you are getting a 401 authentication error, then the Hyperbolic API Client is not able to get the API token from the environment variable. This happened to me as well, in which case save it in your Python session, like this:

import os

os.environ["HYPERBOLIC_API_KEY"] = ...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hyperbolic_gradio-0.0.2.tar.gz (162.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hyperbolic_gradio-0.0.2-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file hyperbolic_gradio-0.0.2.tar.gz.

File metadata

  • Download URL: hyperbolic_gradio-0.0.2.tar.gz
  • Upload date:
  • Size: 162.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for hyperbolic_gradio-0.0.2.tar.gz
Algorithm Hash digest
SHA256 aa877503449e616c7eba6ff4b489c96c7b5a4eba9885e1465e081b14ec8ac3b5
MD5 cf6ceba6a118fbd92bf472d62a2f0316
BLAKE2b-256 0bb9233414dca6a7d91e7e1e69c1f2952d06debd9b34ba57d2ddc2ecc100fb2c

See more details on using hashes here.

File details

Details for the file hyperbolic_gradio-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for hyperbolic_gradio-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 700387a102e96cde75b06a61bdb488b174e1e44f3256c64abedc6dcc26c4ae61
MD5 c40744e0ba54b3b3e2935dc3d4ffa229
BLAKE2b-256 58b282e71a662422f3b840f6792de03942502ffcd19ae628e2e56f75b9bd3438

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page