Skip to main content

TUI AI chat tool for local LLM development

Project description

TinyChat

轻量级终端 AI 聊天应用,支持多后端供应商,中英文双语界面。

特性

多后端支持

  • Ollama - 本地 Ollama 服务器
  • OpenAI 兼容 - 支持 OpenAI 兼容的 API 服务

现代化终端界面

  • 基于 Textual 框架
  • 丰富的 Markdown 渲染和代码高亮
  • 响应式布局,自适应终端尺寸
  • 原生鼠标支持(点击、滚动)
  • 多主题支持(明/暗主题)

国际化

  • 中文/英文双语界面
  • 一键切换语言

会话管理

  • 自动保存聊天历史
  • 支持多会话切换
  • 自动生成会话标题
  • 流式响应实时显示

跨平台

  • 支持 Windows、macOS、Linux
  • 跨平台剪贴板支持

安装

系统要求

  • Python 3.14+
  • pip 或 uv 包管理器

从 PyPI 安装

pip install tinychat

从源码安装

git clone <repository-url>
cd tinychat

# 使用 pip
pip install -e ".[dev]"

# 或使用 uv
uv sync --extra dev

使用

启动应用

tinychat

或直接运行模块:

python -m tinychat

基本操作

  1. 选择后端 - 在左侧边栏点击后端名称
  2. 选择模型 - 在边栏点击模型名称
  3. 发送消息 - 输入内容后按 Enter
  4. 换行 - 按 Ctrl+Enter 插入换行
  5. 滚动历史 - 使用鼠标滚轮或方向键

快捷键

按键 功能
Enter 发送消息
Ctrl+Enter 输入换行
Ctrl+L 切换语言
Ctrl+T 切换主题
Ctrl+Q 退出应用
Ctrl+P 命令面板

配置

配置文件位于 ~/.config/tinychat/config.toml

[settings]
locale = "zh"  # 语言设置: "en" 或 "zh"

[[backends]]
name = "ollama"
type = "ollama"
endpoint = "http://localhost:11434"
default_model = "llama3.2"

[[backends]]
name = "openai"
type = "openai"
endpoint = "https://api.openai.com/v1"
api_key = "your-api-key"
default_model = "gpt-4o"

开发

项目结构

tinychat/
├── src/tinychat/
│   ├── __main__.py           # 入口
│   ├── app_textual.py        # 主应用
│   ├── backends/             # 后端实现
│   │   ├── base.py          # 抽象基类
│   │   ├── ollama.py        # Ollama 后端
│   │   └── openai.py        # OpenAI 后端
│   ├── components/           # UI 组件
│   │   ├── chat_view_textual.py
│   │   ├── input_area_textual.py
│   │   ├── sidebar_textual.py
│   │   └── status_bar_textual.py
│   ├── models/               # 数据模型
│   ├── utils/                # 工具函数
│   │   ├── event_bus.py     # 事件系统
│   │   ├── i18n.py          # 国际化
│   │   └── theme_manager.py # 主题管理
│   └── locales/              # 翻译文件
│       ├── en/LC_MESSAGES/
│       └── zh/LC_MESSAGES/
└── tests/                    # 测试

运行测试

# 运行所有测试
pytest tests/ -v

# 带覆盖率报告
pytest tests/ --cov=src/tinychat --cov-report=html

# 运行单个测试
pytest tests/unit/test_app_textual.py -v

代码检查

ruff check src/ tests/
ruff format src/ tests/

打包发布

# 安装构建工具
pip install build

# 构建
python -m build

# 生成的文件在 dist/ 目录

致谢

许可证

MIT License

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

tinychat_ai-0.1.0.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tinychat_ai-0.1.0-py3-none-any.whl (32.6 kB view details)

Uploaded Python 3

File details

Details for the file tinychat_ai-0.1.0.tar.gz.

File metadata

  • Download URL: tinychat_ai-0.1.0.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for tinychat_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e62b45e223e296b41ed85fbe7f59a727b92a50ab7147ca48ce24dc321a62c6e5
MD5 0e0c5328e0bf1e9b6633a15d4ce15daa
BLAKE2b-256 3ba24c971a682e2305827e368a95d277c191f9099ab8bc1ff0369bc7517f0296

See more details on using hashes here.

File details

Details for the file tinychat_ai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tinychat_ai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 32.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for tinychat_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b30be824c8118d6b58084ed161f513cb177e9f7b2c2ff3843e4eae589da12eb6
MD5 edcab63fc765c757a6c34afe98f3bf54
BLAKE2b-256 675b6cb01ca42424e81aaae09f4c829ea700b93e448c24089a7daec1d1d6a459

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page