A Python package for creating Gradio applications with XAI models
Project description
xai-gradio
is a Python package that makes it very easy for developers to create machine learning apps that are powered by XAI API.
Installation
You can install xai-gradio
directly using pip:
pip install xai-gradio
That's it!
Basic Usage
You'll need to save your xAI API key to the appropriate environment variable:
export XAI_API_KEY=<your token>
Then in a Python file, write:
import gradio as gr
import xai_gradio
gr.load(
name='grok-beta',
src=xai_gradio.registry,
).launch()
Run the Python file, and you should see a Gradio Interface connected to your chosen model!
Customization
Once you can create a Gradio UI from an OpenAI 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 xai_gradio
gr.load(
name='grok-beta',
src=xai_gradio.registry,
title='X.AI-Gradio Integration',
description="Chat with grok-beta 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 xai_gradio
with gr.Blocks() as demo:
with gr.Tab("grok-beta"):
gr.load('grok-beta', src=xai_gradio.registry)
demo.launch()
Under the Hood
The xai-gradio Python library has two dependencies: openai and gradio. It defines a "registry" function xai_gradio.registry, which takes in a model name and returns a Gradio app.
Supported Models and Providers
The following AI models are currently supported:
- xAI (Grok-beta)
For a comprehensive list of available models and their specifications, please refer to:
Note: if you are getting authentication errors, ensure you have set the correct environment variable. You can also set it in your Python session:
import os
os.environ["XAI_API_KEY"] = ...
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file xai_gradio-0.0.1.tar.gz
.
File metadata
- Download URL: xai_gradio-0.0.1.tar.gz
- Upload date:
- Size: 308.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92661d9bc6d6359a1621f9bf3275fede9ca0653b0d978ea04a787ef6a24cbafd |
|
MD5 | 0679e89e53bde4cf8792a731e37bfa0b |
|
BLAKE2b-256 | 1e9122d3fb5afeeaa13ce1357f9aff943175b8ffaaf07e989619c534b95ac1a5 |
File details
Details for the file xai_gradio-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: xai_gradio-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 325278ac2750ad26ae2e955c4486259fbd787b67bc01627b39d81c524eaef2ac |
|
MD5 | d883c40903fde0147e3115585199415d |
|
BLAKE2b-256 | 507e2a2c63ad58c7d00ea5e702a1183807165aa8ce435234c24d0bd41a2809c3 |