Python chatbot framework with multi-platform channels and LLM agent loop
Project description
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*.
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
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 motosan_chat-0.2.1.tar.gz.
File metadata
- Download URL: motosan_chat-0.2.1.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0557a2284cddb5bde68f03de834e6419dbfe4f07264b94f26f46aa1da568fa8
|
|
| MD5 |
2e9e60cfd31fab6b746df0215499b618
|
|
| BLAKE2b-256 |
5f7ad973929a0b61e3d39db3c20e3871156187d864f3448a4e00430b8cd12f41
|
File details
Details for the file motosan_chat-0.2.1-py3-none-any.whl.
File metadata
- Download URL: motosan_chat-0.2.1-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b4b8bd436d651c6700c224ff1eb4f7e9fa1614eb00cabd0902128effd9c11ac
|
|
| MD5 |
0a0a04dcce1e72b442b2ef475f46de5d
|
|
| BLAKE2b-256 |
3b00fee9219294c560b7d091dc3ce16b78af26f570123b44e8216766fd62a4af
|