Skip to main content

AI On UI (aionui)

PyPI version License: MIT Python 3.10+ Code style: black

A powerful Python library for automating interactions with AI models (ChatGPT, Claude, Gemini) through their web interfaces. Supports both synchronous and asynchronous operations, file handling, and cross-platform compatibility.

Key Features

  • 🤖 Multiple AI Model Support:

    • ChatGPT
    • Claude
    • Gemini
  • 🔄 Dual Operation Modes:

    • Sync: for sequential code
    • Async: for asynchronous applications
  • 📦 Versatile Data Handling:

    • Text responses
    • Code blocks
    • JSON structures
    • Images
    • File upload/download
  • 🛠 Advanced Features:

    • Web search (ChatGPT)
    • Large file processing
    • Retry mechanism
    • Detailed logging
    • Cross-platform support

Installation

pip install aionui

Requirements

  • Python 3.10+
  • Google Chrome
  • Playwright

Quickstart

Synchronous Usage

from aionui import AiOnUi

# Initialize
aionui = AiOnUi()

# ChatGPT
with aionui.model_sync("gpt") as model:
    response = model.chat("Hello!")
    print(response)

# Claude
with aionui.model_sync("claude") as model:
    response = model.chat("Hello!")
    print(response)

# Gemini
with aionui.model_sync("gemini") as model:
    response = model.chat("Hello!")
    print(response)

Asynchronous Usage

import asyncio
from aionui import AiOnUi

async def main():
    aionui = AiOnUi()
    
    async with aionui.model_async("gpt") as model:
        response = await model.chat("Hello!")
        print(response)

# Run
asyncio.run(main())

Configuration

Create a config.yaml file:

# Chrome settings
chrome_binary_path: "/usr/bin/google-chrome"  # Path to Chrome binary
user_data_dir: "~/chrome-data"                # Profile directory
debug_port: 9222                              # Port to connect over devtools protocol

Use the config:

aionui = AiOnUi("config.yaml")

Advanced Examples

File Upload and Analysis

async with aionui.model_async("claude") as model:
    # Upload file
    await model.text_as_file("Content for analysis", "data.txt")
    
    # Analyze
    response = await model.chat("Analyze the uploaded data")
    print(response)

Web Search with ChatGPT

with aionui.model_sync("gpt") as model:
    response = model.chat(
        "Latest news about AI?",
        tools=["search_the_web"]
    )
    print(response)

JSON Response

with aionui.model_sync("gemini") as model:
    json_response = model.chat(
        "List 3 programming languages",
        expected_result="json"
    )
    print(json_response)

Documentation

See more examples and detailed guides in the examples directory.

Contributing

Contributions are welcome! See CONTRIBUTING.md for more details.

License

MIT License - see LICENSE for details.

Credits

Copyright (c) 2024 Vu Tri Anh Hoang - GitHub

Download files

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

Source Distribution

aionui-1.4.2.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aionui-1.4.2-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file aionui-1.4.2.tar.gz.

File metadata

  • Download URL: aionui-1.4.2.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for aionui-1.4.2.tar.gz
Algorithm Hash digest
SHA256 aa60cf861327b34c7277657219562a6aa94fe8f50607f5b6a4c468b3fac5e271
MD5 33c8644696869eb750cf66b9d91ba530
BLAKE2b-256 ded46df0986ece0bdd8bd4a73406feba362662b5171226cee4bd45ae1d276532

See more details on using hashes here.

Provenance

The following attestation bundles were made for aionui-1.4.2.tar.gz:

Publisher: publish.yml on AnhHoang-1503/AiOnUi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aionui-1.4.2-py3-none-any.whl.

File metadata

  • Download URL: aionui-1.4.2-py3-none-any.whl
  • Upload date:
  • Size: 27.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for aionui-1.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9b6b6e74d63e2e1fc7e9f16d71f02373654caf1415b2e74a534aa2e6251f3be7
MD5 0671f6ba64411124a99fe3a357971bbb
BLAKE2b-256 e313be919d8de383e20811a7064e5f021d2f44babd668f7dab6a0370287db64e

See more details on using hashes here.

Provenance

The following attestation bundles were made for aionui-1.4.2-py3-none-any.whl:

Publisher: publish.yml on AnhHoang-1503/AiOnUi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.4.2 This release

2 files

1.4.1

2 files

1.4.0

2 files

1.3.3

2 files

1.3.1

2 files

1.3.0

2 files

1.2.1

2 files

1.2.0

2 files

1.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page