motosan-chat (Python)
motosan-chat is a Python chatbot framework with a unified event model, channel adapters, and an LLM agent loop with tool-calling support.
This package mirrors the Rust-side architecture and provides a Python-first developer experience for building multi-platform chatbots.
Features
- Core runtime:
Bot,Thread,IncomingEvent, andChannelprotocol - Agent runtime:
AgentLoop,LlmClient, message/tool-call chain model - Tool system:
ToolDef,ToolResult,ToolContext,@tooldecorator - Channels:
- Web (
FastAPI+ SSE) - Telegram (polling adapter)
- LINE (webhook adapter)
- Discord (gateway adapter)
- Web (
- AI adapter:
MotosanAiClientformotosan-ai
Installation
pip install motosan-chat
Optional extras:
pip install "motosan-chat[web]"
pip install "motosan-chat[telegram]"
pip install "motosan-chat[line]"
pip install "motosan-chat[discord]"
pip install "motosan-chat[ai]"
pip install "motosan-chat[full]"
Quick Start
from motosan_chat import Bot
from motosan_chat.channels import WebChannel
async def handler(thread):
await thread.send(f"echo: {thread.event.content}")
channel = WebChannel()
bot = Bot.builder().channel(channel).handler(handler).build()
await bot.run()
Agent + Tools
from motosan_chat import AgentLoop, Message, ToolContext, ToolResult, tool
@tool(
name="get_weather",
description="Get weather by city",
schema={"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]},
)
async def get_weather(args: dict, ctx: ToolContext) -> ToolResult:
return ToolResult.text(f"Sunny in {args['city']}")
loop_ = AgentLoop(tools=[get_weather])
# result = await loop_.run(llm_client, thread, [Message.user("weather in Tokyo?")])
Development
uv sync --extra full --extra dev
uv run ruff check motosan_chat/ tests/
uv run pytest tests/ -v
Publishing
Build and verify package locally:
uv build
uv publish --dry-run
GitHub Actions publish workflow is triggered by tags that match python-v*.
Metadata
Release files for motosan-chat 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| motosan_chat-0.4.1.tar.gz | 22.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| motosan_chat-0.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.0 kB
Release files / motosan_chat-0.4.1.tar.gz
| Download URL | motosan_chat-0.4.1.tar.gz |
|---|---|
| Size | 22.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
443533990373d66fbbd42c64923d0395a056372101736ac5ce7e9080b5f0c140
|
|
BLAKE2b-256 checksum How to use checksums |
7b53340c70497e450849f2c765227ceadbf7aecf3a566f7889636ca4ba5627f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / motosan_chat-0.4.1-py3-none-any.whl
| Download URL | motosan_chat-0.4.1-py3-none-any.whl |
|---|---|
| Size | 16.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7e4486924dc5af802d67ed5e78eef96e0b4f30a53144598c82cd8f30ee3a90c3
|
|
BLAKE2b-256 checksum How to use checksums |
28e4a75cfe0a15c99ae10d33b091fab40f91ee23cbefdf5e65f011ec7344f423
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for motosan-chat 0.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.