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.1.tar.gz
.
File metadata
- Download URL: agi_green-0.2.1.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 | 69c3c7697cb0b7027bdccf1adc9af6c5d05b6c2cffb617bc87a1a13c6bea850b |
|
MD5 | 8f1585af4bc660a03c20839a80a54d41 |
|
BLAKE2b-256 | 93974a2b2aaf53aba8ce332d291d7f03f65f5acb39cd5f4e4d383548336509e8 |
File details
Details for the file agi.green-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: agi.green-0.2.1-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 | f31770100bfddac5b5bcc36e614cb7a517ad4638a9c713c61982e7d1303c3087 |
|
MD5 | 3b2e55e7affc62fde49e3105b7169a7e |
|
BLAKE2b-256 | 980b2e87bb748659d27679725545d76db8195cbd82b353d6caf5bbb39fb7c203 |