AGI.green Framework
Project description
AGI.green Framework
A modern Python framework for building AI-powered asynchonous chat applications with a browser interface, featuring markdown content rendering and a unified messaging system.
Application can be built entirely in Python or can integrate with arbitrary external services. This differs from conventional full stack solutions with a javascript frontend application making API calls to a Python backend. Instead, the frontend is a slave and the backend is the application.
Features
- Unified Message Protocol: Consistent message handling across different communication channels
- Rich Content Support:
- Markdown rendering
- Mermaid diagrams
- MathJax equations
- Code syntax highlighting
- YAML forms implementing Vueform
- Flexible Architecture:
- WebSocket-based real-time communication
- Message Queue (AMQP) integration for distributed systems - rabbitmq|ABS|inprocess
- Extensible protocol system - asynchronous interaction with anything
- AI Integration:
- OpenAI API support
- Anthropic Claude support
- Custom model integration capability
- Asynchronous Execution:
- Non limited to call and response
- Can add chat messages in response to arbitrary events, e.g. incoming email or SMS or task completion
- Can execute arbitrary code in response to a message or other events
- No javascript required on the frontend!
- Vue Forms in Markdown (chat and docs):
- Support for YAML and JSON forms in markdown
- Support for forms in chat messages
- Support for forms in documents
- Asynchronous form data events with no javascript required on the frontend (python only)
- That means no need to write any javascript to use forms!
Quick Start
- Install dependencies:
# Install RabbitMQ
sudo apt-get install rabbitmq-server # Ubuntu/Debian
brew install rabbitmq # macOS
# Install package
pip install agi.green
- Create a basic chat application:
from agi_green.dispatcher import Dispatcher
class ChatNode(Dispatcher):
async def on_mq_chat(self, author: str, content: str):
'Receive chat message from RabbitMQ'
await self.send_ws('append_chat', content=content)
async def on_ws_chat_input(self, content: str = ''):
'Handle chat input from browser'
await self.send_mq('chat',
author=self.name,
content=content
)
Protocol System
The framework uses a protocol-based architecture where each protocol handles specific types of communication:
ws: WebSocket communication with browsermq: RabbitMQ for peer-to-peer messaginggpt: OpenAI API integrationhttp: HTTP/HTTPS server- Custom protocols can be added by extending the base Protocol class
Message Formatting
Support for rich content in messages:
# Markdown with syntax highlighting
await self.send_ws('append_chat',
content='```python\nprint("Hello")\n```'
)
# Mermaid diagrams
await self.send_ws('append_chat',
content='```mermaid\ngraph TD;\nA-->B;\n```'
)
# Math equations
await self.send_ws('append_chat',
content=r'\\( \int x dx = \frac{x^2}{2} + C \\)'
)
Development Status
Currently in active development (March 2024). The framework is being used in production but the API may have breaking changes. See CHANGELOG for version history.
Requirements
- Python 3.11+
- RabbitMQ server
- Modern web browser
Contributing
Contributions are welcome! Please check our Contributing Guidelines for details.
License
Copyright (c) 2024 Ken Seehart, AGI Green. See LICENSE for details.
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 agi_green-0.2.8.tar.gz.
File metadata
- Download URL: agi_green-0.2.8.tar.gz
- Upload date:
- Size: 6.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
923ecfd1ce61badd789fac16ada4201984bef077e1dcb8c503582d4354481dd4
|
|
| MD5 |
5220476d8113861279624bf5f465508d
|
|
| BLAKE2b-256 |
ccdfe5295da8a04bd948fb180dc317037e18d0f755cfe57709be943ccf7a3dfa
|
File details
Details for the file agi.green-0.2.8-py3-none-any.whl.
File metadata
- Download URL: agi.green-0.2.8-py3-none-any.whl
- Upload date:
- Size: 6.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6dafc10765ed87a81bf432be427d3a1c8593c1e08e5c0ef8f941076e120c1da
|
|
| MD5 |
cda849862467aec8d1dcc91a0240a12f
|
|
| BLAKE2b-256 |
1176444be54d696f2c9e537dfffef1d985614d755651389d1854dd1ff9a7f44b
|