ocht


Nameocht JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryModulare Python-TUI zur Steuerung von LLMs via LangChain
upload_time2025-08-06 08:37:30
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords tui langchain llm cli
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # OChaT

[![PyPI version](https://img.shields.io/pypi/v/ocht.svg)](https://pypi.org/project/ocht/) [![Build Status](https://github.com/dein-username/OChaT/actions/workflows/ci.yml/badge.svg)](https://github.com/dein-username/OChaT/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

**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

1. **Clone the repository**

   ```bash
   git clone https://github.com/dein-username/OChaT.git
   cd OChaT
   ```

2. **Install dependencies**

   ```bash
   uv sync
   ```

3. **Install package in development mode**

   ```bash
   uv install -e .
   ```

> **Note:** By default, `uv sync` installs all dependencies from `pyproject.toml`, including:
>
> * `alembic>=1.15.2`
> * `click>=8.1.8`
> * `langchain>=0.3.26`
> * `langchain-ollama>=0.3.3`
> * `ollama>=0.4.8`
> * `rich>=14.0.0`
> * `sqlmodel>=0.0.24`
> * `textual>=3.2.0`

---

## โšก Quick Start

Launch the TUI application:

```bash
uv run ocht
```

Or use specific commands:

* **`uv run ocht init <workspace>`** - Create new workspace
* **`uv run ocht chat`** - Start interactive chat
* **`uv run ocht list-models`** - List available models
* **`uv run ocht sync-models`** - Sync model metadata
* **`uv run ocht config`** - Open configuration editor
* **`uv 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 |

<details>
<summary>Example Usage</summary>

```bash
# 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
```

</details>

---

## ๐Ÿ—๏ธ Architecture

### Core Components

**Database Layer (`core/`)**
- `models.py` - SQLModel entities: Workspace, Message, LLMProviderConfig, Model, Setting, PromptTemplate
- `db.py` - Database engine, session management, and initialization
- `migration.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 interface
- `ollama.py` - Ollama-specific implementation

**TUI Layer (`tui/`)**
- Textual-based user interface
- `app.py` - Main TUI application
- `screens/` - UI screens for model/provider management
- `widgets/` - Custom UI components (chat bubbles, etc.)
- `styles/` - TCSS styling files

## ๐Ÿ—‚๏ธ Project Structure

```text
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:

```bash
uv run pytest
```

---

## ๐Ÿค Contributing

Contributions are welcome!

1. **Fork** the repository
2. **Create feature branch**: 
   ```bash
   git checkout -b feature/my-feature
   ```
3. **Commit changes**:
   ```bash
   git commit -m "feat: description of my feature"
   ```
4. **Push to fork**:
   ```bash
   git push origin feature/my-feature
   ```
5. **Open Pull Request**

Please follow our coding guidelines and add tests for new features.

---

## ๐Ÿ“„ License

This project is licensed under the [MIT License](LICENSE).


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ocht",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "tui, langchain, llm, cli",
    "author": null,
    "author_email": "Roman Thimian <roman.thimian@me.com>",
    "download_url": "https://files.pythonhosted.org/packages/d2/c6/30180d8e0780b303c53278440191f3f73b89c89460d39cd19cd73ae23e9c/ocht-0.1.1.tar.gz",
    "platform": null,
    "description": "# OChaT\n\n[![PyPI version](https://img.shields.io/pypi/v/ocht.svg)](https://pypi.org/project/ocht/) [![Build Status](https://github.com/dein-username/OChaT/actions/workflows/ci.yml/badge.svg)](https://github.com/dein-username/OChaT/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n\n**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).\n\n---\n\n## \ud83d\udce6 Installation\n\n1. **Clone the repository**\n\n   ```bash\n   git clone https://github.com/dein-username/OChaT.git\n   cd OChaT\n   ```\n\n2. **Install dependencies**\n\n   ```bash\n   uv sync\n   ```\n\n3. **Install package in development mode**\n\n   ```bash\n   uv install -e .\n   ```\n\n> **Note:** By default, `uv sync` installs all dependencies from `pyproject.toml`, including:\n>\n> * `alembic>=1.15.2`\n> * `click>=8.1.8`\n> * `langchain>=0.3.26`\n> * `langchain-ollama>=0.3.3`\n> * `ollama>=0.4.8`\n> * `rich>=14.0.0`\n> * `sqlmodel>=0.0.24`\n> * `textual>=3.2.0`\n\n---\n\n## \u26a1 Quick Start\n\nLaunch the TUI application:\n\n```bash\nuv run ocht\n```\n\nOr use specific commands:\n\n* **`uv run ocht init <workspace>`** - Create new workspace\n* **`uv run ocht chat`** - Start interactive chat\n* **`uv run ocht list-models`** - List available models\n* **`uv run ocht sync-models`** - Sync model metadata\n* **`uv run ocht config`** - Open configuration editor\n* **`uv run ocht migrate <version>`** - Run database migrations\n\n### Available CLI Commands\n\n| Command | Description |\n|---------|-------------|\n| `init <name>` | Creates a new chat workspace with configuration file and history |\n| `chat` | Starts interactive chat session based on current workspace |\n| `config` | Opens configuration in default editor |\n| `export-config <file>` | Exports current settings as YAML or JSON file |\n| `import-config <file>` | Imports settings from YAML or JSON file |\n| `list-models` | Lists available LLM models via LangChain |\n| `sync-models` | Synchronizes model metadata from external providers |\n| `migrate <version>` | Runs Alembic migrations to specified target version |\n| `version` | Shows current CLI/package version |\n| `help [command]` | Shows detailed help for a command |\n\n<details>\n<summary>Example Usage</summary>\n\n```bash\n# Create new chat workspace\nuv run ocht init my-workspace\n\n# Start chat session\nuv run ocht chat\n\n# List available models\nuv run ocht list-models\n\n# Sync model metadata\nuv run ocht sync-models\n```\n\n</details>\n\n---\n\n## \ud83c\udfd7\ufe0f Architecture\n\n### Core Components\n\n**Database Layer (`core/`)**\n- `models.py` - SQLModel entities: Workspace, Message, LLMProviderConfig, Model, Setting, PromptTemplate\n- `db.py` - Database engine, session management, and initialization\n- `migration.py` - Alembic integration for schema migrations\n\n**Repository Layer (`repositories/`)**\n- CRUD operations for each entity\n- Direct database access abstraction\n- Files: `workspace.py`, `message.py`, `llm_provider_config.py`, `model.py`, `setting.py`, `prompt_template.py`\n\n**Service Layer (`services/`)**\n- Business logic and use cases\n- Orchestrates repositories and external APIs\n- Files: `workspace.py`, `chat.py`, `config.py`, `model_manager.py`, `provider_manager.py`, `prompt_manager.py`\n\n**Adapter Layer (`adapters/`)**\n- LangChain integration\n- `base.py` - Abstract LLMAdapter interface\n- `ollama.py` - Ollama-specific implementation\n\n**TUI Layer (`tui/`)**\n- Textual-based user interface\n- `app.py` - Main TUI application\n- `screens/` - UI screens for model/provider management\n- `widgets/` - Custom UI components (chat bubbles, etc.)\n- `styles/` - TCSS styling files\n\n## \ud83d\uddc2\ufe0f Project Structure\n\n```text\nOChaT/\n\u251c\u2500\u2500 .gitignore\n\u251c\u2500\u2500 LICENSE\n\u251c\u2500\u2500 pyproject.toml\n\u251c\u2500\u2500 README.md\n\u251c\u2500\u2500 CLAUDE.md              # Claude Code project instructions\n\u251c\u2500\u2500 alembic.ini            # Alembic configuration\n\u251c\u2500\u2500 migrations/            # Database migration files\n\u251c\u2500\u2500 docs/\n\u251c\u2500\u2500 tests/                 # Test files\n\u251c\u2500\u2500 src/\n\u2502   \u2514\u2500\u2500 ocht/\n\u2502       \u251c\u2500\u2500 __init__.py\n\u2502       \u251c\u2500\u2500 cli.py             # CLI entry point (Click commands)\n\u2502       \u251c\u2500\u2500 core/              # Database engine, sessions & models\n\u2502       \u2502   \u251c\u2500\u2500 db.py          # Engine & session factory\n\u2502       \u2502   \u251c\u2500\u2500 migration.py   # Alembic integration\n\u2502       \u2502   \u251c\u2500\u2500 models.py      # SQLModel entities\n\u2502       \u2502   \u2514\u2500\u2500 version.py     # Version management\n\u2502       \u251c\u2500\u2500 repositories/      # CRUD logic per entity\n\u2502       \u2502   \u251c\u2500\u2500 workspace.py\n\u2502       \u2502   \u251c\u2500\u2500 message.py\n\u2502       \u2502   \u251c\u2500\u2500 llm_provider_config.py\n\u2502       \u2502   \u251c\u2500\u2500 model.py\n\u2502       \u2502   \u251c\u2500\u2500 setting.py\n\u2502       \u2502   \u2514\u2500\u2500 prompt_template.py\n\u2502       \u251c\u2500\u2500 services/          # Business logic / use cases\n\u2502       \u2502   \u251c\u2500\u2500 workspace.py\n\u2502       \u2502   \u251c\u2500\u2500 chat.py\n\u2502       \u2502   \u251c\u2500\u2500 config.py\n\u2502       \u2502   \u251c\u2500\u2500 model_manager.py\n\u2502       \u2502   \u251c\u2500\u2500 provider_manager.py\n\u2502       \u2502   \u251c\u2500\u2500 prompt_manager.py\n\u2502       \u2502   \u251c\u2500\u2500 settings_manager.py\n\u2502       \u2502   \u2514\u2500\u2500 adapter_manager.py\n\u2502       \u251c\u2500\u2500 adapters/          # LangChain adapters\n\u2502       \u2502   \u251c\u2500\u2500 base.py        # Abstract adapter interface\n\u2502       \u2502   \u2514\u2500\u2500 ollama.py      # Ollama implementation\n\u2502       \u251c\u2500\u2500 tui/               # Text-based UI components\n\u2502       \u2502   \u251c\u2500\u2500 app.py         # Main TUI application\n\u2502       \u2502   \u251c\u2500\u2500 screens/       # UI screens\n\u2502       \u2502   \u251c\u2500\u2500 widgets/       # Custom widgets\n\u2502       \u2502   \u2514\u2500\u2500 styles/        # TCSS styling\n\u2502       \u2514\u2500\u2500 data/              # SQLite database\n\u2514\u2500\u2500 uv.lock\n```\n\n---\n\n## \ud83e\uddea Testing\n\nRun tests using pytest:\n\n```bash\nuv run pytest\n```\n\n---\n\n## \ud83e\udd1d Contributing\n\nContributions are welcome!\n\n1. **Fork** the repository\n2. **Create feature branch**: \n   ```bash\n   git checkout -b feature/my-feature\n   ```\n3. **Commit changes**:\n   ```bash\n   git commit -m \"feat: description of my feature\"\n   ```\n4. **Push to fork**:\n   ```bash\n   git push origin feature/my-feature\n   ```\n5. **Open Pull Request**\n\nPlease follow our coding guidelines and add tests for new features.\n\n---\n\n## \ud83d\udcc4 License\n\nThis project is licensed under the [MIT License](LICENSE).\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Modulare Python-TUI zur Steuerung von LLMs via LangChain",
    "version": "0.1.1",
    "project_urls": null,
    "split_keywords": [
        "tui",
        " langchain",
        " llm",
        " cli"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b60727ef529f7b2df051f5a207654ab9828ba2dd101e4a2d881636ec4c912182",
                "md5": "3c24275c45cada43f0c5faf3468bf2af",
                "sha256": "5b58f1f5cbec82141d2e2f2882393753502ef7502ceb94840026b4521494050a"
            },
            "downloads": -1,
            "filename": "ocht-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3c24275c45cada43f0c5faf3468bf2af",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 57476,
            "upload_time": "2025-08-06T08:37:29",
            "upload_time_iso_8601": "2025-08-06T08:37:29.080516Z",
            "url": "https://files.pythonhosted.org/packages/b6/07/27ef529f7b2df051f5a207654ab9828ba2dd101e4a2d881636ec4c912182/ocht-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d2c630180d8e0780b303c53278440191f3f73b89c89460d39cd19cd73ae23e9c",
                "md5": "1fb06543044e484784be53d9a59b1c38",
                "sha256": "f9ffd6ad6de22dbcca6fa2f89a51aa5136d57d54998ad0780de9c179e4fe78e2"
            },
            "downloads": -1,
            "filename": "ocht-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "1fb06543044e484784be53d9a59b1c38",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 40497,
            "upload_time": "2025-08-06T08:37:30",
            "upload_time_iso_8601": "2025-08-06T08:37:30.008245Z",
            "url": "https://files.pythonhosted.org/packages/d2/c6/30180d8e0780b303c53278440191f3f73b89c89460d39cd19cd73ae23e9c/ocht-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-06 08:37:30",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "ocht"
}
        
Elapsed time: 2.01256s