AGI.green Framework
Project description
agi.green
A user interface platform for python AI chat applications browser chat interface featuring markdown content and a unified messaging framework.
A high level python package controls all of the business logic, including a unified message model and asynchronous interaction with the chat ui.
Please note: This is in somewhat early development (October 2003). The framework should be considered unstable for a few weeks.
Previous git submodule and template approach was abandoned. Instead the preferred strategy is to install the agi.green repo with pip.
Dependencies:
- rabbitmq: https://www.rabbitmq.com/download.html
Components:
websockets
: Communicate with browser uiaio_pika
: Communicate viaAMQP
with other docker containersmarkdown
: Messages are rendered as markdown (and plugins such as mermaid and mathjax)
Example chat room:
This implements a peer to peer chat node. It runs inside a docker container, and broadcasts to all peers on the same docker network.
It doesn't get simpler than this. Dispatcher
hides all the details.
A similar Dispatcher could implement an interface to OpenAI or other model, or various agents and API command handlers.
class ChatNode(Dispatcher):
'''
Manages the connection to RabbitMQ and WebSocket connection to browser.
handler methods are named on_<protocol>_<cmd> where protocol is mq or ws
mq = RabbitMQ
ws = WebSocket
'''
async def on_mq_chat(self, author:str, content:str):
'receive chat message from RabbitMQ - append to chat dialog in browser ui'
await self.send_ws('append_chat', content=content)
async def on_ws_chat_input(self, content:str=''):
'receive chat input from browser via websocket - broadcast to peers (including self)'
await self.send_mq('chat', author=f'{self.name}', content=content)
Note that on_mq_chat
and on_ws_chat_input
are not predefined overloaded methods. You can add any methods you like named on_{protocol}_{command}
with arbitrary named arguments, and these handler methods will autoregister. Send messages with send_{protocol}(command, **kwargs)
with corresponding arguments. The function signature defines the message schema. Predefined protocols are ws
(socket connection to browser ui) and mq
(amqp broadcast to peers, including echo to self). Protocol gpt
coming soon. The framework provides for the definition of new protocols.
Extensible Unified Protocol framework:
Each protocol is a class that defines how to connect and send and receive messages.
- Configurable exception handling: By default, errors while handling messages are caught and logged so the program can continue running.
However, sometimes you want the exception to be unhandled, such as when debugging. You can disable exception handling with
exception=None
in the constructor of the protocol or the dispatcher.
Intended applications for this framework:
- fish: fantastic imap sorting hat (conversational email sorting)
- yara: yet another research assistant (interactively build an up to date expert on any topic)
- various experiments in layered language models
Copyright (c) 2023 Ken Seehart, AGI Green
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
Built Distribution
File details
Details for the file agi_green-0.2.2.tar.gz
.
File metadata
- Download URL: agi_green-0.2.2.tar.gz
- Upload date:
- Size: 6.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ec42173c747ee4106a62e2a57a5301643e596e08e615f6f8a9914d339575e17 |
|
MD5 | e24c6de66ac479e47fd53751667abee3 |
|
BLAKE2b-256 | eec9693e13e4f2bcc396acab64eb649b9d13aba3aa119d35c828c8db87efbfb8 |
File details
Details for the file agi.green-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: agi.green-0.2.2-py3-none-any.whl
- Upload date:
- Size: 6.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69c18db2964ac95ea16b2d9e93ca6783d319935665fda02a12543103bd3cd399 |
|
MD5 | e09d3943249aae301c3a2ff1a4fb746b |
|
BLAKE2b-256 | febdbf2e5466f1962cd539ac6a1c4692fcba16f9a121534f4461a34b59f54f7b |