docpilot-cli 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ASWIN ASHOK
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,160 @@
1
+ Metadata-Version: 2.4
2
+ Name: docpilot-cli
3
+ Version: 1.0.0
4
+ Summary: A local-first RAG pipeline CLI tool
5
+ Requires-Python: >=3.12
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Requires-Dist: bs4>=0.0.2
9
+ Requires-Dist: beautifulsoup4>=4.12.0
10
+ Requires-Dist: langchain>=0.2.0
11
+ Requires-Dist: langchain-chroma>=0.1.0
12
+ Requires-Dist: langchain-ollama>=0.1.0
13
+ Requires-Dist: ollama>=0.2.0
14
+ Requires-Dist: pandas>=2.0.0
15
+ Requires-Dist: typer>=0.12.0
16
+ Requires-Dist: httpx>=0.27.0
17
+ Requires-Dist: tomli-w>=1.0.0
18
+ Requires-Dist: pypdf>=5.0.0
19
+ Requires-Dist: pyfiglet>=0.8.0
20
+ Requires-Dist: rich>=13.0.0
21
+ Dynamic: license-file
22
+
23
+ # ๐Ÿš€ DocPilot CLI
24
+
25
+ ![PyPI - Version](https://img.shields.io/pypi/v/docpilot-cli?color=blue&style=flat-square)
26
+ ![Python Version](https://img.shields.io/badge/python-3.12%2B-blue?style=flat-square)
27
+ ![License](https://img.shields.io/badge/license-MIT-green?style=flat-square)
28
+
29
+ **DocPilot** is a lightning-fast, local-first CLI for document ingestion and interactive question-answering. Powered by [Ollama](https://ollama.com/) and Chroma, it allows you to ingest websites, PDFs, and CSVs directly from your terminal and chat with your documentsโ€”keeping 100% of your data safely on your own machine.
30
+
31
+ Itโ€™s built for practical developer workflows: crawl sites concurrently, prepare chunks with multi-threading, and iterate rapidly without ever paying for a cloud API.
32
+
33
+ ---
34
+
35
+ ## โœจ Features
36
+
37
+ - **๐Ÿ”’ 100% Local**: No data ever leaves your machine. Powered by Ollama.
38
+ - **โšก Interactive Setup Wizard**: Get up and running instantly with smart model auto-detection.
39
+ - **๐ŸŒ Universal Ingestion**: Seamlessly ingest Website URLs, XML Sitemaps, PDFs, and CSVs.
40
+ - **๐Ÿš€ Concurrent Processing**: Lightning-fast crawling and multi-threaded document chunking.
41
+ - **๐ŸŽ›๏ธ Performance Profiles**: Switch between `fast`, `balanced`, and `quality` inference speeds on the fly.
42
+ - **๐ŸŽจ Beautiful Terminal UI**: Rich markdown rendering, ASCII art, and intuitive progress bars.
43
+
44
+ ---
45
+
46
+ ## ๐Ÿ“ฆ Installation
47
+
48
+ DocPilot is available on PyPI! You can install it globally using `pip`, `uv`, or `pipx`.
49
+
50
+ ```bash
51
+ # Recommended: Install using uv or pipx
52
+ uv tool install docpilot-cli
53
+
54
+ # Or via standard pip
55
+ pip install docpilot-cli
56
+
57
+ # Optional: Add PDF parsing support
58
+ pip install "docpilot-cli[pdf]"
59
+ ```
60
+
61
+ ### Prerequisites
62
+ 1. **Python 3.12+**
63
+ 2. **[Ollama](https://ollama.com/)**: Installed and running in the background.
64
+ 3. Pull your preferred models:
65
+ ```bash
66
+ ollama pull qwen2.5:latest
67
+ ollama pull mxbai-embed-large:335m
68
+ ```
69
+
70
+ ---
71
+
72
+ ## ๐Ÿ› ๏ธ Quick Start
73
+
74
+ The very first time you run a DocPilot command, it will launch the **Interactive Setup Wizard** to help you configure your chat and embedding models.
75
+
76
+ ### 1. Ingest Knowledge
77
+ Point DocPilot to any documentation site, sitemap, PDF, or CSV:
78
+
79
+ ```bash
80
+ # Crawl a website
81
+ docpilot ingest "https://docs.python.org/3/" --max-pages 100 --workers 16
82
+
83
+ # Ingest a local PDF
84
+ docpilot ingest "./docs/engineering_handbook.pdf"
85
+
86
+ # Ingest a CSV
87
+ docpilot ingest "./data/faq.csv"
88
+ ```
89
+
90
+ ### 2. Ask Questions
91
+ Query your newly created local knowledge base:
92
+
93
+ ```bash
94
+ docpilot ask "How do I create a virtual environment?"
95
+ ```
96
+
97
+ ---
98
+
99
+ ## ๐Ÿงฐ CLI Command Reference
100
+
101
+ Manage your configuration, models, and local database with ease.
102
+
103
+ ### `docpilot setup`
104
+ Re-run the interactive setup wizard at any time to change your default models.
105
+
106
+ ### `docpilot clear`
107
+ Wipe your local Chroma vector database to start fresh. Prompts for safety confirmation.
108
+
109
+ ### `docpilot speed [profile]`
110
+ Adjust the retrieval and generation settings for your desired use case.
111
+ - `fast`: Lower latency, shorter context limits.
112
+ - `balanced`: Default trade-off.
113
+ - `quality`: Larger context, more comprehensive answers, slower inference.
114
+
115
+ ### `docpilot model`
116
+ Manually manage your Ollama models without the interactive setup wizard.
117
+ ```bash
118
+ docpilot model list
119
+ docpilot model set <chat-model>
120
+ docpilot model setembed <embedding-model>
121
+ ```
122
+
123
+ ### `docpilot render`
124
+ Parse and beautifully render any markdown file or text string directly in your terminal.
125
+
126
+ ### `docpilot show`
127
+ Display your current project version and configuration in beautiful ASCII art.
128
+
129
+ ---
130
+
131
+ ## ๐Ÿ—๏ธ Architecture Under the Hood
132
+
133
+ DocPilot employs an optimized RAG (Retrieval-Augmented Generation) pipeline:
134
+
135
+ 1. **Ingestion**: Native Python extractors (BeautifulSoup4, `csv`, `pypdf`) parse the raw data.
136
+ 2. **Chunking**: Multi-threaded chunkers slice the documents into semantically coherent pieces.
137
+ 3. **Embedding**: `langchain-ollama` creates local vector embeddings via Ollama.
138
+ 4. **Storage**: `chromadb` persistently stores vectors on disk at `~/.docpilot/chroma_langchain_db`.
139
+ 5. **Retrieval**: User queries are embedded, matched via similarity search, and fed into a system prompt.
140
+ 6. **Generation**: The designated Ollama chat model generates the final response streamed to the terminal using `rich`.
141
+
142
+ ---
143
+
144
+ ## ๐Ÿค Contributing
145
+
146
+ Contributions are welcome! If you are using DocPilot for your daily workflows or in a hackathon, feel free to open issues and pull requests.
147
+
148
+ To set up a local development environment:
149
+ ```bash
150
+ git clone https://github.com/yourusername/docpilot.git
151
+ cd docpilot
152
+ uv pip install -e ".[dev]"
153
+ uv run pytest
154
+ ```
155
+
156
+ ---
157
+
158
+ ## ๐Ÿ“„ License
159
+
160
+ This project is licensed under the MIT License.
@@ -0,0 +1,138 @@
1
+ # ๐Ÿš€ DocPilot CLI
2
+
3
+ ![PyPI - Version](https://img.shields.io/pypi/v/docpilot-cli?color=blue&style=flat-square)
4
+ ![Python Version](https://img.shields.io/badge/python-3.12%2B-blue?style=flat-square)
5
+ ![License](https://img.shields.io/badge/license-MIT-green?style=flat-square)
6
+
7
+ **DocPilot** is a lightning-fast, local-first CLI for document ingestion and interactive question-answering. Powered by [Ollama](https://ollama.com/) and Chroma, it allows you to ingest websites, PDFs, and CSVs directly from your terminal and chat with your documentsโ€”keeping 100% of your data safely on your own machine.
8
+
9
+ Itโ€™s built for practical developer workflows: crawl sites concurrently, prepare chunks with multi-threading, and iterate rapidly without ever paying for a cloud API.
10
+
11
+ ---
12
+
13
+ ## โœจ Features
14
+
15
+ - **๐Ÿ”’ 100% Local**: No data ever leaves your machine. Powered by Ollama.
16
+ - **โšก Interactive Setup Wizard**: Get up and running instantly with smart model auto-detection.
17
+ - **๐ŸŒ Universal Ingestion**: Seamlessly ingest Website URLs, XML Sitemaps, PDFs, and CSVs.
18
+ - **๐Ÿš€ Concurrent Processing**: Lightning-fast crawling and multi-threaded document chunking.
19
+ - **๐ŸŽ›๏ธ Performance Profiles**: Switch between `fast`, `balanced`, and `quality` inference speeds on the fly.
20
+ - **๐ŸŽจ Beautiful Terminal UI**: Rich markdown rendering, ASCII art, and intuitive progress bars.
21
+
22
+ ---
23
+
24
+ ## ๐Ÿ“ฆ Installation
25
+
26
+ DocPilot is available on PyPI! You can install it globally using `pip`, `uv`, or `pipx`.
27
+
28
+ ```bash
29
+ # Recommended: Install using uv or pipx
30
+ uv tool install docpilot-cli
31
+
32
+ # Or via standard pip
33
+ pip install docpilot-cli
34
+
35
+ # Optional: Add PDF parsing support
36
+ pip install "docpilot-cli[pdf]"
37
+ ```
38
+
39
+ ### Prerequisites
40
+ 1. **Python 3.12+**
41
+ 2. **[Ollama](https://ollama.com/)**: Installed and running in the background.
42
+ 3. Pull your preferred models:
43
+ ```bash
44
+ ollama pull qwen2.5:latest
45
+ ollama pull mxbai-embed-large:335m
46
+ ```
47
+
48
+ ---
49
+
50
+ ## ๐Ÿ› ๏ธ Quick Start
51
+
52
+ The very first time you run a DocPilot command, it will launch the **Interactive Setup Wizard** to help you configure your chat and embedding models.
53
+
54
+ ### 1. Ingest Knowledge
55
+ Point DocPilot to any documentation site, sitemap, PDF, or CSV:
56
+
57
+ ```bash
58
+ # Crawl a website
59
+ docpilot ingest "https://docs.python.org/3/" --max-pages 100 --workers 16
60
+
61
+ # Ingest a local PDF
62
+ docpilot ingest "./docs/engineering_handbook.pdf"
63
+
64
+ # Ingest a CSV
65
+ docpilot ingest "./data/faq.csv"
66
+ ```
67
+
68
+ ### 2. Ask Questions
69
+ Query your newly created local knowledge base:
70
+
71
+ ```bash
72
+ docpilot ask "How do I create a virtual environment?"
73
+ ```
74
+
75
+ ---
76
+
77
+ ## ๐Ÿงฐ CLI Command Reference
78
+
79
+ Manage your configuration, models, and local database with ease.
80
+
81
+ ### `docpilot setup`
82
+ Re-run the interactive setup wizard at any time to change your default models.
83
+
84
+ ### `docpilot clear`
85
+ Wipe your local Chroma vector database to start fresh. Prompts for safety confirmation.
86
+
87
+ ### `docpilot speed [profile]`
88
+ Adjust the retrieval and generation settings for your desired use case.
89
+ - `fast`: Lower latency, shorter context limits.
90
+ - `balanced`: Default trade-off.
91
+ - `quality`: Larger context, more comprehensive answers, slower inference.
92
+
93
+ ### `docpilot model`
94
+ Manually manage your Ollama models without the interactive setup wizard.
95
+ ```bash
96
+ docpilot model list
97
+ docpilot model set <chat-model>
98
+ docpilot model setembed <embedding-model>
99
+ ```
100
+
101
+ ### `docpilot render`
102
+ Parse and beautifully render any markdown file or text string directly in your terminal.
103
+
104
+ ### `docpilot show`
105
+ Display your current project version and configuration in beautiful ASCII art.
106
+
107
+ ---
108
+
109
+ ## ๐Ÿ—๏ธ Architecture Under the Hood
110
+
111
+ DocPilot employs an optimized RAG (Retrieval-Augmented Generation) pipeline:
112
+
113
+ 1. **Ingestion**: Native Python extractors (BeautifulSoup4, `csv`, `pypdf`) parse the raw data.
114
+ 2. **Chunking**: Multi-threaded chunkers slice the documents into semantically coherent pieces.
115
+ 3. **Embedding**: `langchain-ollama` creates local vector embeddings via Ollama.
116
+ 4. **Storage**: `chromadb` persistently stores vectors on disk at `~/.docpilot/chroma_langchain_db`.
117
+ 5. **Retrieval**: User queries are embedded, matched via similarity search, and fed into a system prompt.
118
+ 6. **Generation**: The designated Ollama chat model generates the final response streamed to the terminal using `rich`.
119
+
120
+ ---
121
+
122
+ ## ๐Ÿค Contributing
123
+
124
+ Contributions are welcome! If you are using DocPilot for your daily workflows or in a hackathon, feel free to open issues and pull requests.
125
+
126
+ To set up a local development environment:
127
+ ```bash
128
+ git clone https://github.com/yourusername/docpilot.git
129
+ cd docpilot
130
+ uv pip install -e ".[dev]"
131
+ uv run pytest
132
+ ```
133
+
134
+ ---
135
+
136
+ ## ๐Ÿ“„ License
137
+
138
+ This project is licensed under the MIT License.
@@ -0,0 +1,41 @@
1
+ [project]
2
+ name = "docpilot-cli"
3
+ version = "1.0.0"
4
+ description = "A local-first RAG pipeline CLI tool"
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ dependencies = [
8
+ "bs4>=0.0.2",
9
+ "beautifulsoup4>=4.12.0",
10
+ "langchain>=0.2.0",
11
+ "langchain-chroma>=0.1.0",
12
+ "langchain-ollama>=0.1.0",
13
+ "ollama>=0.2.0",
14
+ "pandas>=2.0.0",
15
+ "typer>=0.12.0",
16
+ "httpx>=0.27.0",
17
+ "tomli-w>=1.0.0",
18
+ "pypdf>=5.0.0",
19
+ "pyfiglet>=0.8.0",
20
+ "rich>=13.0.0",
21
+ ]
22
+
23
+ [project.scripts]
24
+ docpilot = "docpilot.cli:app"
25
+
26
+ [tool.setuptools.packages.find]
27
+ where = ["src"]
28
+
29
+ [build-system]
30
+ requires = ["setuptools>=68", "wheel"]
31
+ build-backend = "setuptools.build_meta"
32
+
33
+ [dependency-groups]
34
+ dev = [
35
+ "pytest>=8.0.0",
36
+ "pytest-mock>=3.12.0",
37
+ "ruff>=0.4.0",
38
+ ]
39
+
40
+ [tool.ruff]
41
+ line-length = 120
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
@@ -0,0 +1,66 @@
1
+ from langchain_ollama.llms import OllamaLLM as Ollama
2
+ from langchain_core.prompts import ChatPromptTemplate
3
+ from .embed import vectorstore
4
+ import os
5
+ from . import store
6
+
7
+ config = store.load_config()
8
+ retrieval_k = int(config.get("retrieval_k", 6))
9
+ max_context_chars = int(config.get("max_context_chars", 3500))
10
+ max_doc_chars = int(config.get("max_doc_chars", 700))
11
+
12
+ model = Ollama(
13
+ model=config.get("default_model", "deepseek-coder-v2"),
14
+ num_predict=int(config.get("num_predict", 192)),
15
+ num_ctx=int(config.get("num_ctx", 2048)),
16
+ num_thread=int(config.get("num_thread", max(1, (os.cpu_count() or 4) - 1))),
17
+ temperature=float(config.get("temperature", 0.1)),
18
+ )
19
+
20
+ retriever = vectorstore.as_retriever(search_kwargs={"k": retrieval_k})
21
+ template = """
22
+ You are an assistant for answering questions based on the following ingested documents.
23
+ Use the information in the documents to answer the question as best as you can.
24
+ If you don't know the answer, say you don't know.
25
+ Always use the information in the documents and never make up an answer.
26
+ Here are some relevant docs: {reviews}
27
+ Here is the question to answer: {question}
28
+ """
29
+ prompt = ChatPromptTemplate.from_template(template)
30
+
31
+ chain = prompt | model
32
+
33
+
34
+ def _build_bounded_context(docs, max_total_chars: int = 6000, max_doc_chars: int = 1200) -> str:
35
+ lines = []
36
+ total = 0
37
+ for doc in docs:
38
+ doc_text = doc.page_content.strip()
39
+ if len(doc_text) > max_doc_chars:
40
+ doc_text = doc_text[:max_doc_chars].rsplit(" ", 1)[0].strip() or doc_text[:max_doc_chars]
41
+ line = f"[ID: {doc.id}] {doc_text}"
42
+ if total + len(line) > max_total_chars:
43
+ break
44
+ lines.append(line)
45
+ total += len(line)
46
+ return "\n".join(lines)
47
+
48
+
49
+ def askai(question):
50
+ rag = retriever.invoke(question)
51
+ rag_text = _build_bounded_context(
52
+ rag,
53
+ max_total_chars=max_context_chars,
54
+ max_doc_chars=max_doc_chars,
55
+ )
56
+ result = chain.invoke({"reviews": rag_text, "question": question})
57
+ return result
58
+
59
+
60
+ if __name__ == "__main__":
61
+ while True:
62
+ question = input("Ask a question (or type 'exit'): ")
63
+ if question.lower() == "exit":
64
+ break
65
+ result = askai(question)
66
+ print(result, "\n\n")