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.3.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.3-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hyperbolic_gradio-0.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 4c96231af32bc31ba726553e73fd4a493e9724a0a89a8896ce1645574bd48857
MD5 952a58d5379e2013c6505586392d9c1b
BLAKE2b-256 0753c9c42f0a16aa36a0f00c9dcc6aec47df162e6fbac79f9ca26afa0f8fb7a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hyperbolic_gradio-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c4e7cda37ec177d58097c246e9a1c20f70655947f85a1cb264f47b874dc3da80
MD5 acf2523e5749268811ca9e4c4a90193e
BLAKE2b-256 51f1b0ceb799fa033f1f7e6fae7a312cec57de61f8e4487c05062c025cd660e6

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