Metadata-Version: 2.4
Name: parishad
Version: 0.1.3
Summary: A cost-aware, local-first council of heterogeneous LLMs for reliable reasoning, coding, and factual correctness
Project-URL: Homepage, https://github.com/parishad-council/parishad
Project-URL: Documentation, https://github.com/parishad-council/parishad#readme
Project-URL: Repository, https://github.com/parishad-council/parishad
Project-URL: Issues, https://github.com/parishad-council/parishad/issues
Author: Parishad Team
License-Expression: MIT
License-File: LICENSE
Keywords: code-generation,council,llm,local-llm,multi-agent,reasoning
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: click>=8.0.0
Requires-Dist: httpx>=0.25.0
Requires-Dist: jsonschema>=4.0.0
Requires-Dist: llama-cpp-python>=0.2.0
Requires-Dist: numpy<2.0
Requires-Dist: openai>=1.0.0
Requires-Dist: psutil>=5.9.0
Requires-Dist: pydantic-settings>=2.0.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: rich>=13.0.0
Requires-Dist: textual>=0.70.0
Requires-Dist: tiktoken>=0.5.0
Provides-Extra: all
Requires-Dist: accelerate>=0.25.0; extra == 'all'
Requires-Dist: black>=23.0.0; extra == 'all'
Requires-Dist: chromadb>=0.5.0; extra == 'all'
Requires-Dist: datasets>=2.14.0; extra == 'all'
Requires-Dist: faiss-cpu>=1.7.0; extra == 'all'
Requires-Dist: mypy>=1.0.0; extra == 'all'
Requires-Dist: pandas>=2.0.0; extra == 'all'
Requires-Dist: pre-commit>=3.0.0; extra == 'all'
Requires-Dist: pypdf>=3.0.0; extra == 'all'
Requires-Dist: ruff>=0.1.0; extra == 'all'
Requires-Dist: sentence-transformers>=2.2.0; extra == 'all'
Requires-Dist: torch>=2.0.0; extra == 'all'
Requires-Dist: tqdm>=4.66.0; extra == 'all'
Requires-Dist: transformers>=4.35.0; extra == 'all'
Provides-Extra: benchmark
Requires-Dist: datasets>=2.14.0; extra == 'benchmark'
Requires-Dist: pandas>=2.0.0; extra == 'benchmark'
Requires-Dist: tqdm>=4.66.0; extra == 'benchmark'
Provides-Extra: cuda
Requires-Dist: accelerate>=0.25.0; extra == 'cuda'
Requires-Dist: auto-gptq>=0.6.0; extra == 'cuda'
Requires-Dist: autoawq>=0.1.0; extra == 'cuda'
Requires-Dist: bitsandbytes>=0.41.0; extra == 'cuda'
Requires-Dist: optimum>=1.16.0; extra == 'cuda'
Requires-Dist: protobuf>=4.0.0; extra == 'cuda'
Requires-Dist: torch>=2.0.0; extra == 'cuda'
Requires-Dist: transformers>=4.35.0; extra == 'cuda'
Provides-Extra: dev
Requires-Dist: black>=23.0.0; extra == 'dev'
Requires-Dist: mypy>=1.0.0; extra == 'dev'
Requires-Dist: pre-commit>=3.0.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Provides-Extra: distributed
Requires-Dist: grpcio-tools>=1.50.0; extra == 'distributed'
Requires-Dist: grpcio>=1.50.0; extra == 'distributed'
Provides-Extra: local
Requires-Dist: accelerate>=0.25.0; extra == 'local'
Requires-Dist: torch>=2.0.0; extra == 'local'
Requires-Dist: transformers>=4.35.0; extra == 'local'
Provides-Extra: mlx
Requires-Dist: mlx-lm>=0.1.0; extra == 'mlx'
Provides-Extra: perception
Requires-Dist: markitdown>=0.0.1; extra == 'perception'
Provides-Extra: retrieval
Requires-Dist: chromadb>=0.5.0; extra == 'retrieval'
Requires-Dist: faiss-cpu>=1.7.0; extra == 'retrieval'
Requires-Dist: pypdf>=3.0.0; extra == 'retrieval'
Requires-Dist: sentence-transformers>=2.2.0; extra == 'retrieval'
Description-Content-Type: text/markdown

<div align="center">

![Parishad Gradient Logo](docs/assets/logo.svg)

**A cost-aware, local-first council of heterogeneous LLMs for reliable reasoning, coding, and factual correctness.**

[![PyPI Version](https://img.shields.io/pypi/v/parishad?style=flat-square&color=orange)](https://pypi.org/project/parishad/)
[![Python Version](https://img.shields.io/pypi/pyversions/parishad?style=flat-square&color=blue)](https://pypi.org/project/parishad/)
[![License](https://img.shields.io/github/license/parishad-council/parishad?style=flat-square)](LICENSE)
[![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square)](https://github.com/psf/black)
[![Type Checked](https://img.shields.io/badge/mypy-checked-blue.svg?style=flat-square)](http://mypy-lang.org/)

</div>

---

## 📖 Overview

**Parishad** (Hindi: *Council*) orchestrates multiple local language models into a structured reasoning pipeline. Instead of relying on a single massive model, Parishad coordinates specialized, smaller models (2B-34B parameters) into functional roles based on traditional Indian administrative titles.

This approach achieves **higher reliability** and **lower latency** on consumer hardware (Mac Silicon, NVIDIA GPUs) by assigning tasks to the most appropriate model slot (Small/Medium/Big) tailored to your compute budget.

## ✨ Key Features

- **🏛️ Heterogeneous Model Council**: Seamlessly orchestrate varying model sizes (e.g., Phi-3 for syntax, Llama-3 for reasoning, Mixtral for judgment).
- **🖥️ Beautiful TUI Dashboard**: Real-time interactive terminal interface with visual role tracking, progress bars, and emoji indicators.
- **👁️ Vision Capabilities**: Integrated `PerceptionTool` allows the council to "see" and analyze images via local VLMs.
- **💰 Cost-Aware Execution**: Define token budgets per query; the council adapts its strategy to stay within limits.
- **🛡️ Structured Verification**: The `Prerak` (Checker) role actively challenges hallucinations using deterministic tools and cross-examination.
- **🔌 Local-First Backends**: Native support for **Ollama**, **Llama.cpp**, **MLX**, and **Transformers**.

## 🏛️ The Three Sabhas (Council Configurations)

Parishad offers three distinct council sizes to balance speed, cost, and depth:

### 1. Laghu Sabha (Fast Council)
*   **Roles**: 5 (Darbari, Majumdar, Sainik, Prerak, Raja)
*   **Use Case**: Quick queries, simple code generation, factual checks.
*   **Models**: Optimized for Small/Mid models.

### 2. Madhya Sabha (Core Council)
*   **Roles**: 8 (Adds **Sar Senapati** [Coordinator], **Sacheev** [Secretary], **Dandadhyaksha** [Magistrate])
*   **Use Case**: Balanced reasoning for standard development tasks.
*   **Models**: Uses Mid/Big models for deeper analysis.

### 3. Maha Sabha (Extended Council)
*   **Roles**: 10 (Adds **Pantapradhan** [Prime Minister], **Vidushak** [Lateral Thinker])
*   **Use Case**: Complex system design, creative problem solving, and strategic planning.
*   **Models**: Full spectrum orchestration (Small + Mid + Big).

## 🏗️ Architecture

Parishad organizes models into a directed graph of roles:

```text
┌───────────┐      ┌───────────┐      ┌───────────┐
│  DARBARI  │ ──►  │ MAJUMDAR  │ ──►  │  SAINIK   │
│ (Refiner) │      │ (Planner) │      │ (Worker)  │
└───────────┘      └───────────┘      └───────────┘
                                            │
                                            ▼
┌───────────┐      ┌───────────┐      ┌───────────┐
│   RAJA    │ ◄──  │  PRERAK   │ ◄──  │ SYSTEM &  │
│  (Judge)  │      │ (Checker) │      │   TOOLS   │
└───────────┘      └───────────┘      └───────────┘
```

- **Darbari**: Normalizes vague user queries into structured task specifications.
- **Majumdar**: Decomposes complex tasks into stepwise execution plans.
- **Sainik**: Executes steps, writing code or generating content using tools.
- **Prerak**: Validates output against facts, schema, or safety policies.
- **Raja**: Synthesizes the final answer and assigns a confidence score.

## 📦 Installation

### Standard Install
```bash
pip install parishad
```

### Optimized Install Options
Choose the backend that matches your hardware:

```bash
# Apple Silicon (M1/M2/M3) - Recommended
pip install "parishad[mlx]"

# NVIDIA GPU / Local Parsing
pip install "parishad[local,cuda]"

# With Retrieval (RAG) capabilities
pip install "parishad[retrieval]"

# For Developers (Linting, Testing)
pip install "parishad[dev]"
```

## 🚀 Quick Start

### 1. Launch & Setup
Run the main command to initialize the council. This automatically handles permissions, scans for models (Ollama/HF), and launches the TUI.

```bash
parishad
```

**Pro Tip:** Use `/sabha` to switch between council sizes (e.g., `laghu` for speed, `maha` for deep reasoning) and `/scan` to find new local models.

### 2. CLI Direct Execution
Run a specific task without entering the interactive shell.

```bash
parishad run --sabha madhyam "Analyze the 'data.csv' file and plot trends"
```

### 3. Python API
Integrate Parishad into your own applications.

```python
from parishad import Parishad

# Initialize the council
council = Parishad(config="core")

# Execute a complex query
result = council.run("Design a scalable REST API architecture for a bookstore.")

print(f"Final Answer: {result.final_answer}")
print(f"Confidence: {result.confidence_score}/10")
# Full execution trace available in result.trace
```

## 🎮 Interactive Features

Unlock the full power of the council with these TUI capabilities:

### ⚡ Slash Commands
Control the session without leaving the chat interface:
- **`/sabha [mode]`**: Switch council configuration instantly (e.g., `/sabha laghu` for speed, `/sabha maha` for power).
- **`/scan`**: Re-scan your system for newly downloaded models.
- **`/roles`**: View currently active roles, their models, and slot assignments.
- **`/history`**: View past queries and load previous traces.
- **`/clear`**: Reset the conversation context.

### 📎 Context Awareness (@ Mentions)
Parishad allows you to "chat with your files". Directly reference local files in your query:
- **`@path/to/file.py`**: Reads the file and adds it to the context.
- **`@src/`**: Scans the directory structure.

Example:
> *"Analyze @src/main.py and refactor the ErrorHandler class."*


## 🤝 Contributing

Contributions are welcome! Please follow these steps:

1.  Fork the repository.
2.  Install dev dependencies: `pip install -e ".[dev]"`
3.  Ensure code style compliance: `black . && ruff check .`
4.  Submit a Pull Request.

## 📄 License

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

---

<div align="center">
  <sub>Built with ❤️ by <a href="https://github.com/ommo007">Om Mohite</a> & <a href="https://github.com/Ashiiish-88">Ashish Prajapati</a>. Trusted by developers for local agentic workflows.</sub>
</div>
