Skip to content

16A9DA/WidgetAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WidgetAI

WidgetAI is a floating desktop widget that gives you instant, friction‑free access to ChatGPT, Claude, and Perplexity from a single, compact terminal‑style interface.
No browser tabs, no copy‑pasting, no context switching: just type a command and get the answer inline.


Features

  • One‑click AI access send prompts to ChatGPT, Claude, or Perplexity with simple slash commands.
  • Floating always‑on‑top stays above all windows; perfect for developers, researchers, and writers.
  • Terminal‑inspired UI classic black/green design with a retro feel, minimal and distraction‑free.
  • Automatic fallback if one provider fails, it transparently retries the next in your fallback chain (chatgpt → claude → perplexity).
  • Live streaming responses see the AI’s answer appear in real‑time, not just when it finishes.
  • Rich formatting renders Markdown tables, code blocks, lists, links, bold, and italic properly (requires markdown).
  • Persistent history per provider every prompt and response is saved locally (in ~/.widgetai/history.json).
  • Smart memory injection the last 8 successful exchanges are automatically prepended to new prompts, so the AI “remembers” the conversation even after a restart.
  • Cross‑model memory switch from ChatGPT to Claude and the previous context is carried over.
  • History viewer display recent prompts and answers for any provider with /history [provider].
  • Clear history wipe all or per‑provider history with /clear [provider].
  • Login assistant if a provider requires you to log in, use /login chatgpt to open the login window and stay authenticated.
  • Compact / expanded modes the widget stays small while idle and expands automatically when a response appears.
  • Docker support run WidgetAI in a container without installing Python dependencies locally.

Docker

WidgetAI is available as a Docker image. Pull and run it with:

docker pull pa9da/widgetai:latest
docker run --rm -it \
  -e DISPLAY=$DISPLAY \
  -v /tmp/.X11-unix:/tmp/.X11-unix \
  -v ~/.widgetai:/root/.widgetai \
  pa9da/widgetai:latest

🚀 Getting Started

Requirements

  • Python 3.9 or higher
  • PySide6, QtWebEngine, and other dependencies (see requirements.txt)

Installation (from source)

git clone https://github.com/yourusername/WidgetAI.git
cd WidgetAI
pip install -r requirements.txt
python app.py

First‑run setup

  1. The widget will appear as a small floating window.
  2. Use /login chatgpt (or /login claude, /login perplexity) to log in once – the browser will open; log in and close it. Your session will be remembered.
  3. Now you can start asking questions.

Command Reference

All commands are entered in the input field. Press Enter to submit.

Command Description
/chatgpt <prompt> Send a prompt to ChatGPT.
/claude <prompt> Send a prompt to Claude.
/perplexity <prompt> Send a prompt to Perplexity.
/ask <prompt> Auto‑select the best provider (with fallback chain).
/login <chatgpt|claude|perplexity> Open the login window for that provider.
/history Show the last 18 entries from all providers.
/history <provider> Show history for a specific provider.
/clear Clear all history.
/clear <provider> Clear history for a specific provider.
/help Display the command reference.
/exit Close WidgetAI.

History & Memory System

WidgetAI stores every user prompt and assistant response in a local JSON file (~/.widgetai/history.json). Each entry is tagged with:

  • role"user" or "assistant"
  • provider"chatgpt", "claude", or "perplexity"
  • status"ok", "pending", "streaming", or "failed"
  • timestamp and the actual content.

How memory works

  • When you send a prompt, the system first builds a shared memory string from the last 8 successful exchanges (status "ok") across all providers.
  • This memory is prepended to your new prompt as context, so the AI can “remember” what was discussed earlier.
  • If you switch from ChatGPT to Claude, Claude will still see the previous conversation history, making the experience seamless.

Viewing history

Use the /history command to see a plain‑text list of recent interactions. The output includes the role, provider, and status (if not ok).

Clearing history

Use /clear to wipe everything, or /clear chatgpt to clear only that provider’s history.


Output Formatting

WidgetAI uses the markdown Python library to render responses with full Markdown support.
The following are automatically styled in the output panel:

  • Code blocks with syntax highlighting (pre‑formatted)
  • Inline code
  • Tables
  • Unordered and ordered lists
  • Bold and italic text
  • Links (clickable)
  • Blockquotes and headings

Customisation

You can tweak the UI style, polling intervals, fallback chain, and memory limit by editing core/settings.py.
Common settings include:

  • FALLBACK_CHAIN – list of providers to try in order.
  • SHARED_MEMORY_LIMIT – number of history entries to use as context.
  • COMPACT_WIDTH, COMPACT_HEIGHT, MAX_EXPANDED_HEIGHT – widget dimensions.
  • POLL_INTERVAL_MS – how often to check for a new response.

📁 Project Structure

WidgetAI/
├── app.py                     # Main entry point
├── ui/
│   └── main_window.py         # UI logic
├── core/
│   ├── command_router.py      # Parses slash commands
│   ├── web_session.py         # Hidden browser automation
│   ├── provider_base.py       # Base class for AI providers
│   ├── chatgpt_provider.py
│   ├── claude_provider.py
│   ├── perplexity_provider.py
│   ├── provider_registry.py
│   ├── history_store.py       # Persistence & memory management
│   ├── failure_detection.py   # Retry logic
│   ├── output_formatter.py    # Markdown → HTML conversion
│   ├── logging_config.py
│   └── settings.py
├── requirements.txt
└── README.md

🤝 Contributing

Contributions are welcome! If you find a bug or have an idea for a new feature, feel free to open an issue or submit a pull request.


📄 License

MIT — see the LICENSE file for details.


🙏 Acknowledgements

  • Built with PySide6 and Qt WebEngine.
  • Inspired by the need for a lightweight AI terminal for daily tasks.

Enjoy your new AI terminal!
If you have any questions, open an issue or reach out.
/chatgpt happy coding!

About

Fast access to multiple AI systems from a single desktop.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors