ngpt 2.3.4__tar.gz → 2.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.
Files changed (32) hide show
  1. {ngpt-2.3.4 → ngpt-2.5.0}/PKG-INFO +27 -1
  2. {ngpt-2.3.4 → ngpt-2.5.0}/README.md +23 -0
  3. {ngpt-2.3.4 → ngpt-2.5.0}/docs/api/config.md +60 -2
  4. {ngpt-2.3.4 → ngpt-2.5.0}/docs/configuration.md +17 -3
  5. {ngpt-2.3.4 → ngpt-2.5.0}/docs/installation.md +16 -0
  6. {ngpt-2.3.4 → ngpt-2.5.0}/docs/overview.md +2 -0
  7. {ngpt-2.3.4 → ngpt-2.5.0}/docs/usage/cli_usage.md +71 -4
  8. {ngpt-2.3.4 → ngpt-2.5.0}/ngpt/cli.py +370 -39
  9. {ngpt-2.3.4 → ngpt-2.5.0}/ngpt/config.py +80 -7
  10. {ngpt-2.3.4 → ngpt-2.5.0}/pyproject.toml +5 -1
  11. {ngpt-2.3.4 → ngpt-2.5.0}/uv.lock +63 -1
  12. {ngpt-2.3.4 → ngpt-2.5.0}/.github/workflows/python-publish.yml +0 -0
  13. {ngpt-2.3.4 → ngpt-2.5.0}/.gitignore +0 -0
  14. {ngpt-2.3.4 → ngpt-2.5.0}/.python-version +0 -0
  15. {ngpt-2.3.4 → ngpt-2.5.0}/COMMIT_GUIDELINES.md +0 -0
  16. {ngpt-2.3.4 → ngpt-2.5.0}/CONTRIBUTING.md +0 -0
  17. {ngpt-2.3.4 → ngpt-2.5.0}/LICENSE +0 -0
  18. {ngpt-2.3.4 → ngpt-2.5.0}/docs/CONTRIBUTING.md +0 -0
  19. {ngpt-2.3.4 → ngpt-2.5.0}/docs/LICENSE.md +0 -0
  20. {ngpt-2.3.4 → ngpt-2.5.0}/docs/README.md +0 -0
  21. {ngpt-2.3.4 → ngpt-2.5.0}/docs/_config.yml +0 -0
  22. {ngpt-2.3.4 → ngpt-2.5.0}/docs/api/README.md +0 -0
  23. {ngpt-2.3.4 → ngpt-2.5.0}/docs/api/client.md +0 -0
  24. {ngpt-2.3.4 → ngpt-2.5.0}/docs/assets/css/style.scss +0 -0
  25. {ngpt-2.3.4 → ngpt-2.5.0}/docs/examples/README.md +0 -0
  26. {ngpt-2.3.4 → ngpt-2.5.0}/docs/examples/advanced.md +0 -0
  27. {ngpt-2.3.4 → ngpt-2.5.0}/docs/examples/basic.md +0 -0
  28. {ngpt-2.3.4 → ngpt-2.5.0}/docs/examples/integrations.md +0 -0
  29. {ngpt-2.3.4 → ngpt-2.5.0}/docs/usage/README.md +0 -0
  30. {ngpt-2.3.4 → ngpt-2.5.0}/docs/usage/library_usage.md +0 -0
  31. {ngpt-2.3.4 → ngpt-2.5.0}/ngpt/__init__.py +0 -0
  32. {ngpt-2.3.4 → ngpt-2.5.0}/ngpt/client.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ngpt
3
- Version: 2.3.4
3
+ Version: 2.5.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
@@ -30,6 +30,9 @@ Classifier: Topic :: Utilities
30
30
  Requires-Python: >=3.8
31
31
  Requires-Dist: prompt-toolkit>=3.0.0
32
32
  Requires-Dist: requests>=2.31.0
33
+ Requires-Dist: rich>=14.0.0
34
+ Provides-Extra: prettify
35
+ Requires-Dist: rich>=10.0.0; extra == 'prettify'
33
36
  Description-Content-Type: text/markdown
34
37
 
35
38
  # nGPT
@@ -76,9 +79,18 @@ ngpt -n "Tell me about quantum computing"
76
79
  # Generate code
77
80
  ngpt --code "function to calculate the Fibonacci sequence"
78
81
 
82
+ # Generate code with syntax highlighting
83
+ ngpt --code --prettify "function to calculate the Fibonacci sequence"
84
+
79
85
  # Generate and execute shell commands
80
86
  ngpt --shell "list all files in the current directory"
81
87
 
88
+ # Display markdown responses with beautiful formatting
89
+ ngpt --prettify "Explain markdown syntax with examples"
90
+
91
+ # Use a specific markdown renderer
92
+ ngpt --prettify --renderer=rich "Create a markdown table"
93
+
82
94
  # Use multiline editor for complex prompts
83
95
  ngpt --text
84
96
 
@@ -99,6 +111,7 @@ For more examples and detailed usage, visit the [CLI Usage Guide](https://nazdri
99
111
  - 💬 **Interactive Chat**: Continuous conversation with memory in modern UI
100
112
  - 📊 **Streaming Responses**: Real-time output for better user experience
101
113
  - 🔍 **Web Search**: Integrated with compatible API endpoints
114
+ - 🎨 **Markdown Rendering**: Beautiful formatting of markdown and code with syntax highlighting
102
115
  - ⚙️ **Multiple Configurations**: Cross-platform config system supporting different profiles
103
116
  - 💻 **Shell Command Generation**: OS-aware command execution
104
117
  - 🧩 **Clean Code Generation**: Output code without markdown or explanations
@@ -267,8 +280,12 @@ You can configure the client using the following options:
267
280
  | `--max_tokens` | Set maximum response length in tokens |
268
281
  | `--preprompt` | Set custom system prompt to control AI behavior |
269
282
  | `--log` | Set filepath to log conversation to (for interactive modes) |
283
+ | `--prettify` | Render markdown responses and code with syntax highlighting |
284
+ | `--renderer` | Select which markdown renderer to use with --prettify (auto, rich, or glow) |
285
+ | `--list-renderers` | Show available markdown renderers for use with --prettify |
270
286
  | `--config` | Path to a custom configuration file or, when used without a value, enters interactive configuration mode |
271
287
  | `--config-index` | Index of the configuration to use (default: 0) |
288
+ | `--provider` | Provider name to identify the configuration to use (alternative to --config-index) |
272
289
  | `--remove` | Remove the configuration at the specified index (requires --config and --config-index) |
273
290
  | `--show-config` | Show configuration details and exit |
274
291
  | `--all` | Used with `--show-config` to display all configurations |
@@ -291,8 +308,17 @@ ngpt --config
291
308
  # Edit an existing configuration at index 1
292
309
  ngpt --config --config-index 1
293
310
 
311
+ # Edit an existing configuration by provider name
312
+ ngpt --config --provider Gemini
313
+
294
314
  # Remove a configuration at index 2
295
315
  ngpt --config --remove --config-index 2
316
+
317
+ # Remove a configuration by provider name
318
+ ngpt --config --remove --provider Gemini
319
+
320
+ # Use a specific configuration by provider name
321
+ ngpt --provider OpenAI "Tell me about quantum computing"
296
322
  ```
297
323
 
298
324
  In interactive mode:
@@ -42,9 +42,18 @@ ngpt -n "Tell me about quantum computing"
42
42
  # Generate code
43
43
  ngpt --code "function to calculate the Fibonacci sequence"
44
44
 
45
+ # Generate code with syntax highlighting
46
+ ngpt --code --prettify "function to calculate the Fibonacci sequence"
47
+
45
48
  # Generate and execute shell commands
46
49
  ngpt --shell "list all files in the current directory"
47
50
 
51
+ # Display markdown responses with beautiful formatting
52
+ ngpt --prettify "Explain markdown syntax with examples"
53
+
54
+ # Use a specific markdown renderer
55
+ ngpt --prettify --renderer=rich "Create a markdown table"
56
+
48
57
  # Use multiline editor for complex prompts
49
58
  ngpt --text
50
59
 
@@ -65,6 +74,7 @@ For more examples and detailed usage, visit the [CLI Usage Guide](https://nazdri
65
74
  - 💬 **Interactive Chat**: Continuous conversation with memory in modern UI
66
75
  - 📊 **Streaming Responses**: Real-time output for better user experience
67
76
  - 🔍 **Web Search**: Integrated with compatible API endpoints
77
+ - 🎨 **Markdown Rendering**: Beautiful formatting of markdown and code with syntax highlighting
68
78
  - ⚙️ **Multiple Configurations**: Cross-platform config system supporting different profiles
69
79
  - 💻 **Shell Command Generation**: OS-aware command execution
70
80
  - 🧩 **Clean Code Generation**: Output code without markdown or explanations
@@ -233,8 +243,12 @@ You can configure the client using the following options:
233
243
  | `--max_tokens` | Set maximum response length in tokens |
234
244
  | `--preprompt` | Set custom system prompt to control AI behavior |
235
245
  | `--log` | Set filepath to log conversation to (for interactive modes) |
246
+ | `--prettify` | Render markdown responses and code with syntax highlighting |
247
+ | `--renderer` | Select which markdown renderer to use with --prettify (auto, rich, or glow) |
248
+ | `--list-renderers` | Show available markdown renderers for use with --prettify |
236
249
  | `--config` | Path to a custom configuration file or, when used without a value, enters interactive configuration mode |
237
250
  | `--config-index` | Index of the configuration to use (default: 0) |
251
+ | `--provider` | Provider name to identify the configuration to use (alternative to --config-index) |
238
252
  | `--remove` | Remove the configuration at the specified index (requires --config and --config-index) |
239
253
  | `--show-config` | Show configuration details and exit |
240
254
  | `--all` | Used with `--show-config` to display all configurations |
@@ -257,8 +271,17 @@ ngpt --config
257
271
  # Edit an existing configuration at index 1
258
272
  ngpt --config --config-index 1
259
273
 
274
+ # Edit an existing configuration by provider name
275
+ ngpt --config --provider Gemini
276
+
260
277
  # Remove a configuration at index 2
261
278
  ngpt --config --remove --config-index 2
279
+
280
+ # Remove a configuration by provider name
281
+ ngpt --config --remove --provider Gemini
282
+
283
+ # Use a specific configuration by provider name
284
+ ngpt --provider OpenAI "Tell me about quantum computing"
262
285
  ```
263
286
 
264
287
  In interactive mode:
@@ -122,7 +122,7 @@ custom_configs = load_configs("/path/to/custom/config.json")
122
122
 
123
123
  ### load_config()
124
124
 
125
- Loads a specific configuration by index and applies environment variables.
125
+ Loads a specific configuration by index or provider name and applies environment variables.
126
126
 
127
127
  ```python
128
128
  from ngpt.config import load_config
@@ -130,7 +130,8 @@ from typing import Dict, Any
130
130
 
131
131
  config: Dict[str, Any] = load_config(
132
132
  custom_path: Optional[str] = None,
133
- config_index: int = 0
133
+ config_index: int = 0,
134
+ provider: Optional[str] = None
134
135
  )
135
136
  ```
136
137
 
@@ -140,6 +141,7 @@ config: Dict[str, Any] = load_config(
140
141
  |-----------|------|---------|-------------|
141
142
  | `custom_path` | `Optional[str]` | `None` | Optional custom path to the configuration file |
142
143
  | `config_index` | `int` | `0` | Index of the configuration to load (0-based) |
144
+ | `provider` | `Optional[str]` | `None` | Provider name to identify the configuration to use (alternative to config_index) |
143
145
 
144
146
  #### Returns
145
147
 
@@ -160,6 +162,11 @@ config_1 = load_config(config_index=1)
160
162
  print(f"Using provider: {config_1.get('provider', 'Unknown')}")
161
163
  print(f"Using model: {config_1.get('model', 'Unknown')}")
162
164
 
165
+ # Load a specific configuration by provider name
166
+ gemini_config = load_config(provider="Gemini")
167
+ print(f"Using provider: {gemini_config.get('provider', 'Unknown')}")
168
+ print(f"Using model: {gemini_config.get('model', 'Unknown')}")
169
+
163
170
  # Load from a custom path
164
171
  custom_config = load_config(custom_path="/path/to/custom/config.json")
165
172
  ```
@@ -277,6 +284,57 @@ else:
277
284
  print("Failed to remove configuration")
278
285
  ```
279
286
 
287
+ ### is_provider_unique()
288
+
289
+ Checks if a provider name is unique among configurations.
290
+
291
+ ```python
292
+ from ngpt.config import is_provider_unique
293
+ from typing import List, Dict, Any, Optional
294
+
295
+ is_unique: bool = is_provider_unique(
296
+ configs: List[Dict[str, Any]],
297
+ provider: str,
298
+ exclude_index: Optional[int] = None
299
+ )
300
+ ```
301
+
302
+ #### Parameters
303
+
304
+ | Parameter | Type | Default | Description |
305
+ |-----------|------|---------|-------------|
306
+ | `configs` | `List[Dict[str, Any]]` | Required | List of configuration dictionaries |
307
+ | `provider` | `str` | Required | Provider name to check for uniqueness |
308
+ | `exclude_index` | `Optional[int]` | `None` | Optional index to exclude from the check (useful when updating an existing config) |
309
+
310
+ #### Returns
311
+
312
+ `True` if the provider name is unique among all configurations, `False` otherwise.
313
+
314
+ #### Examples
315
+
316
+ ```python
317
+ from ngpt.config import load_configs, is_provider_unique
318
+
319
+ # Load all configurations
320
+ configs = load_configs()
321
+
322
+ # Check if a provider name is unique
323
+ provider_name = "New Provider"
324
+ if is_provider_unique(configs, provider_name):
325
+ print(f"'{provider_name}' is a unique provider name")
326
+ else:
327
+ print(f"'{provider_name}' is already used by another configuration")
328
+
329
+ # Check if provider name is unique when updating an existing config
330
+ existing_idx = 1
331
+ update_provider = "Updated Provider"
332
+ if is_provider_unique(configs, update_provider, exclude_index=existing_idx):
333
+ print(f"'{update_provider}' is unique and can be used to update config at index {existing_idx}")
334
+ else:
335
+ print(f"'{update_provider}' is already used by another configuration")
336
+ ```
337
+
280
338
  ## Complete Examples
281
339
 
282
340
  ### Managing Multiple Configurations
@@ -87,8 +87,14 @@ ngpt --config
87
87
  # Edit an existing configuration at index 1
88
88
  ngpt --config --config-index 1
89
89
 
90
+ # Edit an existing configuration by provider name
91
+ ngpt --config --provider Gemini
92
+
90
93
  # Remove a configuration at index 2
91
94
  ngpt --config --remove --config-index 2
95
+
96
+ # Remove a configuration by provider name
97
+ ngpt --config --remove --provider Gemini
92
98
  ```
93
99
 
94
100
  The interactive configuration will prompt you for values and guide you through the process.
@@ -104,6 +110,9 @@ ngpt --api-key "your-key" --base-url "https://api.example.com/v1/" --model "cust
104
110
  # Select a specific configuration by index
105
111
  ngpt --config-index 2 "Your prompt here"
106
112
 
113
+ # Select a specific configuration by provider name
114
+ ngpt --provider Gemini "Your prompt here"
115
+
107
116
  # Control response generation parameters
108
117
  ngpt --temperature 0.8 --top_p 0.95 --max_tokens 300 "Write a creative story"
109
118
 
@@ -158,6 +167,11 @@ ngpt --config-index 1 "Tell me about quantum computing"
158
167
 
159
168
  # Use local Ollama (config at index 2)
160
169
  ngpt --config-index 2 "Tell me about quantum computing"
170
+
171
+ # Or use provider names instead of indices (more intuitive)
172
+ ngpt --provider OpenAI "Tell me about quantum computing"
173
+ ngpt --provider Groq "Tell me about quantum computing"
174
+ ngpt --provider Ollama-Local "Tell me about quantum computing"
161
175
  ```
162
176
 
163
177
  ### Programmatically Loading Configurations
@@ -167,12 +181,12 @@ In your Python code, you can load and use different configurations:
167
181
  ```python
168
182
  from ngpt import NGPTClient, load_config
169
183
 
170
- # Load OpenAI configuration
184
+ # Load OpenAI configuration by index
171
185
  openai_config = load_config(config_index=0)
172
186
  openai_client = NGPTClient(**openai_config)
173
187
 
174
- # Load Groq configuration
175
- groq_config = load_config(config_index=1)
188
+ # Load Groq configuration by provider name
189
+ groq_config = load_config(provider="Groq")
176
190
  groq_client = NGPTClient(**groq_config)
177
191
 
178
192
  # Use the clients
@@ -8,6 +8,10 @@ There are several ways to install nGPT depending on your needs and environment.
8
8
  - `requests` library (automatically installed as a dependency)
9
9
  - `prompt_toolkit` library (automatically installed as a dependency)
10
10
 
11
+ ## Optional Dependencies
12
+
13
+ - `rich` library - For enhanced markdown rendering with syntax highlighting
14
+
11
15
  ## Installing from PyPI (Recommended)
12
16
 
13
17
  The simplest way to install nGPT is through the Python Package Index (PyPI):
@@ -18,6 +22,18 @@ pip install ngpt
18
22
 
19
23
  This will install the latest stable release of nGPT and all its dependencies.
20
24
 
25
+ For markdown rendering capabilities, install with the prettify extra:
26
+
27
+ ```bash
28
+ pip install ngpt[prettify]
29
+ ```
30
+
31
+ Alternatively, you can install the optional dependency separately:
32
+
33
+ ```bash
34
+ pip install rich
35
+ ```
36
+
21
37
  ## Installing in a Virtual Environment
22
38
 
23
39
  It's often good practice to install Python packages in a virtual environment to avoid conflicts:
@@ -18,6 +18,8 @@ nGPT is a lightweight Python library and command-line interface (CLI) tool desig
18
18
 
19
19
  - **Web Search Integration**: Works with compatible API endpoints that support web search capabilities.
20
20
 
21
+ - **Markdown Rendering**: Beautiful formatting of markdown responses and syntax highlighting for code.
22
+
21
23
  - **Multiple Configuration Support**: Maintain different API configurations for various services or models.
22
24
 
23
25
  - **Shell Command Generation**: Generate OS-aware commands that work on your specific platform.
@@ -48,6 +48,11 @@ Here are the most commonly used options:
48
48
  | `--temperature` | Set temperature (controls randomness, default: 0.7) |
49
49
  | `--top_p` | Set top_p (controls diversity, default: 1.0) |
50
50
  | `--max_tokens` | Set maximum response length in tokens |
51
+ | `--prettify` | Render markdown responses and code with syntax highlighting |
52
+ | `--renderer` | Select which markdown renderer to use (auto, rich, or glow) |
53
+ | `--list-renderers` | Show available markdown renderers on your system |
54
+ | `--config-index` | Index of the configuration to use (default: 0) |
55
+ | `--provider` | Provider name to identify the configuration to use (alternative to --config-index) |
51
56
 
52
57
  ## Feature Details
53
58
 
@@ -138,6 +143,44 @@ This opens an editor where you can:
138
143
  - Press Ctrl+D or F10 to submit the text
139
144
  - Press Esc to cancel
140
145
 
146
+ ### Markdown Rendering
147
+
148
+ Display markdown responses with beautiful formatting and syntax highlighting:
149
+
150
+ ```bash
151
+ ngpt --prettify "Explain markdown syntax with examples"
152
+ ```
153
+
154
+ This renders the AI's response with proper markdown formatting, including:
155
+ - Syntax highlighting for code blocks
156
+ - Proper rendering of tables
157
+ - Formatted headers, lists, and other markdown elements
158
+
159
+ You can specify which markdown renderer to use:
160
+
161
+ ```bash
162
+ # Use Rich (Python library) renderer
163
+ ngpt --prettify --renderer=rich "Create a markdown table comparing programming languages"
164
+
165
+ # Use Glow (terminal-based) renderer
166
+ ngpt --prettify --renderer=glow "Write documentation with code examples"
167
+
168
+ # Use automatic selection (default is Rich if available)
169
+ ngpt --prettify --renderer=auto "Explain blockchain with code examples"
170
+ ```
171
+
172
+ Combine with code generation for syntax-highlighted code:
173
+
174
+ ```bash
175
+ ngpt -c --prettify "function to calculate the Fibonacci sequence"
176
+ ```
177
+
178
+ See available renderers on your system:
179
+
180
+ ```bash
181
+ ngpt --list-renderers
182
+ ```
183
+
141
184
  ### Using Web Search
142
185
 
143
186
  Enable web search capability (if your API endpoint supports it):
@@ -172,6 +215,12 @@ Select a specific configuration by index:
172
215
  ngpt --config-index 1 "Your prompt here"
173
216
  ```
174
217
 
218
+ Select a specific configuration by provider name:
219
+
220
+ ```bash
221
+ ngpt --provider Gemini "Your prompt here"
222
+ ```
223
+
175
224
  Specify API credentials directly:
176
225
 
177
226
  ```bash
@@ -186,18 +235,30 @@ Add a new configuration interactively:
186
235
  ngpt --config
187
236
  ```
188
237
 
189
- Edit an existing configuration:
238
+ Edit an existing configuration by index:
190
239
 
191
240
  ```bash
192
241
  ngpt --config --config-index 1
193
242
  ```
194
243
 
195
- Remove a configuration:
244
+ Edit an existing configuration by provider name:
245
+
246
+ ```bash
247
+ ngpt --config --provider Gemini
248
+ ```
249
+
250
+ Remove a configuration by index:
196
251
 
197
252
  ```bash
198
253
  ngpt --config --remove --config-index 2
199
254
  ```
200
255
 
256
+ Remove a configuration by provider name:
257
+
258
+ ```bash
259
+ ngpt --config --remove --provider Gemini
260
+ ```
261
+
201
262
  ### Model Management
202
263
 
203
264
  List all available models for the current configuration:
@@ -228,8 +289,14 @@ ngpt --model gpt-4o-mini -n "Explain quantum entanglement"
228
289
  # Interactive session with custom prompt and logging
229
290
  ngpt -i --preprompt "You are a data science tutor" --log datasci_tutoring.txt
230
291
 
231
- # Constrain output format with a custom system prompt
232
- ngpt --preprompt "Your responses should be concise and include code examples." "How to parse JSON in JavaScript?"
292
+ # Generate code with syntax highlighting
293
+ ngpt -c --prettify "create a sorting algorithm"
294
+
295
+ # Render markdown with web search for up-to-date information
296
+ ngpt --prettify --web-search "Create a markdown table of recent SpaceX launches"
297
+
298
+ # Interactive session with markdown rendering
299
+ ngpt -i --prettify --renderer=rich
233
300
  ```
234
301
 
235
302
  ### Using a Custom Configuration File