A powerful Python library for automating interactions with AI models (ChatGPT, Claude, Gemini) through their web interfaces using Playwright. Supports both synchronous and asynchronous operations, file handling, and multi-platform compatibility.
Project description
AI On UI (aionui)
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
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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa60cf861327b34c7277657219562a6aa94fe8f50607f5b6a4c468b3fac5e271
|
|
| MD5 |
33c8644696869eb750cf66b9d91ba530
|
|
| BLAKE2b-256 |
ded46df0986ece0bdd8bd4a73406feba362662b5171226cee4bd45ae1d276532
|
Provenance
The following attestation bundles were made for aionui-1.4.2.tar.gz:
Publisher:
publish.yml on AnhHoang-1503/AiOnUi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aionui-1.4.2.tar.gz -
Subject digest:
aa60cf861327b34c7277657219562a6aa94fe8f50607f5b6a4c468b3fac5e271 - Sigstore transparency entry: 255404418
- Sigstore integration time:
-
Permalink:
AnhHoang-1503/AiOnUi@bbcf383992c2f4ebf1d3c82f09b5f54d6e1ddddd -
Branch / Tag:
refs/tags/V1.4.2 - Owner: https://github.com/AnhHoang-1503
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bbcf383992c2f4ebf1d3c82f09b5f54d6e1ddddd -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b6b6e74d63e2e1fc7e9f16d71f02373654caf1415b2e74a534aa2e6251f3be7
|
|
| MD5 |
0671f6ba64411124a99fe3a357971bbb
|
|
| BLAKE2b-256 |
e313be919d8de383e20811a7064e5f021d2f44babd668f7dab6a0370287db64e
|
Provenance
The following attestation bundles were made for aionui-1.4.2-py3-none-any.whl:
Publisher:
publish.yml on AnhHoang-1503/AiOnUi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aionui-1.4.2-py3-none-any.whl -
Subject digest:
9b6b6e74d63e2e1fc7e9f16d71f02373654caf1415b2e74a534aa2e6251f3be7 - Sigstore transparency entry: 255404421
- Sigstore integration time:
-
Permalink:
AnhHoang-1503/AiOnUi@bbcf383992c2f4ebf1d3c82f09b5f54d6e1ddddd -
Branch / Tag:
refs/tags/V1.4.2 - Owner: https://github.com/AnhHoang-1503
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bbcf383992c2f4ebf1d3c82f09b5f54d6e1ddddd -
Trigger Event:
release
-
Statement type: