Skip to main content

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!

ChatInterface

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()

ChatInterface with customizations

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xai_gradio-0.0.2.tar.gz (309.4 kB view details)

Uploaded Source

Built Distribution

xai_gradio-0.0.2-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file xai_gradio-0.0.2.tar.gz.

File metadata

  • Download URL: xai_gradio-0.0.2.tar.gz
  • Upload date:
  • Size: 309.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.6

File hashes

Hashes for xai_gradio-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c472da98a0d909c78d845af1447138ab39bf06a0501ee825c64409420f341f84
MD5 3e7beb9d99eba69a09af153ae3684c1f
BLAKE2b-256 97ce057df4fc475aaf460e3ff92e212fba7b6bfb33fa1ee9223f5177b3ae0af8

See more details on using hashes here.

File details

Details for the file xai_gradio-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: xai_gradio-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.6

File hashes

Hashes for xai_gradio-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7f013545a0e852fd200dec43e4c57220aec5a5c21d6910159d71eaafcc5fca5b
MD5 d8b1546f8ba9005b5d4615c2672b4c0a
BLAKE2b-256 6252a76738332270c41f93d64603627c895bfb0e91a79da156ca88ad6e825901

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page