Skip to main content

together_gradio

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

Installation

  1. Clone this repo: git clone git@github.com:gradio-app/together_gradio.git
  2. Navigate into the folder that you cloned this repo into: cd together_gradio
  3. Install this package: pip install -e .

That's it!

Basic Usage

Just like if you were to use the Together Client, you should first save your together API token to this environment variable:

export TOGETHER_API_KEY=<your token>

Then in a Python file, write:

import gradio as gr
import together_gradio

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

Run the Python file, and you should see a Gradio ChatInterface connected to the model on Together!

ChatInterface

Customization

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

import gradio as gr
import together_gradio

gr.load(
    name='meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo',
    src=together_gradio.registry,
    title='Together-Gradio Integration',
    description="Chat with Meta-Llama-3.1-70B-Instruct-Turbo 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 together_gradio

with gr.Blocks() as demo:
    with gr.Tab("8B"):
        gr.load('meta-llama/Meta-Llama-3-8B-Instruct-Lite', src=Together_gradio.registry)
    with gr.Tab("70B"):
        gr.load('meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo', src=Together_gradio.registry)

demo.launch()

Under the Hood

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

Supported Models in Together API

Currently the available options are: llama3.1-8b, llama3.1-70b


Note: if you are getting a 401 authentication error, then the Together 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["TOGETHER_API_KEY"] = ...

Metadata

Release files for together-gradio 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for together-gradio 0.0.1
File Size Uploaded Provenance
together_gradio-0.0.1.tar.gz 62.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for together-gradio 0.0.1
File Interpreter ABI Platform
together_gradio-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 66.0 kB

Release files / together_gradio-0.0.1.tar.gz

Download URL together_gradio-0.0.1.tar.gz
Size 62.2 kB
Tags Source
SHA-256 checksum
How to use checksums
48ed2a0b20fe48d92de043ac4f3383277be2635aa618d8a2f8e6ad3db171b2b8
BLAKE2b-256 checksum
How to use checksums
898fa771cc8c822688a241c13439e22d34b09a06b0cae0484aedf104fb55cdc1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.6

Release files / together_gradio-0.0.1-py3-none-any.whl

Download URL together_gradio-0.0.1-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f1e5cea4743ca1453f097cd35e55100880ac88f56e12af613bb8e140c123b20f
BLAKE2b-256 checksum
How to use checksums
c1ae71c91dabae48d58786281d473a849cb03145720ffeb1c1ff0db057aba990
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.6

Security for together-gradio 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page