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

Uploaded Python 3

File details

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

File metadata

  • Download URL: hyperbolic_gradio-0.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 a2be49f8840aacb9b1ba0743aa84b3b8eb58455051eb949acf61e225d3d574f3
MD5 afc8b4ae71987b4fadd10f3819cad960
BLAKE2b-256 be20a7c73e740a9c68ca3503f99d373945afb6e6e60905ebc1c374c47eae5edc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hyperbolic_gradio-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 58d7c8046496545d542ff8fe90a30a4608f3c473d9990e8ba24c196b0d0ee345
MD5 fc9be865d3395fcaae8de96868b7fd30
BLAKE2b-256 9e7fd0300972a07d25ce4de424fb6b9d132378b3be7a8c7d56bac59599623c48

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