ngpt 3.4.4__tar.gz → 3.5.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.
- {ngpt-3.4.4/docs → ngpt-3.5.0}/CONTRIBUTING.md +44 -14
- {ngpt-3.4.4 → ngpt-3.5.0}/PKG-INFO +105 -258
- {ngpt-3.4.4 → ngpt-3.5.0}/PKGBUILD +1 -1
- {ngpt-3.4.4 → ngpt-3.5.0}/README.md +102 -255
- {ngpt-3.4.4 → ngpt-3.5.0/docs}/CONTRIBUTING.md +52 -10
- {ngpt-3.4.4 → ngpt-3.5.0}/docs/LICENSE.md +4 -0
- ngpt-3.5.0/docs/_config.yml +11 -0
- ngpt-3.5.0/docs/_sass/custom/custom.scss +18 -0
- ngpt-3.5.0/docs/configuration.md +349 -0
- ngpt-3.5.0/docs/examples/advanced.md +361 -0
- ngpt-3.5.0/docs/examples/basic.md +322 -0
- ngpt-3.5.0/docs/examples.md +14 -0
- ngpt-3.5.0/docs/index.md +78 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/docs/installation.md +57 -66
- ngpt-3.5.0/docs/overview.md +127 -0
- ngpt-3.5.0/docs/usage/cli_config.md +266 -0
- ngpt-3.5.0/docs/usage/cli_usage.md +603 -0
- ngpt-3.5.0/docs/usage/gitcommsg.md +275 -0
- ngpt-3.5.0/docs/usage/web_search.md +115 -0
- ngpt-3.5.0/docs/usage.md +16 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/ngpt/cli/modes/chat.py +15 -11
- ngpt-3.5.0/ngpt/utils/web_search.py +594 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/pyproject.toml +3 -3
- {ngpt-3.4.4 → ngpt-3.5.0}/uv.lock +13 -342
- {ngpt-3.4.4 → ngpt-3.5.0}/wiki.md +9 -9
- ngpt-3.4.4/docs/README.md +0 -39
- ngpt-3.4.4/docs/_config.yml +0 -7
- ngpt-3.4.4/docs/api/README.md +0 -114
- ngpt-3.4.4/docs/api/cli.md +0 -897
- ngpt-3.4.4/docs/api/cli_config.md +0 -364
- ngpt-3.4.4/docs/api/client.md +0 -329
- ngpt-3.4.4/docs/api/config.md +0 -512
- ngpt-3.4.4/docs/api/logging.md +0 -138
- ngpt-3.4.4/docs/assets/css/style.scss +0 -75
- ngpt-3.4.4/docs/configuration.md +0 -390
- ngpt-3.4.4/docs/examples/README.md +0 -115
- ngpt-3.4.4/docs/examples/advanced.md +0 -753
- ngpt-3.4.4/docs/examples/basic.md +0 -433
- ngpt-3.4.4/docs/examples/cli_components.md +0 -1197
- ngpt-3.4.4/docs/examples/integrations.md +0 -725
- ngpt-3.4.4/docs/overview.md +0 -62
- ngpt-3.4.4/docs/usage/README.md +0 -136
- ngpt-3.4.4/docs/usage/cli_config.md +0 -284
- ngpt-3.4.4/docs/usage/cli_framework.md +0 -782
- ngpt-3.4.4/docs/usage/cli_usage.md +0 -1022
- ngpt-3.4.4/docs/usage/gitcommsg.md +0 -410
- ngpt-3.4.4/docs/usage/library_usage.md +0 -759
- ngpt-3.4.4/ngpt/utils/web_search.py +0 -310
- {ngpt-3.4.4 → ngpt-3.5.0}/.github/workflows/aur-publish.yml +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/.github/workflows/python-publish.yml +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/.gitignore +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/.python-version +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/COMMIT_GUIDELINES.md +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/LICENSE +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/ngpt/__init__.py +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/ngpt/__main__.py +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/ngpt/cli/__init__.py +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/ngpt/cli/args.py +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/ngpt/cli/config_manager.py +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/ngpt/cli/formatters.py +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/ngpt/cli/main.py +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/ngpt/cli/modes/__init__.py +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/ngpt/cli/modes/code.py +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/ngpt/cli/modes/gitcommsg.py +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/ngpt/cli/modes/interactive.py +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/ngpt/cli/modes/rewrite.py +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/ngpt/cli/modes/shell.py +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/ngpt/cli/modes/text.py +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/ngpt/cli/renderers.py +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/ngpt/cli/ui.py +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/ngpt/client.py +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/ngpt/utils/__init__.py +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/ngpt/utils/cli_config.py +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/ngpt/utils/config.py +0 -0
- {ngpt-3.4.4 → ngpt-3.5.0}/ngpt/utils/log.py +0 -0
@@ -1,8 +1,3 @@
|
|
1
|
-
---
|
2
|
-
title: Contributing to NGPT
|
3
|
-
description: Guidelines and instructions for contributing to the NGPT project
|
4
|
-
---
|
5
|
-
|
6
1
|
# Contributing to NGPT
|
7
2
|
|
8
3
|
Thank you for your interest in contributing to NGPT! This document provides guidelines and instructions for contributing to this project.
|
@@ -33,15 +28,15 @@ Thank you for your interest in contributing to NGPT! This document provides guid
|
|
33
28
|
- `args.py` - Argument parsing setup
|
34
29
|
- `config_manager.py` - CLI configuration handling
|
35
30
|
- `formatters.py` - Output formatting logic
|
36
|
-
- `interactive.py` - Interactive mode implementation
|
37
31
|
- `modes/` - Different operational modes
|
38
32
|
- `__init__.py` - Modes initialization
|
39
33
|
- `chat.py` - Chat mode functionality
|
40
34
|
- `code.py` - Code generation mode
|
41
35
|
- `gitcommsg.py` - Git commit message generation
|
36
|
+
- `interactive.py` - Interactive mode implementation
|
37
|
+
- `rewrite.py` - Text rewriting mode
|
42
38
|
- `shell.py` - Shell command generation
|
43
39
|
- `text.py` - Text generation mode
|
44
|
-
- `rewrite.py` - Text rewriting mode
|
45
40
|
- `renderers.py` - Output rendering logic (e.g., markdown)
|
46
41
|
- `ui.py` - User interface elements (e.g., prompts, spinners)
|
47
42
|
- `utils/` - Utility modules
|
@@ -50,8 +45,7 @@ Thank you for your interest in contributing to NGPT! This document provides guid
|
|
50
45
|
- `cli_config.py` - CLI-specific option configuration management
|
51
46
|
- `log.py` - Logging setup and utilities
|
52
47
|
- `docs/` - Documentation files
|
53
|
-
- `
|
54
|
-
- `examples/` - Example code and usage
|
48
|
+
- `examples/` - Example usage
|
55
49
|
- `usage/` - Usage guides and tutorials
|
56
50
|
- `.github/` - GitHub workflows and templates
|
57
51
|
- `pyproject.toml` - Project configuration and dependencies
|
@@ -83,14 +77,22 @@ Before submitting a pull request, please make sure that:
|
|
83
77
|
5. Push to your fork: `git push origin feature/your-feature-name`
|
84
78
|
6. Open a Pull Request against the main repository
|
85
79
|
|
86
|
-
## Testing
|
80
|
+
## Testing Your Changes
|
87
81
|
|
88
82
|
Before submitting your changes, please test:
|
89
83
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
84
|
+
1. Basic CLI functionality
|
85
|
+
2. Any new features you've added
|
86
|
+
3. Any components you've modified
|
87
|
+
4. Test on different platforms if possible (Windows, Linux, macOS)
|
88
|
+
5. Try various prompts and inputs to ensure robustness
|
89
|
+
|
90
|
+
Test your changes with:
|
91
|
+
```bash
|
92
|
+
# After installing with -e flag
|
93
|
+
python -m ngpt --version
|
94
|
+
python -m ngpt "Test prompt"
|
95
|
+
```
|
94
96
|
|
95
97
|
## Issue Reporting
|
96
98
|
|
@@ -115,6 +117,34 @@ Feature requests are welcome! To submit a feature request:
|
|
115
117
|
|
116
118
|
For questions about the project that aren't bugs or feature requests, please use GitHub Discussions instead of opening an issue. This helps keep the issue tracker focused on bugs and features.
|
117
119
|
|
120
|
+
## Common Tasks
|
121
|
+
|
122
|
+
### Adding a New Mode
|
123
|
+
|
124
|
+
If you're adding a new mode to nGPT, you should:
|
125
|
+
|
126
|
+
1. Create a new file in `ngpt/cli/modes/` for your mode implementation
|
127
|
+
2. Add your mode to the mode selection logic in `ngpt/cli/args.py`
|
128
|
+
3. Update help documentation to include your mode
|
129
|
+
4. Add tests for your new mode
|
130
|
+
5. Update documentation in `docs/usage/` to describe your mode
|
131
|
+
|
132
|
+
### Improving Renderers
|
133
|
+
|
134
|
+
For improvements to the output rendering:
|
135
|
+
|
136
|
+
1. Modify the renderer code in `ngpt/cli/renderers.py`
|
137
|
+
2. Ensure backward compatibility if possible
|
138
|
+
3. Test with various types of output (code, markdown, tables, etc.)
|
139
|
+
|
140
|
+
### Updating Documentation
|
141
|
+
|
142
|
+
When updating documentation:
|
143
|
+
|
144
|
+
1. Ensure your changes are reflected in both the code docstrings and in the Markdown documentation
|
145
|
+
2. Update examples if necessary
|
146
|
+
3. Test that documentation renders correctly
|
147
|
+
|
118
148
|
## License
|
119
149
|
|
120
150
|
By contributing to this project, you agree that your contributions will be licensed under the same [LICENSE](LICENSE) as the project.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ngpt
|
3
|
-
Version: 3.
|
4
|
-
Summary: Swiss army knife for LLMs: powerful CLI
|
3
|
+
Version: 3.5.0
|
4
|
+
Summary: Swiss army knife for LLMs: powerful CLI and interactive chatbot in one package. Seamlessly work with OpenAI, Ollama, Groq, Claude, Gemini, or any OpenAI-compatible API to generate code, craft git commits, rewrite text, and execute shell commands.
|
5
5
|
Project-URL: Homepage, https://github.com/nazdridoy/ngpt
|
6
6
|
Project-URL: Repository, https://github.com/nazdridoy/ngpt
|
7
7
|
Project-URL: Bug Tracker, https://github.com/nazdridoy/ngpt/issues
|
@@ -28,12 +28,12 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
28
28
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
29
29
|
Classifier: Topic :: Utilities
|
30
30
|
Requires-Python: >=3.8
|
31
|
+
Requires-Dist: beautifulsoup4>=4.12.0
|
31
32
|
Requires-Dist: duckduckgo-search>=3.0.0
|
32
33
|
Requires-Dist: prompt-toolkit>=3.0.0
|
33
34
|
Requires-Dist: pyperclip>=1.8.0
|
34
35
|
Requires-Dist: requests>=2.31.0
|
35
36
|
Requires-Dist: rich>=10.0.0
|
36
|
-
Requires-Dist: trafilatura>=1.6.0
|
37
37
|
Description-Content-Type: text/markdown
|
38
38
|
|
39
39
|
# nGPT
|
@@ -46,13 +46,13 @@ Description-Content-Type: text/markdown
|
|
46
46
|
</p>
|
47
47
|
|
48
48
|
<p align="center">
|
49
|
-
<a href="https://nazdridoy.github.io/ngpt/installation
|
50
|
-
<a href="https://nazdridoy.github.io/ngpt/installation
|
51
|
-
<a href="https://nazdridoy.github.io/ngpt/installation
|
52
|
-
<a href="https://nazdridoy.github.io/ngpt/installation
|
49
|
+
<a href="https://nazdridoy.github.io/ngpt/installation/"><img src="https://img.shields.io/badge/Linux-support-blue?logo=linux" alt="Linux"></a>
|
50
|
+
<a href="https://nazdridoy.github.io/ngpt/installation/"><img src="https://img.shields.io/badge/Windows-support-blue?logo=windows" alt="Windows"></a>
|
51
|
+
<a href="https://nazdridoy.github.io/ngpt/installation/"><img src="https://img.shields.io/badge/macOS-support-blue?logo=apple" alt="macOS"></a>
|
52
|
+
<a href="https://nazdridoy.github.io/ngpt/installation/"><img src="https://img.shields.io/badge/Android-Termux-blue?logo=android" alt="Android"></a>
|
53
53
|
</p>
|
54
54
|
|
55
|
-
🤖 nGPT: A Swiss army knife for LLMs: powerful CLI
|
55
|
+
🤖 nGPT: A Swiss army knife for LLMs: powerful CLI and interactive chatbot in one package. Seamlessly work with OpenAI, Ollama, Groq, Claude, Gemini, or any OpenAI-compatible API to generate code, craft git commits, rewrite text, and execute shell commands. Fast, lightweight, and designed for both casual users and developers.
|
56
56
|
|
57
57
|
|
58
58
|

|
@@ -60,12 +60,12 @@ Description-Content-Type: text/markdown
|
|
60
60
|
|
61
61
|
## Features
|
62
62
|
|
63
|
-
- ✅ **Versatile**:
|
63
|
+
- ✅ **Versatile**: Powerful and easy-to-use CLI tool for various AI tasks
|
64
64
|
- 🪶 **Lightweight**: Minimal dependencies with everything you need included
|
65
|
-
- 🔄 **API Flexibility**: Works with OpenAI, Ollama, Groq, Claude, Gemini, and any compatible endpoint
|
65
|
+
- 🔄 **API Flexibility**: Works with OpenAI, Ollama, Groq, Claude, Gemini, and any OpenAI-compatible endpoint
|
66
66
|
- 💬 **Interactive Chat**: Continuous conversation with memory in modern UI
|
67
67
|
- 📊 **Streaming Responses**: Real-time output for better user experience
|
68
|
-
- 🔍 **Web Search**: Enhance any model with contextual information from the web
|
68
|
+
- 🔍 **Web Search**: Enhance any model with contextual information from the web, using advanced content extraction to identify the most relevant information from web pages
|
69
69
|
- 📥 **Stdin Processing**: Process piped content by using `{}` placeholder in prompts
|
70
70
|
- 🎨 **Markdown Rendering**: Beautiful formatting of markdown and code with syntax highlighting
|
71
71
|
- ⚡ **Real-time Markdown**: Stream responses with live updating syntax highlighting and formatting
|
@@ -77,48 +77,55 @@ Description-Content-Type: text/markdown
|
|
77
77
|
- 📑 **Git Commit Messages**: AI-powered generation of conventional, detailed commit messages from git diffs
|
78
78
|
- 🎭 **System Prompts**: Customize model behavior with custom system prompts
|
79
79
|
- 📃 **Conversation Logging**: Save your conversations to text files for later reference
|
80
|
-
- 🧰 **CLI Components**: Reusable components for building custom AI-powered command-line tools
|
81
80
|
- 🔌 **Modular Architecture**: Well-structured codebase with clean separation of concerns
|
82
81
|
- 🔄 **Provider Switching**: Easily switch between different LLM providers with a single parameter
|
83
82
|
- 🚀 **Performance Optimized**: Fast response times and minimal resource usage
|
84
83
|
|
85
|
-
See the [Feature Overview](https://nazdridoy.github.io/ngpt/overview
|
84
|
+
See the [Feature Overview](https://nazdridoy.github.io/ngpt/overview/) for more details.
|
86
85
|
|
87
86
|
|
88
87
|
## Table of Contents
|
89
|
-
- [Quick Start](#quick-start)
|
90
88
|
- [Features](#features)
|
91
|
-
- [Documentation](#documentation)
|
92
89
|
- [Installation](#installation)
|
90
|
+
- [Quick Start](#quick-start)
|
93
91
|
- [Usage](#usage)
|
92
|
+
- [Command Line Options](#command-line-options)
|
94
93
|
- [Documentation](https://nazdridoy.github.io/ngpt/)
|
95
|
-
|
96
|
-
- [Python Library](#as-a-library)
|
97
|
-
- [CLI Framework](#as-a-cli-framework)
|
94
|
+
- [Documentation](#documentation)
|
98
95
|
- [Configuration](#configuration)
|
99
|
-
- [
|
96
|
+
- [API Key Setup](#api-key-setup)
|
97
|
+
- [OpenAI API Key](#openai-api-key)
|
98
|
+
- [Google Gemini API Key](#google-gemini-api-key)
|
100
99
|
- [CLI Configuration](#cli-configuration)
|
101
100
|
- [Interactive Configuration](#interactive-configuration)
|
102
101
|
- [Configuration File](#configuration-file)
|
103
102
|
- [Configuration Priority](#configuration-priority)
|
104
|
-
- [API Key Setup](#api-key-setup)
|
105
|
-
- [OpenAI API Key](#openai-api-key)
|
106
|
-
- [Google Gemini API Key](#google-gemini-api-key)
|
107
103
|
- [Contributing](#contributing)
|
108
104
|
- [License](#license)
|
109
105
|
|
110
|
-
##
|
106
|
+
## Installation
|
111
107
|
|
112
108
|
```bash
|
113
|
-
#
|
109
|
+
# Installation with pip
|
114
110
|
pip install ngpt
|
115
111
|
|
116
|
-
# Or install with uv (faster)
|
112
|
+
# Or install with uv (faster installation)
|
117
113
|
uv pip install ngpt
|
118
114
|
|
119
|
-
# Or install globally as a CLI tool (recommended)
|
115
|
+
# Or install globally as a CLI tool (recommended for command-line usage)
|
120
116
|
uv tool install ngpt
|
121
117
|
|
118
|
+
# Arch Linux: install from AUR
|
119
|
+
paru -S ngpt
|
120
|
+
```
|
121
|
+
|
122
|
+
Requires Python 3.8 or newer.
|
123
|
+
|
124
|
+
For detailed installation instructions, see the [Installation Guide](https://nazdridoy.github.io/ngpt/installation/).
|
125
|
+
|
126
|
+
## Quick Start
|
127
|
+
|
128
|
+
```bash
|
122
129
|
# Chat with default settings
|
123
130
|
ngpt "Tell me about quantum computing"
|
124
131
|
|
@@ -203,60 +210,6 @@ ngpt --provider Groq "Explain quantum computing"
|
|
203
210
|
# Compare outputs from different providers
|
204
211
|
ngpt --provider OpenAI "Explain quantum physics" > openai_response.txt
|
205
212
|
ngpt --provider Ollama "Explain quantum physics" > ollama_response.txt
|
206
|
-
```
|
207
|
-
|
208
|
-
For more examples and detailed usage, visit the [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage.html).
|
209
|
-
|
210
|
-
## Documentation
|
211
|
-
|
212
|
-
Comprehensive documentation, including API reference, usage guides, and examples, is available at:
|
213
|
-
|
214
|
-
**[https://nazdridoy.github.io/ngpt/](https://nazdridoy.github.io/ngpt/)**
|
215
|
-
|
216
|
-
Key documentation sections:
|
217
|
-
- [Installation Guide](https://nazdridoy.github.io/ngpt/installation.html)
|
218
|
-
- [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage.html)
|
219
|
-
- [Library Usage Guide](https://nazdridoy.github.io/ngpt/usage/library_usage.html)
|
220
|
-
- [CLI Framework Guide](https://nazdridoy.github.io/ngpt/usage/cli_framework.html)
|
221
|
-
- [Configuration Guide](https://nazdridoy.github.io/ngpt/configuration.html)
|
222
|
-
- [Examples & Tutorials](https://nazdridoy.github.io/ngpt/examples/basic.html)
|
223
|
-
|
224
|
-
## Installation
|
225
|
-
|
226
|
-
```bash
|
227
|
-
# Installation with pip
|
228
|
-
pip install ngpt
|
229
|
-
|
230
|
-
# Or install with uv (faster installation)
|
231
|
-
uv pip install ngpt
|
232
|
-
|
233
|
-
# Or install globally as a CLI tool (recommended for command-line usage)
|
234
|
-
uv tool install ngpt
|
235
|
-
|
236
|
-
# Arch Linux: install from AUR
|
237
|
-
paru -S ngpt
|
238
|
-
```
|
239
|
-
|
240
|
-
Requires Python 3.8 or newer.
|
241
|
-
|
242
|
-
For detailed installation instructions, see the [Installation Guide](https://nazdridoy.github.io/ngpt/installation.html).
|
243
|
-
|
244
|
-
## Usage
|
245
|
-
|
246
|
-
### As a CLI Tool
|
247
|
-
|
248
|
-
```bash
|
249
|
-
# Basic chat (default mode)
|
250
|
-
ngpt "Hello, how are you?"
|
251
|
-
|
252
|
-
# Interactive chat session with conversation history
|
253
|
-
ngpt -i
|
254
|
-
|
255
|
-
# Log conversation to a file
|
256
|
-
ngpt --interactive --log conversation.log
|
257
|
-
|
258
|
-
# Use custom system prompt to guide AI behavior
|
259
|
-
ngpt --preprompt "You are a Python programming tutor" "Explain decorators"
|
260
213
|
|
261
214
|
# Show all API configurations
|
262
215
|
ngpt --show-config --all
|
@@ -282,165 +235,16 @@ ngpt -s "list all files in current directory"
|
|
282
235
|
# On Windows generates: dir
|
283
236
|
# On Linux/macOS generates: ls -la
|
284
237
|
|
285
|
-
# Generate
|
286
|
-
# Returns only code without markdown formatting or explanations
|
238
|
+
# Generate code (using -c or --code flag)
|
287
239
|
ngpt -c "create a python function that calculates fibonacci numbers"
|
288
240
|
|
289
241
|
# Use multiline text editor for complex prompts (using -t or --text flag)
|
290
|
-
# Opens an interactive editor with syntax highlighting and intuitive controls
|
291
242
|
ngpt -t
|
292
243
|
```
|
293
244
|
|
294
|
-
For more
|
295
|
-
|
296
|
-
### As a Library
|
297
|
-
|
298
|
-
```python
|
299
|
-
from ngpt import NGPTClient
|
300
|
-
from ngpt.utils.config import load_config
|
301
|
-
|
302
|
-
# Load the first configuration (index 0) from config file
|
303
|
-
config = load_config(config_index=0)
|
304
|
-
|
305
|
-
# Initialize the client with config
|
306
|
-
client = NGPTClient(**config)
|
307
|
-
|
308
|
-
# Or initialize with custom parameters
|
309
|
-
client = NGPTClient(
|
310
|
-
api_key="your-key",
|
311
|
-
base_url="http://your-endpoint",
|
312
|
-
provider="openai",
|
313
|
-
model="o3-mini"
|
314
|
-
)
|
315
|
-
|
316
|
-
# Chat
|
317
|
-
response = client.chat("Hello, how are you?")
|
318
|
-
|
319
|
-
# Chat with web search (if your API endpoint supports it)
|
320
|
-
response = client.chat("What's the latest news about AI?", web_search=True)
|
321
|
-
|
322
|
-
# Generate shell command
|
323
|
-
command = client.generate_shell_command("list all files")
|
324
|
-
|
325
|
-
# Generate code
|
326
|
-
code = client.generate_code("create a python function that calculates fibonacci numbers")
|
327
|
-
```
|
328
|
-
|
329
|
-
For more library examples and advanced usage, see the [Library Usage Guide](https://nazdridoy.github.io/ngpt/usage/library_usage.html).
|
330
|
-
|
331
|
-
#### Advanced Library Usage
|
332
|
-
|
333
|
-
```python
|
334
|
-
# Stream responses
|
335
|
-
for chunk in client.chat("Write a poem about Python", stream=True):
|
336
|
-
print(chunk, end="", flush=True)
|
337
|
-
|
338
|
-
# Customize system prompt
|
339
|
-
response = client.chat(
|
340
|
-
"Explain quantum computing",
|
341
|
-
system_prompt="You are a quantum physics professor. Explain complex concepts simply."
|
342
|
-
)
|
343
|
-
|
344
|
-
# OS-aware shell commands
|
345
|
-
# Automatically generates appropriate commands for the current OS
|
346
|
-
command = client.generate_shell_command("find large files")
|
347
|
-
import subprocess
|
348
|
-
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
349
|
-
print(result.stdout)
|
350
|
-
|
351
|
-
# Clean code generation
|
352
|
-
# Returns only code without markdown or explanations
|
353
|
-
code = client.generate_code("function that converts Celsius to Fahrenheit")
|
354
|
-
print(code)
|
355
|
-
|
356
|
-
# Compare responses from different providers
|
357
|
-
openai_config = load_config(config_index=0) # OpenAI
|
358
|
-
groq_config = load_config(config_index=1) # Groq
|
359
|
-
|
360
|
-
openai_client = NGPTClient(**openai_config)
|
361
|
-
groq_client = NGPTClient(**groq_config)
|
362
|
-
|
363
|
-
openai_response = openai_client.chat("Explain quantum computing")
|
364
|
-
groq_response = groq_client.chat("Explain quantum computing")
|
365
|
-
```
|
366
|
-
|
367
|
-
For advanced usage patterns and integrations, check out the [Advanced Examples](https://nazdridoy.github.io/ngpt/examples/advanced.html).
|
368
|
-
|
369
|
-
### As a CLI Framework
|
370
|
-
|
371
|
-
nGPT can also be used as a framework to build your own AI-powered command-line tools. You can leverage nGPT's pre-built CLI components to quickly develop sophisticated CLI applications.
|
372
|
-
|
373
|
-
```python
|
374
|
-
from ngpt import NGPTClient
|
375
|
-
from ngpt.utils.config import load_config
|
376
|
-
from ngpt.cli.interactive import interactive_chat_session
|
377
|
-
from ngpt.cli.renderers import prettify_markdown
|
378
|
-
from ngpt.cli.args import setup_argument_parser
|
379
|
-
import sys
|
380
|
-
|
381
|
-
# Create a custom CLI tool with colorized help
|
382
|
-
parser = setup_argument_parser()
|
383
|
-
parser.description = "Specialized Code Assistant"
|
384
|
-
parser.add_argument("prompt", nargs="?", help="Code description")
|
385
|
-
parser.add_argument("--language", "-l", default="python", help="Programming language")
|
386
|
-
parser.add_argument("--interactive", "-i", action="store_true", help="Start interactive mode")
|
387
|
-
args = parser.parse_args()
|
388
|
-
|
389
|
-
# Initialize client
|
390
|
-
client = NGPTClient(**load_config())
|
391
|
-
|
392
|
-
# Use interactive session for conversation
|
393
|
-
if args.interactive:
|
394
|
-
system_prompt = f"You are an expert {args.language} developer. Provide clear, detailed answers."
|
395
|
-
interactive_chat_session(client=client, preprompt=system_prompt, prettify=True)
|
396
|
-
elif args.prompt:
|
397
|
-
# Generate and prettify code
|
398
|
-
code = client.generate_code(args.prompt, language=args.language)
|
399
|
-
print(prettify_markdown(f"```{args.language}\n{code}\n```"))
|
400
|
-
else:
|
401
|
-
parser.print_help()
|
402
|
-
sys.exit(1)
|
403
|
-
```
|
245
|
+
For more examples and detailed usage, visit the [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage/).
|
404
246
|
|
405
|
-
|
406
|
-
- Code generators for specific languages or frameworks
|
407
|
-
- Domain-specific assistants (SQL, legal, finance, etc.)
|
408
|
-
- Documentation generators
|
409
|
-
- Translation tools
|
410
|
-
- And much more
|
411
|
-
|
412
|
-
For detailed information about building CLI tools with nGPT, see the [CLI Framework Guide](https://nazdridoy.github.io/ngpt/usage/cli_framework.html) and explore the [CLI Component Examples](https://nazdridoy.github.io/ngpt/examples/cli_components.html).
|
413
|
-
|
414
|
-
## Configuration
|
415
|
-
|
416
|
-
### API Key Setup
|
417
|
-
|
418
|
-
#### OpenAI API Key
|
419
|
-
1. Create an account at [OpenAI](https://platform.openai.com/)
|
420
|
-
2. Navigate to API keys: https://platform.openai.com/api-keys
|
421
|
-
3. Click "Create new secret key" and copy your API key
|
422
|
-
4. Configure nGPT with your key:
|
423
|
-
```bash
|
424
|
-
ngpt --config
|
425
|
-
# Enter provider: OpenAI
|
426
|
-
# Enter API key: your-openai-api-key
|
427
|
-
# Enter base URL: https://api.openai.com/v1/
|
428
|
-
# Enter model: gpt-3.5-turbo (or other model)
|
429
|
-
```
|
430
|
-
|
431
|
-
#### Google Gemini API Key
|
432
|
-
1. Create or use an existing Google account
|
433
|
-
2. Go to [Google AI Studio](https://aistudio.google.com/)
|
434
|
-
3. Navigate to API keys in the left sidebar (or visit https://aistudio.google.com/app/apikey)
|
435
|
-
4. Create an API key and copy it
|
436
|
-
5. Configure nGPT with your key:
|
437
|
-
```bash
|
438
|
-
ngpt --config
|
439
|
-
# Enter provider: Gemini
|
440
|
-
# Enter API key: your-gemini-api-key
|
441
|
-
# Enter base URL: https://generativelanguage.googleapis.com/v1beta/openai
|
442
|
-
# Enter model: gemini-2.0-flash
|
443
|
-
```
|
247
|
+
## Usage
|
444
248
|
|
445
249
|
### Command Line Options
|
446
250
|
|
@@ -449,8 +253,8 @@ For detailed information about building CLI tools with nGPT, see the [CLI Framew
|
|
449
253
|
usage: ngpt [-h] [-v] [--language LANGUAGE] [--config [CONFIG]] [--config-index CONFIG_INDEX] [--provider PROVIDER]
|
450
254
|
[--remove] [--show-config] [--all] [--list-models] [--list-renderers] [--cli-config [COMMAND ...]]
|
451
255
|
[--api-key API_KEY] [--base-url BASE_URL] [--model MODEL] [--web-search] [--temperature TEMPERATURE]
|
452
|
-
[--top_p TOP_P] [--max_tokens MAX_TOKENS] [--log [FILE]] [--preprompt PREPROMPT] [--no-stream
|
453
|
-
|
256
|
+
[--top_p TOP_P] [--max_tokens MAX_TOKENS] [--log [FILE]] [--preprompt PREPROMPT] [--no-stream | --prettify |
|
257
|
+
--stream-prettify] [--renderer {auto,rich,glow}] [--rec-chunk] [--diff [FILE]] [--chunk-size CHUNK_SIZE]
|
454
258
|
[--analyses-chunk-size ANALYSES_CHUNK_SIZE] [--max-msg-lines MAX_MSG_LINES]
|
455
259
|
[--max-recursion-depth MAX_RECURSION_DEPTH] [-i | -s | -c | -t | -p | -r | -g]
|
456
260
|
[prompt]
|
@@ -469,12 +273,10 @@ options::
|
|
469
273
|
|
470
274
|
Configuration Options::
|
471
275
|
|
472
|
-
--config [CONFIG] Path to a custom config file or, if no value provided, enter interactive
|
473
|
-
configuration mode to create a new config
|
276
|
+
--config [CONFIG] Path to a custom config file or, if no value provided, enter interactive configuration mode to create a new config
|
474
277
|
--config-index CONFIG_INDEX Index of the configuration to use or edit (default: 0)
|
475
278
|
--provider PROVIDER Provider name to identify the configuration to use
|
476
|
-
--remove Remove the configuration at the specified index (requires --config and
|
477
|
-
--config-index or --provider)
|
279
|
+
--remove Remove the configuration at the specified index (requires --config and --config-index or --provider)
|
478
280
|
--show-config Show the current configuration(s) and exit
|
479
281
|
--all Show details for all configurations (requires --show-config)
|
480
282
|
--list-models List all available models for the current configuration and exit
|
@@ -486,30 +288,28 @@ Global Options::
|
|
486
288
|
--api-key API_KEY API key for the service
|
487
289
|
--base-url BASE_URL Base URL for the API
|
488
290
|
--model MODEL Model to use
|
489
|
-
--web-search Enable web search capability
|
490
|
-
feature)
|
291
|
+
--web-search Enable web search capability using DuckDuckGo to enhance prompts with relevant information
|
491
292
|
--temperature TEMPERATURE Set temperature (controls randomness, default: 0.7)
|
492
293
|
--top_p TOP_P Set top_p (controls diversity, default: 1.0)
|
493
294
|
--max_tokens MAX_TOKENS Set max response length in tokens
|
494
|
-
--log [FILE] Set filepath to log conversation to, or create a temporary log file if no path
|
495
|
-
provided
|
295
|
+
--log [FILE] Set filepath to log conversation to, or create a temporary log file if no path provided
|
496
296
|
--preprompt PREPROMPT Set custom system prompt to control AI behavior
|
497
|
-
--
|
498
|
-
|
499
|
-
|
500
|
-
|
297
|
+
--renderer {auto,rich,glow} Select which markdown renderer to use with --prettify or --stream-prettify (auto, rich, or glow)
|
298
|
+
|
299
|
+
Output Display Options (mutually exclusive)::
|
300
|
+
|
301
|
+
--no-stream Return the whole response without streaming or formatting
|
302
|
+
--prettify Render complete response with markdown and code formatting (non-streaming)
|
303
|
+
--stream-prettify Stream response with real-time markdown rendering (default)
|
501
304
|
|
502
305
|
Git Commit Message Options::
|
503
306
|
|
504
307
|
--rec-chunk Process large diffs in chunks with recursive analysis if needed
|
505
|
-
--diff [FILE] Use diff from specified file instead of staged changes. If used without a path,
|
506
|
-
uses the path from CLI config.
|
308
|
+
--diff [FILE] Use diff from specified file instead of staged changes. If used without a path, uses the path from CLI config.
|
507
309
|
--chunk-size CHUNK_SIZE Number of lines per chunk when chunking is enabled (default: 200)
|
508
|
-
--analyses-chunk-size ANALYSES_CHUNK_SIZE
|
509
|
-
Number of lines per chunk when recursively chunking analyses (default: 200)
|
310
|
+
--analyses-chunk-size ANALYSES_CHUNK_SIZE Number of lines per chunk when recursively chunking analyses (default: 200)
|
510
311
|
--max-msg-lines MAX_MSG_LINES Maximum number of lines in commit message before condensing (default: 20)
|
511
|
-
--max-recursion-depth MAX_RECURSION_DEPTH
|
512
|
-
Maximum recursion depth for commit message condensing (default: 3)
|
312
|
+
--max-recursion-depth MAX_RECURSION_DEPTH Maximum recursion depth for commit message condensing (default: 3)
|
513
313
|
|
514
314
|
Modes (mutually exclusive)::
|
515
315
|
|
@@ -517,15 +317,62 @@ Modes (mutually exclusive)::
|
|
517
317
|
-s, --shell Generate and execute shell commands
|
518
318
|
-c, --code Generate code
|
519
319
|
-t, --text Enter multi-line text input (submit with Ctrl+D)
|
520
|
-
-p, --pipe Read from stdin and use content with prompt. Use {} in prompt as placeholder
|
521
|
-
for stdin content
|
320
|
+
-p, --pipe Read from stdin and use content with prompt. Use {} in prompt as placeholder for stdin content
|
522
321
|
-r, --rewrite Rewrite text from stdin to be more natural while preserving tone and meaning
|
523
322
|
-g, --gitcommsg Generate AI-powered git commit messages from staged changes or diff file
|
524
323
|
```
|
525
324
|
|
526
325
|
> **Note**: For better visualization of conventional commit messages on GitHub, you can use the [GitHub Commit Labels](https://greasyfork.org/en/scripts/526153-github-commit-labels) userscript, which adds colorful labels to your commits.
|
527
326
|
|
528
|
-
For a complete reference of all available options, see the [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage
|
327
|
+
For a complete reference of all available options, detailed CLI examples and usage information, see the [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage/).
|
328
|
+
|
329
|
+
|
330
|
+
## Documentation
|
331
|
+
|
332
|
+
Comprehensive documentation, including usage guides and examples, is available at:
|
333
|
+
|
334
|
+
**[https://nazdridoy.github.io/ngpt/](https://nazdridoy.github.io/ngpt/)**
|
335
|
+
|
336
|
+
Key documentation sections:
|
337
|
+
- [Installation Guide](https://nazdridoy.github.io/ngpt/installation/)
|
338
|
+
- [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage/)
|
339
|
+
- [Configuration Guide](https://nazdridoy.github.io/ngpt/configuration/)
|
340
|
+
- [Examples & Tutorials](https://nazdridoy.github.io/ngpt/examples/basic/)
|
341
|
+
- [Git Commit Message Guide](https://nazdridoy.github.io/ngpt/usage/gitcommsg/)
|
342
|
+
|
343
|
+
|
344
|
+
## Configuration
|
345
|
+
|
346
|
+
### API Key Setup
|
347
|
+
|
348
|
+
#### OpenAI API Key
|
349
|
+
1. Create an account at [OpenAI](https://platform.openai.com/)
|
350
|
+
2. Navigate to API keys: https://platform.openai.com/api-keys
|
351
|
+
3. Click "Create new secret key" and copy your API key
|
352
|
+
4. Configure nGPT with your key:
|
353
|
+
```bash
|
354
|
+
ngpt --config
|
355
|
+
# Enter provider: OpenAI
|
356
|
+
# Enter API key: your-openai-api-key
|
357
|
+
# Enter base URL: https://api.openai.com/v1/
|
358
|
+
# Enter model: gpt-3.5-turbo (or other model)
|
359
|
+
```
|
360
|
+
|
361
|
+
#### Google Gemini API Key
|
362
|
+
1. Create or use an existing Google account
|
363
|
+
2. Go to [Google AI Studio](https://aistudio.google.com/)
|
364
|
+
3. Navigate to API keys in the left sidebar (or visit https://aistudio.google.com/app/apikey)
|
365
|
+
4. Create an API key and copy it
|
366
|
+
5. Configure nGPT with your key:
|
367
|
+
```bash
|
368
|
+
ngpt --config
|
369
|
+
# Enter provider: Gemini
|
370
|
+
# Enter API key: your-gemini-api-key
|
371
|
+
# Enter base URL: https://generativelanguage.googleapis.com/v1beta/openai
|
372
|
+
# Enter model: gemini-2.0-flash
|
373
|
+
```
|
374
|
+
|
375
|
+
For more detailed information, refer to the [API Key Setup documentation](https://nazdridoy.github.io/ngpt/configuration/#api-key-setup).
|
529
376
|
|
530
377
|
### CLI Configuration
|
531
378
|
|
@@ -598,7 +445,7 @@ CLI Configuration Help:
|
|
598
445
|
|
599
446
|
```
|
600
447
|
|
601
|
-
For more details, see the [CLI Configuration Guide](https://nazdridoy.github.io/ngpt/usage/cli_config
|
448
|
+
For more details, see the [CLI Configuration Guide](https://nazdridoy.github.io/ngpt/usage/cli_config/).
|
602
449
|
|
603
450
|
### Interactive Configuration
|
604
451
|
|
@@ -630,7 +477,7 @@ In interactive mode:
|
|
630
477
|
- For security, your API key is not displayed when editing configurations
|
631
478
|
- When removing a configuration, you'll be asked to confirm before deletion
|
632
479
|
|
633
|
-
For more details on configuring nGPT, see the [Configuration Guide](https://nazdridoy.github.io/ngpt/configuration
|
480
|
+
For more details on configuring nGPT, see the [Configuration Guide](https://nazdridoy.github.io/ngpt/configuration/).
|
634
481
|
|
635
482
|
### Configuration File
|
636
483
|
|
@@ -666,7 +513,7 @@ The configuration file uses a JSON list format, allowing you to store multiple c
|
|
666
513
|
]
|
667
514
|
```
|
668
515
|
|
669
|
-
For details on the configuration file format and structure, see the [Configuration Guide](https://nazdridoy.github.io/ngpt/configuration
|
516
|
+
For details on the configuration file format and structure, see the [Configuration Guide](https://nazdridoy.github.io/ngpt/configuration/).
|
670
517
|
|
671
518
|
### Configuration Priority
|
672
519
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
pkgname=ngpt
|
3
3
|
pkgver=0.0.0 # Automatically updated by CI on release
|
4
4
|
pkgrel=1
|
5
|
-
pkgdesc="Swiss army knife for LLMs: powerful CLI
|
5
|
+
pkgdesc="Swiss army knife for LLMs: powerful CLI and interactive chatbot in one package. Seamlessly work with OpenAI, Ollama, Groq, Claude, Gemini, or any OpenAI-compatible API to generate code, craft git commits, rewrite text, and execute shell commands."
|
6
6
|
arch=('any')
|
7
7
|
url="https://github.com/nazdridoy/ngpt"
|
8
8
|
license=('MIT')
|