A Python package for replicating Gradio applications
Project description
sambanova_gradio
is a Python package that makes it very easy for developers to create machine learning apps that are powered by sambanova's Inference API.
Installation
Install this package: pip install sambanova-gradio
That's it!
Basic Usage
Just like if you were to use the sambanova API, you should first save your sambanova API token to this environment variable:
export SAMBANOVA_API_KEY=<your token>
Then in a Python file, write:
import gradio as gr
import sambanova_gradio
gr.load(
name='Meta-Llama-3.1-405B-Instruct',
src=sambanova_gradio.registry,
).launch()
Run the Python file, and you should see a Gradio Interface connected to the model on sambanova!
Customization
Once you can create a Gradio UI from a sambanova 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 sambanova_gradio
gr.load(
name='Meta-Llama-3.1-405B-Instruct',
src=sambanova_gradio.registry,
title='Sambanova-Gradio Integration',
description="Chat with Meta-Llama-3.1-405B-Instruct model.",
examples=["Explain quantum gravity to a 5-year old.", "How many R are there in the word Strawberry?"]
).launch()
Composition
Or use your loaded Interface within larger Gradio Web UIs, e.g.
import gradio as gr
import sambanova_gradio
with gr.Blocks() as demo:
with gr.Tab("405B"):
gr.load('Meta-Llama-3.1-405B-Instruct', src=sambanova_gradio.registry)
with gr.Tab("70B"):
gr.load('Meta-Llama-3.1-70B-Instruct-8k', src=sambanova_gradio.registry)
demo.launch()
Under the Hood
The sambanova-gradio Python library has two dependencies: openai and gradio. It defines a "registry" function sambanova_gradio.registry, which takes in a model name and returns a Gradio app.
Supported Models in Sambanova Cloud
| Model | Context Length | Output Length | Dtype / Precision |
|---|---|---|---|
| Meta-Llama-3.1-8B-Instruct | 4096 | 1000 | BF16 |
| Meta-Llama-3.1-8B-Instruct-8k | 8192 | 1000 | BF16 |
| Meta-Llama-3.1-70B-Instruct | 4096 | 1000 | BF16 |
| Meta-Llama-3.1-70B-Instruct-8k | 8192 | 1000 | BF16 |
| Meta-Llama-3.1-405B-Instruct | 4096 | 1000 | BF16 |
| Meta-Llama-3.1-405B-Instruct-8k | 8192 | 1000 | BF16 |
Note: if you are getting a 401 authentication error, then the sambanova 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["SAMBANOVA_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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sambanova_gradio-0.1.4.tar.gz.
File metadata
- Download URL: sambanova_gradio-0.1.4.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b04c883eebfc6409b26bd2efcc0ebc2f689c304fd990d85309d627b831fecf9
|
|
| MD5 |
0e2ec9f325609a067702dd01d457dbe7
|
|
| BLAKE2b-256 |
37179c98eea743a154e8dc8174d0b80c712c7c87d8bd70687a5d0895f4d8f54c
|
File details
Details for the file sambanova_gradio-0.1.4-py3-none-any.whl.
File metadata
- Download URL: sambanova_gradio-0.1.4-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
608ac39568a296c01ad26181856917bb0990cc473abe692cda208fbd3d17b978
|
|
| MD5 |
211f764a20a547d9c0b0f19ed5d33f32
|
|
| BLAKE2b-256 |
32de85441444aa8456331ebb1c7754d3580b5758457e53f0b45fc06f2f465849
|