ngpt 2.7.2__tar.gz → 2.9.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.
Files changed (40) hide show
  1. {ngpt-2.7.2 → ngpt-2.9.0}/PKG-INFO +138 -20
  2. {ngpt-2.7.2 → ngpt-2.9.0}/README.md +135 -16
  3. {ngpt-2.7.2 → ngpt-2.9.0}/docs/README.md +12 -3
  4. ngpt-2.9.0/docs/api/cli.md +389 -0
  5. {ngpt-2.7.2 → ngpt-2.9.0}/docs/configuration.md +84 -1
  6. {ngpt-2.7.2 → ngpt-2.9.0}/docs/examples/README.md +21 -0
  7. ngpt-2.9.0/docs/examples/cli_components.md +823 -0
  8. ngpt-2.9.0/docs/installation.md +261 -0
  9. {ngpt-2.7.2 → ngpt-2.9.0}/docs/usage/README.md +40 -2
  10. ngpt-2.9.0/docs/usage/cli_config.md +146 -0
  11. ngpt-2.9.0/docs/usage/cli_framework.md +535 -0
  12. ngpt-2.9.0/docs/usage/cli_usage.md +750 -0
  13. {ngpt-2.7.2 → ngpt-2.9.0}/docs/usage/library_usage.md +168 -0
  14. ngpt-2.9.0/ngpt/__init__.py +22 -0
  15. {ngpt-2.7.2 → ngpt-2.9.0}/ngpt/cli.py +276 -48
  16. ngpt-2.9.0/ngpt/cli_config.py +247 -0
  17. {ngpt-2.7.2 → ngpt-2.9.0}/pyproject.toml +3 -7
  18. {ngpt-2.7.2 → ngpt-2.9.0}/uv.lock +4 -9
  19. ngpt-2.7.2/docs/installation.md +0 -124
  20. ngpt-2.7.2/docs/usage/cli_usage.md +0 -486
  21. ngpt-2.7.2/ngpt/__init__.py +0 -11
  22. {ngpt-2.7.2 → ngpt-2.9.0}/.github/workflows/python-publish.yml +0 -0
  23. {ngpt-2.7.2 → ngpt-2.9.0}/.gitignore +0 -0
  24. {ngpt-2.7.2 → ngpt-2.9.0}/.python-version +0 -0
  25. {ngpt-2.7.2 → ngpt-2.9.0}/COMMIT_GUIDELINES.md +0 -0
  26. {ngpt-2.7.2 → ngpt-2.9.0}/CONTRIBUTING.md +0 -0
  27. {ngpt-2.7.2 → ngpt-2.9.0}/LICENSE +0 -0
  28. {ngpt-2.7.2 → ngpt-2.9.0}/docs/CONTRIBUTING.md +0 -0
  29. {ngpt-2.7.2 → ngpt-2.9.0}/docs/LICENSE.md +0 -0
  30. {ngpt-2.7.2 → ngpt-2.9.0}/docs/_config.yml +0 -0
  31. {ngpt-2.7.2 → ngpt-2.9.0}/docs/api/README.md +0 -0
  32. {ngpt-2.7.2 → ngpt-2.9.0}/docs/api/client.md +0 -0
  33. {ngpt-2.7.2 → ngpt-2.9.0}/docs/api/config.md +0 -0
  34. {ngpt-2.7.2 → ngpt-2.9.0}/docs/assets/css/style.scss +0 -0
  35. {ngpt-2.7.2 → ngpt-2.9.0}/docs/examples/advanced.md +0 -0
  36. {ngpt-2.7.2 → ngpt-2.9.0}/docs/examples/basic.md +0 -0
  37. {ngpt-2.7.2 → ngpt-2.9.0}/docs/examples/integrations.md +0 -0
  38. {ngpt-2.7.2 → ngpt-2.9.0}/docs/overview.md +0 -0
  39. {ngpt-2.7.2 → ngpt-2.9.0}/ngpt/client.py +0 -0
  40. {ngpt-2.7.2 → ngpt-2.9.0}/ngpt/config.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ngpt
3
- Version: 2.7.2
3
+ Version: 2.9.0
4
4
  Summary: A lightweight Python CLI and library for interacting with OpenAI-compatible APIs, supporting both official and self-hosted LLM endpoints.
5
5
  Project-URL: Homepage, https://github.com/nazdridoy/ngpt
6
6
  Project-URL: Repository, https://github.com/nazdridoy/ngpt
@@ -28,10 +28,9 @@ 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: prompt-toolkit>=3.0.0
31
32
  Requires-Dist: requests>=2.31.0
32
- Provides-Extra: full
33
- Requires-Dist: prompt-toolkit>=3.0.0; extra == 'full'
34
- Requires-Dist: rich>=10.0.0; extra == 'full'
33
+ Requires-Dist: rich>=10.0.0
35
34
  Description-Content-Type: text/markdown
36
35
 
37
36
  # nGPT
@@ -43,6 +42,9 @@ Description-Content-Type: text/markdown
43
42
 
44
43
  A lightweight Python CLI and library for interacting with OpenAI-compatible APIs, supporting both official and self-hosted LLM endpoints.
45
44
 
45
+ ![2025-04-23_16-18-01](https://github.com/user-attachments/assets/b8e58926-5165-4352-b48b-9f4a982da86e)
46
+
47
+
46
48
  ## Table of Contents
47
49
  - [Quick Start](#quick-start)
48
50
  - [Features](#features)
@@ -52,8 +54,10 @@ A lightweight Python CLI and library for interacting with OpenAI-compatible APIs
52
54
  - [Documentation](https://nazdridoy.github.io/ngpt/)
53
55
  - [CLI Tool](#as-a-cli-tool)
54
56
  - [Python Library](#as-a-library)
57
+ - [CLI Framework](#as-a-cli-framework)
55
58
  - [Configuration](#configuration)
56
59
  - [Command Line Options](#command-line-options)
60
+ - [CLI Configuration](#cli-configuration)
57
61
  - [Interactive Configuration](#interactive-configuration)
58
62
  - [Configuration File](#configuration-file)
59
63
  - [Configuration Priority](#configuration-priority)
@@ -63,11 +67,14 @@ A lightweight Python CLI and library for interacting with OpenAI-compatible APIs
63
67
  ## Quick Start
64
68
 
65
69
  ```bash
66
- # Install
70
+ # Install with pip
67
71
  pip install ngpt
68
72
 
69
- # Install with additional features
70
- pip install "ngpt[full]"
73
+ # Or install with uv (faster)
74
+ uv pip install ngpt
75
+
76
+ # Or install globally as a CLI tool (recommended)
77
+ uv tool install ngpt
71
78
 
72
79
  # Chat with default settings
73
80
  ngpt "Tell me about quantum computing"
@@ -113,8 +120,8 @@ For more examples and detailed usage, visit the [CLI Usage Guide](https://nazdri
113
120
 
114
121
  ## Features
115
122
 
116
- - ✅ **Dual Mode**: Use as a CLI tool or import as a Python library
117
- - 🪶 **Lightweight**: Minimal dependencies (just `requests`)
123
+ - ✅ **Versatile**: Use as a CLI tool, Python library, or CLI framework for building custom tools
124
+ - 🪶 **Lightweight**: Minimal dependencies with everything you need included
118
125
  - 🔄 **API Flexibility**: Works with OpenAI, Ollama, Groq, and any compatible endpoint
119
126
  - 💬 **Interactive Chat**: Continuous conversation with memory in modern UI
120
127
  - 📊 **Streaming Responses**: Real-time output for better user experience
@@ -127,6 +134,7 @@ For more examples and detailed usage, visit the [CLI Usage Guide](https://nazdri
127
134
  - 📝 **Rich Multiline Editor**: Interactive multiline text input with syntax highlighting and intuitive controls
128
135
  - 🎭 **System Prompts**: Customize model behavior with custom system prompts
129
136
  - 📃 **Conversation Logging**: Save your conversations to text files for later reference
137
+ - 🧰 **CLI Components**: Reusable components for building custom AI-powered command-line tools
130
138
 
131
139
  See the [Feature Overview](https://nazdridoy.github.io/ngpt/overview.html) for more details.
132
140
 
@@ -140,25 +148,25 @@ Key documentation sections:
140
148
  - [Installation Guide](https://nazdridoy.github.io/ngpt/installation.html)
141
149
  - [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage.html)
142
150
  - [Library Usage Guide](https://nazdridoy.github.io/ngpt/usage/library_usage.html)
151
+ - [CLI Framework Guide](https://nazdridoy.github.io/ngpt/usage/cli_framework.html)
143
152
  - [Configuration Guide](https://nazdridoy.github.io/ngpt/configuration.html)
144
153
  - [Examples & Tutorials](https://nazdridoy.github.io/ngpt/examples/basic.html)
145
154
 
146
155
  ## Installation
147
156
 
148
157
  ```bash
149
- # Basic installation (minimal dependencies)
158
+ # Installation with pip
150
159
  pip install ngpt
151
160
 
152
- # Full installation with all features (recommended)
153
- pip install "ngpt[full]"
161
+ # Or install with uv (faster installation)
162
+ uv pip install ngpt
163
+
164
+ # Or install globally as a CLI tool (recommended for command-line usage)
165
+ uv tool install ngpt
154
166
  ```
155
167
 
156
168
  Requires Python 3.8 or newer.
157
169
 
158
- The full installation includes:
159
- - Enhanced markdown rendering with syntax highlighting
160
- - Improved interactive input experience with multiline editing
161
-
162
170
  For detailed installation instructions, see the [Installation Guide](https://nazdridoy.github.io/ngpt/installation.html).
163
171
 
164
172
  ## Usage
@@ -278,6 +286,47 @@ print(code)
278
286
 
279
287
  For advanced usage patterns and integrations, check out the [Advanced Examples](https://nazdridoy.github.io/ngpt/examples/advanced.html).
280
288
 
289
+ ### As a CLI Framework
290
+
291
+ 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.
292
+
293
+ ```python
294
+ from ngpt import NGPTClient, load_config
295
+ from ngpt.cli import interactive_chat_session, prettify_markdown, ColoredHelpFormatter
296
+ import argparse
297
+
298
+ # Create a custom CLI tool with colorized help
299
+ parser = argparse.ArgumentParser(
300
+ description="Specialized Code Assistant",
301
+ formatter_class=ColoredHelpFormatter
302
+ )
303
+ parser.add_argument("prompt", nargs="?", help="Code description")
304
+ parser.add_argument("--language", "-l", default="python", help="Programming language")
305
+ parser.add_argument("--interactive", "-i", action="store_true", help="Start interactive mode")
306
+ args = parser.parse_args()
307
+
308
+ # Initialize client
309
+ client = NGPTClient(**load_config())
310
+
311
+ # Use interactive session for conversation
312
+ if args.interactive:
313
+ system_prompt = f"You are an expert {args.language} developer. Provide clear, detailed answers."
314
+ interactive_chat_session(client=client, preprompt=system_prompt, prettify=True)
315
+ elif args.prompt:
316
+ # Generate and prettify code
317
+ code = client.generate_code(args.prompt, language=args.language)
318
+ print(prettify_markdown(f"```{args.language}\n{code}\n```"))
319
+ ```
320
+
321
+ This allows you to build specialized AI tools like:
322
+ - Code generators for specific languages or frameworks
323
+ - Domain-specific assistants (SQL, legal, finance, etc.)
324
+ - Documentation generators
325
+ - Translation tools
326
+ - And much more
327
+
328
+ 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).
329
+
281
330
  ## Configuration
282
331
 
283
332
  ### Command Line Options
@@ -304,17 +353,85 @@ You can configure the client using the following options:
304
353
  | `--config` | Path to a custom configuration file or, when used without a value, enters interactive configuration mode |
305
354
  | `--config-index` | Index of the configuration to use (default: 0) |
306
355
  | `--provider` | Provider name to identify the configuration to use (alternative to --config-index) |
307
- | `--remove` | Remove the configuration at the specified index (requires --config and --config-index) |
356
+ | `--remove` | Remove the configuration at the specified index (requires --config and --config-index or --provider) |
308
357
  | `--show-config` | Show configuration details and exit |
309
358
  | `--all` | Used with `--show-config` to display all configurations |
310
359
  | `-i, --interactive` | Start an interactive chat session with stylish UI, conversation history, and special commands |
311
360
  | `-s, --shell` | Generate and execute shell commands |
312
361
  | `-c, --code` | Generate clean code output |
313
362
  | `-t, --text` | Open interactive multiline editor for complex prompts |
363
+ | `--language` | Programming language to generate code in (for code mode, default: python) |
364
+ | `--cli-config` | Manage CLI configuration settings (set, get, unset, list, help) |
314
365
  | `-v, --version` | Show version information |
315
366
 
316
367
  For a complete reference of all available options, see the [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage.html).
317
368
 
369
+ ### CLI Configuration
370
+
371
+ NGPT offers a CLI configuration system that allows you to set default values for command-line options:
372
+
373
+ ```bash
374
+ # Set default options
375
+ ngpt --cli-config set language typescript
376
+ ngpt --cli-config set temperature 0.9
377
+ ngpt --cli-config set prettify true
378
+
379
+ # View current settings
380
+ ngpt --cli-config get
381
+
382
+ # Get a specific setting
383
+ ngpt --cli-config get language
384
+
385
+ # Remove a setting
386
+ ngpt --cli-config unset prettify
387
+
388
+ # List all available options
389
+ ngpt --cli-config list
390
+
391
+ # Show help information
392
+ ngpt --cli-config help
393
+ ```
394
+
395
+ Key features of CLI configuration:
396
+ - **Context-Aware**: Settings are applied based on the current command mode (e.g., `language` only applies in code generation mode `-c`).
397
+ - **Priority**: When determining option values, NGPT uses the following priority order (highest to lowest):
398
+ 1. Command-line arguments
399
+ 2. Environment variables
400
+ 3. CLI configuration (ngpt-cli.conf)
401
+ 4. Main configuration file (ngpt.conf)
402
+ 5. Default values
403
+ - **Mutual Exclusivity**: For options like `no-stream`, `prettify`, and `stream-prettify`, setting one to `True` automatically sets the others to `False` in the configuration file, ensuring consistency.
404
+ - **Smart Selection**: The `provider` setting is used to select which configuration profile to use, offering a persistent way to select your preferred API.
405
+
406
+ Available options include:
407
+ - General options (all modes): `provider`, `temperature`, `top_p`, `max_tokens`, `preprompt`, `renderer`, `config-index`, `web-search`
408
+ - Mode-specific options: `language` (code mode only), `log` (interactive and text modes)
409
+ - Mutually exclusive options: `no-stream`, `prettify`, `stream-prettify`
410
+
411
+ #### Practical Examples
412
+
413
+ ```bash
414
+ # Set Gemini as your default provider
415
+ ngpt --cli-config set provider Gemini
416
+ # Now you can run commands without specifying --provider
417
+ ngpt "Explain quantum computing"
418
+
419
+ # Configure code generation for TypeScript
420
+ ngpt --cli-config set language typescript
421
+ # Now in code mode, TypeScript will be used by default
422
+ ngpt -c "Write a function to sort an array"
423
+
424
+ # Set a higher temperature for more creative responses
425
+ ngpt --cli-config set temperature 0.9
426
+ ```
427
+
428
+ The CLI configuration is stored in:
429
+ - Linux: `~/.config/ngpt/ngpt-cli.conf`
430
+ - macOS: `~/Library/Application Support/ngpt/ngpt-cli.conf`
431
+ - Windows: `%APPDATA%\ngpt\ngpt-cli.conf`
432
+
433
+ For more details, see the [CLI Configuration Guide](https://nazdridoy.github.io/ngpt/usage/cli_config.html).
434
+
318
435
  ### Interactive Configuration
319
436
 
320
437
  The `--config` option without arguments enters interactive configuration mode, allowing you to add or edit configurations:
@@ -387,10 +504,11 @@ For details on the configuration file format and structure, see the [Configurati
387
504
 
388
505
  nGPT determines configuration values in the following order (highest priority first):
389
506
 
390
- 1. Command line arguments (`--api-key`, `--base-url`, `--model`)
507
+ 1. Command line arguments (`--api-key`, `--base-url`, `--model`, etc.)
391
508
  2. Environment variables (`OPENAI_API_KEY`, `OPENAI_BASE_URL`, `OPENAI_MODEL`)
392
- 3. Configuration file (selected by `--config-index`, defaults to index 0)
393
- 4. Default values
509
+ 3. CLI configuration file (`ngpt-cli.conf`, managed with `--cli-config`)
510
+ 4. Main configuration file `ngpt.conf` or `custom-config-file`
511
+ 5. Default values
394
512
 
395
513
  ## Contributing
396
514
 
@@ -7,6 +7,9 @@
7
7
 
8
8
  A lightweight Python CLI and library for interacting with OpenAI-compatible APIs, supporting both official and self-hosted LLM endpoints.
9
9
 
10
+ ![2025-04-23_16-18-01](https://github.com/user-attachments/assets/b8e58926-5165-4352-b48b-9f4a982da86e)
11
+
12
+
10
13
  ## Table of Contents
11
14
  - [Quick Start](#quick-start)
12
15
  - [Features](#features)
@@ -16,8 +19,10 @@ A lightweight Python CLI and library for interacting with OpenAI-compatible APIs
16
19
  - [Documentation](https://nazdridoy.github.io/ngpt/)
17
20
  - [CLI Tool](#as-a-cli-tool)
18
21
  - [Python Library](#as-a-library)
22
+ - [CLI Framework](#as-a-cli-framework)
19
23
  - [Configuration](#configuration)
20
24
  - [Command Line Options](#command-line-options)
25
+ - [CLI Configuration](#cli-configuration)
21
26
  - [Interactive Configuration](#interactive-configuration)
22
27
  - [Configuration File](#configuration-file)
23
28
  - [Configuration Priority](#configuration-priority)
@@ -27,11 +32,14 @@ A lightweight Python CLI and library for interacting with OpenAI-compatible APIs
27
32
  ## Quick Start
28
33
 
29
34
  ```bash
30
- # Install
35
+ # Install with pip
31
36
  pip install ngpt
32
37
 
33
- # Install with additional features
34
- pip install "ngpt[full]"
38
+ # Or install with uv (faster)
39
+ uv pip install ngpt
40
+
41
+ # Or install globally as a CLI tool (recommended)
42
+ uv tool install ngpt
35
43
 
36
44
  # Chat with default settings
37
45
  ngpt "Tell me about quantum computing"
@@ -77,8 +85,8 @@ For more examples and detailed usage, visit the [CLI Usage Guide](https://nazdri
77
85
 
78
86
  ## Features
79
87
 
80
- - ✅ **Dual Mode**: Use as a CLI tool or import as a Python library
81
- - 🪶 **Lightweight**: Minimal dependencies (just `requests`)
88
+ - ✅ **Versatile**: Use as a CLI tool, Python library, or CLI framework for building custom tools
89
+ - 🪶 **Lightweight**: Minimal dependencies with everything you need included
82
90
  - 🔄 **API Flexibility**: Works with OpenAI, Ollama, Groq, and any compatible endpoint
83
91
  - 💬 **Interactive Chat**: Continuous conversation with memory in modern UI
84
92
  - 📊 **Streaming Responses**: Real-time output for better user experience
@@ -91,6 +99,7 @@ For more examples and detailed usage, visit the [CLI Usage Guide](https://nazdri
91
99
  - 📝 **Rich Multiline Editor**: Interactive multiline text input with syntax highlighting and intuitive controls
92
100
  - 🎭 **System Prompts**: Customize model behavior with custom system prompts
93
101
  - 📃 **Conversation Logging**: Save your conversations to text files for later reference
102
+ - 🧰 **CLI Components**: Reusable components for building custom AI-powered command-line tools
94
103
 
95
104
  See the [Feature Overview](https://nazdridoy.github.io/ngpt/overview.html) for more details.
96
105
 
@@ -104,25 +113,25 @@ Key documentation sections:
104
113
  - [Installation Guide](https://nazdridoy.github.io/ngpt/installation.html)
105
114
  - [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage.html)
106
115
  - [Library Usage Guide](https://nazdridoy.github.io/ngpt/usage/library_usage.html)
116
+ - [CLI Framework Guide](https://nazdridoy.github.io/ngpt/usage/cli_framework.html)
107
117
  - [Configuration Guide](https://nazdridoy.github.io/ngpt/configuration.html)
108
118
  - [Examples & Tutorials](https://nazdridoy.github.io/ngpt/examples/basic.html)
109
119
 
110
120
  ## Installation
111
121
 
112
122
  ```bash
113
- # Basic installation (minimal dependencies)
123
+ # Installation with pip
114
124
  pip install ngpt
115
125
 
116
- # Full installation with all features (recommended)
117
- pip install "ngpt[full]"
126
+ # Or install with uv (faster installation)
127
+ uv pip install ngpt
128
+
129
+ # Or install globally as a CLI tool (recommended for command-line usage)
130
+ uv tool install ngpt
118
131
  ```
119
132
 
120
133
  Requires Python 3.8 or newer.
121
134
 
122
- The full installation includes:
123
- - Enhanced markdown rendering with syntax highlighting
124
- - Improved interactive input experience with multiline editing
125
-
126
135
  For detailed installation instructions, see the [Installation Guide](https://nazdridoy.github.io/ngpt/installation.html).
127
136
 
128
137
  ## Usage
@@ -242,6 +251,47 @@ print(code)
242
251
 
243
252
  For advanced usage patterns and integrations, check out the [Advanced Examples](https://nazdridoy.github.io/ngpt/examples/advanced.html).
244
253
 
254
+ ### As a CLI Framework
255
+
256
+ 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.
257
+
258
+ ```python
259
+ from ngpt import NGPTClient, load_config
260
+ from ngpt.cli import interactive_chat_session, prettify_markdown, ColoredHelpFormatter
261
+ import argparse
262
+
263
+ # Create a custom CLI tool with colorized help
264
+ parser = argparse.ArgumentParser(
265
+ description="Specialized Code Assistant",
266
+ formatter_class=ColoredHelpFormatter
267
+ )
268
+ parser.add_argument("prompt", nargs="?", help="Code description")
269
+ parser.add_argument("--language", "-l", default="python", help="Programming language")
270
+ parser.add_argument("--interactive", "-i", action="store_true", help="Start interactive mode")
271
+ args = parser.parse_args()
272
+
273
+ # Initialize client
274
+ client = NGPTClient(**load_config())
275
+
276
+ # Use interactive session for conversation
277
+ if args.interactive:
278
+ system_prompt = f"You are an expert {args.language} developer. Provide clear, detailed answers."
279
+ interactive_chat_session(client=client, preprompt=system_prompt, prettify=True)
280
+ elif args.prompt:
281
+ # Generate and prettify code
282
+ code = client.generate_code(args.prompt, language=args.language)
283
+ print(prettify_markdown(f"```{args.language}\n{code}\n```"))
284
+ ```
285
+
286
+ This allows you to build specialized AI tools like:
287
+ - Code generators for specific languages or frameworks
288
+ - Domain-specific assistants (SQL, legal, finance, etc.)
289
+ - Documentation generators
290
+ - Translation tools
291
+ - And much more
292
+
293
+ 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).
294
+
245
295
  ## Configuration
246
296
 
247
297
  ### Command Line Options
@@ -268,17 +318,85 @@ You can configure the client using the following options:
268
318
  | `--config` | Path to a custom configuration file or, when used without a value, enters interactive configuration mode |
269
319
  | `--config-index` | Index of the configuration to use (default: 0) |
270
320
  | `--provider` | Provider name to identify the configuration to use (alternative to --config-index) |
271
- | `--remove` | Remove the configuration at the specified index (requires --config and --config-index) |
321
+ | `--remove` | Remove the configuration at the specified index (requires --config and --config-index or --provider) |
272
322
  | `--show-config` | Show configuration details and exit |
273
323
  | `--all` | Used with `--show-config` to display all configurations |
274
324
  | `-i, --interactive` | Start an interactive chat session with stylish UI, conversation history, and special commands |
275
325
  | `-s, --shell` | Generate and execute shell commands |
276
326
  | `-c, --code` | Generate clean code output |
277
327
  | `-t, --text` | Open interactive multiline editor for complex prompts |
328
+ | `--language` | Programming language to generate code in (for code mode, default: python) |
329
+ | `--cli-config` | Manage CLI configuration settings (set, get, unset, list, help) |
278
330
  | `-v, --version` | Show version information |
279
331
 
280
332
  For a complete reference of all available options, see the [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage.html).
281
333
 
334
+ ### CLI Configuration
335
+
336
+ NGPT offers a CLI configuration system that allows you to set default values for command-line options:
337
+
338
+ ```bash
339
+ # Set default options
340
+ ngpt --cli-config set language typescript
341
+ ngpt --cli-config set temperature 0.9
342
+ ngpt --cli-config set prettify true
343
+
344
+ # View current settings
345
+ ngpt --cli-config get
346
+
347
+ # Get a specific setting
348
+ ngpt --cli-config get language
349
+
350
+ # Remove a setting
351
+ ngpt --cli-config unset prettify
352
+
353
+ # List all available options
354
+ ngpt --cli-config list
355
+
356
+ # Show help information
357
+ ngpt --cli-config help
358
+ ```
359
+
360
+ Key features of CLI configuration:
361
+ - **Context-Aware**: Settings are applied based on the current command mode (e.g., `language` only applies in code generation mode `-c`).
362
+ - **Priority**: When determining option values, NGPT uses the following priority order (highest to lowest):
363
+ 1. Command-line arguments
364
+ 2. Environment variables
365
+ 3. CLI configuration (ngpt-cli.conf)
366
+ 4. Main configuration file (ngpt.conf)
367
+ 5. Default values
368
+ - **Mutual Exclusivity**: For options like `no-stream`, `prettify`, and `stream-prettify`, setting one to `True` automatically sets the others to `False` in the configuration file, ensuring consistency.
369
+ - **Smart Selection**: The `provider` setting is used to select which configuration profile to use, offering a persistent way to select your preferred API.
370
+
371
+ Available options include:
372
+ - General options (all modes): `provider`, `temperature`, `top_p`, `max_tokens`, `preprompt`, `renderer`, `config-index`, `web-search`
373
+ - Mode-specific options: `language` (code mode only), `log` (interactive and text modes)
374
+ - Mutually exclusive options: `no-stream`, `prettify`, `stream-prettify`
375
+
376
+ #### Practical Examples
377
+
378
+ ```bash
379
+ # Set Gemini as your default provider
380
+ ngpt --cli-config set provider Gemini
381
+ # Now you can run commands without specifying --provider
382
+ ngpt "Explain quantum computing"
383
+
384
+ # Configure code generation for TypeScript
385
+ ngpt --cli-config set language typescript
386
+ # Now in code mode, TypeScript will be used by default
387
+ ngpt -c "Write a function to sort an array"
388
+
389
+ # Set a higher temperature for more creative responses
390
+ ngpt --cli-config set temperature 0.9
391
+ ```
392
+
393
+ The CLI configuration is stored in:
394
+ - Linux: `~/.config/ngpt/ngpt-cli.conf`
395
+ - macOS: `~/Library/Application Support/ngpt/ngpt-cli.conf`
396
+ - Windows: `%APPDATA%\ngpt\ngpt-cli.conf`
397
+
398
+ For more details, see the [CLI Configuration Guide](https://nazdridoy.github.io/ngpt/usage/cli_config.html).
399
+
282
400
  ### Interactive Configuration
283
401
 
284
402
  The `--config` option without arguments enters interactive configuration mode, allowing you to add or edit configurations:
@@ -351,10 +469,11 @@ For details on the configuration file format and structure, see the [Configurati
351
469
 
352
470
  nGPT determines configuration values in the following order (highest priority first):
353
471
 
354
- 1. Command line arguments (`--api-key`, `--base-url`, `--model`)
472
+ 1. Command line arguments (`--api-key`, `--base-url`, `--model`, etc.)
355
473
  2. Environment variables (`OPENAI_API_KEY`, `OPENAI_BASE_URL`, `OPENAI_MODEL`)
356
- 3. Configuration file (selected by `--config-index`, defaults to index 0)
357
- 4. Default values
474
+ 3. CLI configuration file (`ngpt-cli.conf`, managed with `--cli-config`)
475
+ 4. Main configuration file `ngpt.conf` or `custom-config-file`
476
+ 5. Default values
358
477
 
359
478
  ## Contributing
360
479
 
@@ -1,21 +1,28 @@
1
1
  # nGPT Documentation
2
2
 
3
- Welcome to the documentation for nGPT, a lightweight Python CLI and library for interacting with OpenAI-compatible APIs, supporting both official and self-hosted LLM endpoints.
3
+ Welcome to the documentation for nGPT, a lightweight Python CLI and library for interacting with OpenAI-compatible APIs, supporting both official and self-hosted LLM endpoints. nGPT offers three main modes of use:
4
+
5
+ - A command-line interface (CLI) tool for quick AI interactions
6
+ - A Python library for integration into your applications
7
+ - A CLI framework for building your own AI-powered command-line tools
4
8
 
5
9
  ## Table of Contents
6
10
 
7
11
  - [Overview](overview.md)
8
12
  - [Installation](installation.md)
9
13
  - [Usage](usage/README.md)
10
- - [Library Usage](usage/library_usage.md)
11
14
  - [CLI Usage](usage/cli_usage.md)
15
+ - [Library Usage](usage/library_usage.md)
16
+ - [CLI Framework](usage/cli_framework.md)
12
17
  - [API Reference](api/README.md)
13
18
  - [NGPTClient](api/client.md)
14
19
  - [Configuration](api/config.md)
20
+ - [CLI Components](api/cli.md)
15
21
  - [Examples](examples/README.md)
16
22
  - [Basic Examples](examples/basic.md)
17
23
  - [Advanced Examples](examples/advanced.md)
18
24
  - [Custom Integrations](examples/integrations.md)
25
+ - [CLI Component Examples](examples/cli_components.md)
19
26
  - [Configuration](configuration.md)
20
27
  - [Contributing](CONTRIBUTING.md)
21
28
  - [License](LICENSE.md)
@@ -24,4 +31,6 @@ Welcome to the documentation for nGPT, a lightweight Python CLI and library for
24
31
 
25
32
  For a quick start, refer to the [Installation](installation.md) and [Usage](usage/README.md) guides.
26
33
 
27
- If you're primarily interested in using nGPT as a library in your Python projects, head directly to the [Library Usage](usage/library_usage.md) guide.
34
+ If you're primarily interested in using nGPT as a library in your Python projects, head directly to the [Library Usage](usage/library_usage.md) guide.
35
+
36
+ For creating your own CLI tools using nGPT's components, check out the [CLI Framework](usage/cli_framework.md) guide and the [CLI Component Examples](examples/cli_components.md).