Modulare Python-TUI zur Steuerung von LLMs via LangChain
Project description
OChaT
OChaT is a modular Python TUI application that orchestrates Large Language Models (LLMs) via LangChain. It supports both local models (Ollama) and cloud providers (ChatGPT, Claude, Grok).
๐ฆ Installation
-
Clone the repository
git clone https://github.com/dein-username/OChaT.git cd OChaT
-
Install dependencies
uv sync -
Install package in development mode
uv install -e .
Note: By default,
uv syncinstalls all dependencies frompyproject.toml, including:
alembic>=1.15.2click>=8.1.8langchain>=0.3.26langchain-ollama>=0.3.3ollama>=0.4.8rich>=14.0.0sqlmodel>=0.0.24textual>=3.2.0
โก Quick Start
Launch the TUI application:
uv run ocht
Or use specific commands:
uv run ocht init <workspace>- Create new workspaceuv run ocht chat- Start interactive chatuv run ocht list-models- List available modelsuv run ocht sync-models- Sync model metadatauv run ocht config- Open configuration editoruv run ocht migrate <version>- Run database migrations
Available CLI Commands
| Command | Description |
|---|---|
init <name> |
Creates a new chat workspace with configuration file and history |
chat |
Starts interactive chat session based on current workspace |
config |
Opens configuration in default editor |
export-config <file> |
Exports current settings as YAML or JSON file |
import-config <file> |
Imports settings from YAML or JSON file |
list-models |
Lists available LLM models via LangChain |
sync-models |
Synchronizes model metadata from external providers |
migrate <version> |
Runs Alembic migrations to specified target version |
version |
Shows current CLI/package version |
help [command] |
Shows detailed help for a command |
Example Usage
# Create new chat workspace
uv run ocht init my-workspace
# Start chat session
uv run ocht chat
# List available models
uv run ocht list-models
# Sync model metadata
uv run ocht sync-models
๐๏ธ Architecture
Core Components
Database Layer (core/)
models.py- SQLModel entities: Workspace, Message, LLMProviderConfig, Model, Setting, PromptTemplatedb.py- Database engine, session management, and initializationmigration.py- Alembic integration for schema migrations
Repository Layer (repositories/)
- CRUD operations for each entity
- Direct database access abstraction
- Files:
workspace.py,message.py,llm_provider_config.py,model.py,setting.py,prompt_template.py
Service Layer (services/)
- Business logic and use cases
- Orchestrates repositories and external APIs
- Files:
workspace.py,chat.py,config.py,model_manager.py,provider_manager.py,prompt_manager.py
Adapter Layer (adapters/)
- LangChain integration
base.py- Abstract LLMAdapter interfaceollama.py- Ollama-specific implementation
TUI Layer (tui/)
- Textual-based user interface
app.py- Main TUI applicationscreens/- UI screens for model/provider managementwidgets/- Custom UI components (chat bubbles, etc.)styles/- TCSS styling files
๐๏ธ Project Structure
OChaT/
โโโ .gitignore
โโโ LICENSE
โโโ pyproject.toml
โโโ README.md
โโโ CLAUDE.md # Claude Code project instructions
โโโ alembic.ini # Alembic configuration
โโโ migrations/ # Database migration files
โโโ docs/
โโโ tests/ # Test files
โโโ src/
โ โโโ ocht/
โ โโโ __init__.py
โ โโโ cli.py # CLI entry point (Click commands)
โ โโโ core/ # Database engine, sessions & models
โ โ โโโ db.py # Engine & session factory
โ โ โโโ migration.py # Alembic integration
โ โ โโโ models.py # SQLModel entities
โ โ โโโ version.py # Version management
โ โโโ repositories/ # CRUD logic per entity
โ โ โโโ workspace.py
โ โ โโโ message.py
โ โ โโโ llm_provider_config.py
โ โ โโโ model.py
โ โ โโโ setting.py
โ โ โโโ prompt_template.py
โ โโโ services/ # Business logic / use cases
โ โ โโโ workspace.py
โ โ โโโ chat.py
โ โ โโโ config.py
โ โ โโโ model_manager.py
โ โ โโโ provider_manager.py
โ โ โโโ prompt_manager.py
โ โ โโโ settings_manager.py
โ โ โโโ adapter_manager.py
โ โโโ adapters/ # LangChain adapters
โ โ โโโ base.py # Abstract adapter interface
โ โ โโโ ollama.py # Ollama implementation
โ โโโ tui/ # Text-based UI components
โ โ โโโ app.py # Main TUI application
โ โ โโโ screens/ # UI screens
โ โ โโโ widgets/ # Custom widgets
โ โ โโโ styles/ # TCSS styling
โ โโโ data/ # SQLite database
โโโ uv.lock
๐งช Testing
Run tests using pytest:
uv run pytest
๐ค Contributing
Contributions are welcome!
- Fork the repository
- Create feature branch:
git checkout -b feature/my-feature
- Commit changes:
git commit -m "feat: description of my feature"
- Push to fork:
git push origin feature/my-feature
- Open Pull Request
Please follow our coding guidelines and add tests for new features.
๐ License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
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 ocht-0.1.1.tar.gz.
File metadata
- Download URL: ocht-0.1.1.tar.gz
- Upload date:
- Size: 40.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9ffd6ad6de22dbcca6fa2f89a51aa5136d57d54998ad0780de9c179e4fe78e2
|
|
| MD5 |
1fb06543044e484784be53d9a59b1c38
|
|
| BLAKE2b-256 |
d2c630180d8e0780b303c53278440191f3f73b89c89460d39cd19cd73ae23e9c
|
File details
Details for the file ocht-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ocht-0.1.1-py3-none-any.whl
- Upload date:
- Size: 57.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b58f1f5cbec82141d2e2f2882393753502ef7502ceb94840026b4521494050a
|
|
| MD5 |
3c24275c45cada43f0c5faf3468bf2af
|
|
| BLAKE2b-256 |
b60727ef529f7b2df051f5a207654ab9828ba2dd101e4a2d881636ec4c912182
|