ngpt 2.11.5__tar.gz → 2.13.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-2.11.5 → ngpt-2.13.0}/CONTRIBUTING.md +11 -2
- {ngpt-2.11.5 → ngpt-2.13.0}/PKG-INFO +60 -28
- {ngpt-2.11.5 → ngpt-2.13.0}/README.md +58 -27
- {ngpt-2.11.5 → ngpt-2.13.0}/docs/CONTRIBUTING.md +13 -2
- {ngpt-2.11.5 → ngpt-2.13.0}/docs/api/cli.md +130 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/docs/configuration.md +4 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/docs/examples/cli_components.md +191 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/docs/usage/cli_framework.md +5 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/docs/usage/cli_usage.md +192 -5
- {ngpt-2.11.5 → ngpt-2.13.0}/ngpt/cli/args.py +8 -1
- {ngpt-2.11.5 → ngpt-2.13.0}/ngpt/cli/formatters.py +1 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/ngpt/cli/main.py +16 -1
- {ngpt-2.11.5 → ngpt-2.13.0}/ngpt/cli/modes/__init__.py +2 -1
- {ngpt-2.11.5 → ngpt-2.13.0}/ngpt/cli/modes/chat.py +36 -9
- ngpt-2.13.0/ngpt/cli/modes/rewrite.py +209 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/pyproject.toml +3 -2
- {ngpt-2.11.5 → ngpt-2.13.0}/uv.lock +114 -106
- ngpt-2.11.5/ngpt/__main__.py +0 -4
- {ngpt-2.11.5 → ngpt-2.13.0}/.github/workflows/python-publish.yml +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/.gitignore +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/.python-version +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/COMMIT_GUIDELINES.md +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/LICENSE +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/docs/LICENSE.md +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/docs/README.md +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/docs/_config.yml +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/docs/api/README.md +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/docs/api/cli_config.md +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/docs/api/client.md +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/docs/api/config.md +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/docs/assets/css/style.scss +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/docs/examples/README.md +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/docs/examples/advanced.md +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/docs/examples/basic.md +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/docs/examples/integrations.md +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/docs/installation.md +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/docs/overview.md +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/docs/usage/README.md +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/docs/usage/cli_config.md +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/docs/usage/library_usage.md +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/ngpt/__init__.py +0 -0
- /ngpt-2.11.5/ngpt/cli.py → /ngpt-2.13.0/ngpt/__main__.py +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/ngpt/cli/__init__.py +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/ngpt/cli/config_manager.py +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/ngpt/cli/interactive.py +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/ngpt/cli/modes/code.py +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/ngpt/cli/modes/shell.py +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/ngpt/cli/modes/text.py +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/ngpt/cli/renderers.py +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/ngpt/cli/ui.py +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/ngpt/client.py +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/ngpt/utils/__init__.py +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/ngpt/utils/cli_config.py +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/ngpt/utils/config.py +0 -0
- {ngpt-2.11.5 → ngpt-2.13.0}/ngpt/utils/log.py +0 -0
@@ -20,7 +20,7 @@ Thank you for your interest in contributing to NGPT! This document provides guid
|
|
20
20
|
|
21
21
|
- `ngpt/` - Main package directory
|
22
22
|
- `__init__.py` - Package initialization
|
23
|
-
- `
|
23
|
+
- `__main__.py` - Entry point when run as a module
|
24
24
|
- `client.py` - Client implementation for API interaction
|
25
25
|
- `cli/` - Command-line interface implementation
|
26
26
|
- `__init__.py`
|
@@ -29,7 +29,12 @@ Thank you for your interest in contributing to NGPT! This document provides guid
|
|
29
29
|
- `config_manager.py` - CLI configuration handling
|
30
30
|
- `formatters.py` - Output formatting logic
|
31
31
|
- `interactive.py` - Interactive mode implementation
|
32
|
-
- `modes/` - Different operational modes
|
32
|
+
- `modes/` - Different operational modes
|
33
|
+
- `chat.py` - Chat mode functionality
|
34
|
+
- `code.py` - Code generation mode
|
35
|
+
- `shell.py` - Shell command generation
|
36
|
+
- `text.py` - Text generation mode
|
37
|
+
- `rewrite.py` - Text rewriting mode
|
33
38
|
- `renderers.py` - Output rendering logic (e.g., markdown)
|
34
39
|
- `ui.py` - User interface elements (e.g., prompts, spinners)
|
35
40
|
- `utils/` - Utility modules
|
@@ -37,6 +42,10 @@ Thank you for your interest in contributing to NGPT! This document provides guid
|
|
37
42
|
- `config.py` - API endpoint and general configuration management
|
38
43
|
- `cli_config.py` - CLI-specific option configuration management
|
39
44
|
- `log.py` - Logging setup and utilities
|
45
|
+
- `docs/` - Documentation files
|
46
|
+
- `api/` - API reference documentation
|
47
|
+
- `examples/` - Example code and usage
|
48
|
+
- `usage/` - Usage guides and tutorials
|
40
49
|
- `.github/` - GitHub workflows and templates
|
41
50
|
- `pyproject.toml` - Project configuration and dependencies
|
42
51
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ngpt
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.13.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
|
@@ -29,6 +29,7 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
29
29
|
Classifier: Topic :: Utilities
|
30
30
|
Requires-Python: >=3.8
|
31
31
|
Requires-Dist: prompt-toolkit>=3.0.0
|
32
|
+
Requires-Dist: pyperclip>=1.8.0
|
32
33
|
Requires-Dist: requests>=2.31.0
|
33
34
|
Requires-Dist: rich>=10.0.0
|
34
35
|
Description-Content-Type: text/markdown
|
@@ -100,6 +101,18 @@ ngpt --code --stream-prettify "function to calculate the Fibonacci sequence"
|
|
100
101
|
# Generate and execute shell commands
|
101
102
|
ngpt --shell "list all files in the current directory"
|
102
103
|
|
104
|
+
# Read from stdin and use the content in your prompt
|
105
|
+
echo "What is this text about?" | ngpt --stdin "Analyze the following text: {}"
|
106
|
+
|
107
|
+
# Rewrite text to improve quality while preserving tone and meaning
|
108
|
+
echo "your text" | ngpt --rewrite
|
109
|
+
|
110
|
+
# Rewrite text from a command-line argument
|
111
|
+
ngpt --rewrite "your text to rewrite"
|
112
|
+
|
113
|
+
# Use interactive multiline editor to enter text to rewrite
|
114
|
+
ngpt --rewrite
|
115
|
+
|
103
116
|
# Display markdown responses with beautiful formatting
|
104
117
|
ngpt --prettify "Explain markdown syntax with examples"
|
105
118
|
|
@@ -120,6 +133,9 @@ ngpt --interactive --log conversation.log
|
|
120
133
|
|
121
134
|
# Create a temporary log file automatically
|
122
135
|
ngpt --log "Tell me about quantum computing"
|
136
|
+
|
137
|
+
# Process text from stdin using the {} placeholder
|
138
|
+
cat README.md | ngpt --stdin "Summarize this document: {}"
|
123
139
|
```
|
124
140
|
|
125
141
|
For more examples and detailed usage, visit the [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage.html).
|
@@ -132,10 +148,12 @@ For more examples and detailed usage, visit the [CLI Usage Guide](https://nazdri
|
|
132
148
|
- 💬 **Interactive Chat**: Continuous conversation with memory in modern UI
|
133
149
|
- 📊 **Streaming Responses**: Real-time output for better user experience
|
134
150
|
- 🔍 **Web Search**: Integrated with compatible API endpoints
|
151
|
+
- 📥 **Stdin Processing**: Process piped content by using `{}` placeholder in prompts
|
135
152
|
- 🎨 **Markdown Rendering**: Beautiful formatting of markdown and code with syntax highlighting
|
136
153
|
- ⚡ **Real-time Markdown**: Stream responses with live updating syntax highlighting and formatting
|
137
154
|
- ⚙️ **Multiple Configurations**: Cross-platform config system supporting different profiles
|
138
155
|
- 💻 **Shell Command Generation**: OS-aware command execution
|
156
|
+
- 🧠 **Text Rewriting**: Improve text quality while maintaining original tone and meaning
|
139
157
|
- 🧩 **Clean Code Generation**: Output code without markdown or explanations
|
140
158
|
- 📝 **Rich Multiline Editor**: Interactive multiline text input with syntax highlighting and intuitive controls
|
141
159
|
- 🎭 **System Prompts**: Customize model behavior with custom system prompts
|
@@ -343,38 +361,52 @@ For detailed information about building CLI tools with nGPT, see the [CLI Framew
|
|
343
361
|
|
344
362
|
### Command Line Options
|
345
363
|
|
346
|
-
You can configure
|
364
|
+
You can configure nGPT using the following options:
|
365
|
+
|
366
|
+
#### Mode Options (Mutually Exclusive)
|
367
|
+
|
368
|
+
| Option | Description |
|
369
|
+
|--------|-------------|
|
370
|
+
| `-i, --interactive` | Start an interactive chat session with conversation memory and special commands |
|
371
|
+
| `-s, --shell` | Generate and execute shell commands appropriate for your operating system |
|
372
|
+
| `-c, --code` | Generate clean code without markdown formatting or explanations |
|
373
|
+
| `-t, --text` | Open interactive multiline editor for complex prompts with syntax highlighting |
|
374
|
+
| `--stdin` | Read from stdin and use content with prompt. Use {} in prompt as placeholder for stdin content |
|
375
|
+
| `--rewrite` | Rewrite text to improve quality while preserving original tone and meaning |
|
376
|
+
|
377
|
+
#### Global Options
|
347
378
|
|
348
379
|
| Option | Description |
|
349
380
|
|--------|-------------|
|
350
|
-
| `--api-key` | API key for the service |
|
351
|
-
| `--base-url` | Base URL for the API |
|
352
|
-
| `--model` | Model to use |
|
353
|
-
| `--
|
354
|
-
| `--
|
381
|
+
| `--api-key KEY` | API key for the service |
|
382
|
+
| `--base-url URL` | Base URL for the API |
|
383
|
+
| `--model MODEL` | Model to use |
|
384
|
+
| `--web-search` | Enable web search capability (if your API endpoint supports it) |
|
385
|
+
| `--temperature VALUE` | Set temperature (controls randomness, default: 0.7) |
|
386
|
+
| `--top_p VALUE` | Set top_p (controls diversity, default: 1.0) |
|
387
|
+
| `--max_tokens NUMBER` | Set maximum response length in tokens |
|
388
|
+
| `--preprompt TEXT` | Set custom system prompt to control AI behavior |
|
389
|
+
| `--language LANG` | Programming language to generate code in (for code mode, default: python) |
|
355
390
|
| `--no-stream` | Return the whole response without streaming |
|
356
|
-
| `--
|
357
|
-
| `--
|
358
|
-
| `--
|
359
|
-
| `--
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
|
364
|
-
|
365
|
-
| `--config` | Path to a custom
|
366
|
-
| `--config-index` | Index of the configuration to use (default: 0) |
|
367
|
-
| `--provider` | Provider name to identify the configuration to use
|
391
|
+
| `--prettify` | Render markdown responses and code with syntax highlighting and formatting |
|
392
|
+
| `--stream-prettify` | Enable streaming with markdown rendering (automatically uses Rich renderer) |
|
393
|
+
| `--renderer {auto,rich,glow}` | Select which markdown renderer to use with --prettify (default: auto) |
|
394
|
+
| `--log [FILE]` | Set filepath to log conversation to, or create a temporary log file if no path provided |
|
395
|
+
|
396
|
+
#### Configuration Options
|
397
|
+
|
398
|
+
| Option | Description |
|
399
|
+
|--------|-------------|
|
400
|
+
| `--config [PATH]` | Path to a custom config file or, if no value provided, enter interactive configuration mode |
|
401
|
+
| `--config-index INDEX` | Index of the configuration to use or edit (default: 0) |
|
402
|
+
| `--provider NAME` | Provider name to identify the configuration to use |
|
368
403
|
| `--remove` | Remove the configuration at the specified index (requires --config and --config-index or --provider) |
|
369
|
-
| `--show-config` | Show configuration
|
370
|
-
| `--all` |
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
| `-
|
375
|
-
| `--language` | Programming language to generate code in (for code mode, default: python) |
|
376
|
-
| `--cli-config` | Manage CLI configuration settings (set, get, unset, list, help) |
|
377
|
-
| `-v, --version` | Show version information |
|
404
|
+
| `--show-config` | Show the current configuration(s) and exit |
|
405
|
+
| `--all` | Show details for all configurations (requires --show-config) |
|
406
|
+
| `--list-models` | List all available models for the current configuration and exit |
|
407
|
+
| `--list-renderers` | Show available markdown renderers for use with --prettify |
|
408
|
+
| `--cli-config [COMMAND]` | Manage CLI configuration (set, get, unset, list, help) |
|
409
|
+
| `-v, --version` | Show version information and exit |
|
378
410
|
|
379
411
|
For a complete reference of all available options, see the [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage.html).
|
380
412
|
|
@@ -65,6 +65,18 @@ ngpt --code --stream-prettify "function to calculate the Fibonacci sequence"
|
|
65
65
|
# Generate and execute shell commands
|
66
66
|
ngpt --shell "list all files in the current directory"
|
67
67
|
|
68
|
+
# Read from stdin and use the content in your prompt
|
69
|
+
echo "What is this text about?" | ngpt --stdin "Analyze the following text: {}"
|
70
|
+
|
71
|
+
# Rewrite text to improve quality while preserving tone and meaning
|
72
|
+
echo "your text" | ngpt --rewrite
|
73
|
+
|
74
|
+
# Rewrite text from a command-line argument
|
75
|
+
ngpt --rewrite "your text to rewrite"
|
76
|
+
|
77
|
+
# Use interactive multiline editor to enter text to rewrite
|
78
|
+
ngpt --rewrite
|
79
|
+
|
68
80
|
# Display markdown responses with beautiful formatting
|
69
81
|
ngpt --prettify "Explain markdown syntax with examples"
|
70
82
|
|
@@ -85,6 +97,9 @@ ngpt --interactive --log conversation.log
|
|
85
97
|
|
86
98
|
# Create a temporary log file automatically
|
87
99
|
ngpt --log "Tell me about quantum computing"
|
100
|
+
|
101
|
+
# Process text from stdin using the {} placeholder
|
102
|
+
cat README.md | ngpt --stdin "Summarize this document: {}"
|
88
103
|
```
|
89
104
|
|
90
105
|
For more examples and detailed usage, visit the [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage.html).
|
@@ -97,10 +112,12 @@ For more examples and detailed usage, visit the [CLI Usage Guide](https://nazdri
|
|
97
112
|
- 💬 **Interactive Chat**: Continuous conversation with memory in modern UI
|
98
113
|
- 📊 **Streaming Responses**: Real-time output for better user experience
|
99
114
|
- 🔍 **Web Search**: Integrated with compatible API endpoints
|
115
|
+
- 📥 **Stdin Processing**: Process piped content by using `{}` placeholder in prompts
|
100
116
|
- 🎨 **Markdown Rendering**: Beautiful formatting of markdown and code with syntax highlighting
|
101
117
|
- ⚡ **Real-time Markdown**: Stream responses with live updating syntax highlighting and formatting
|
102
118
|
- ⚙️ **Multiple Configurations**: Cross-platform config system supporting different profiles
|
103
119
|
- 💻 **Shell Command Generation**: OS-aware command execution
|
120
|
+
- 🧠 **Text Rewriting**: Improve text quality while maintaining original tone and meaning
|
104
121
|
- 🧩 **Clean Code Generation**: Output code without markdown or explanations
|
105
122
|
- 📝 **Rich Multiline Editor**: Interactive multiline text input with syntax highlighting and intuitive controls
|
106
123
|
- 🎭 **System Prompts**: Customize model behavior with custom system prompts
|
@@ -308,38 +325,52 @@ For detailed information about building CLI tools with nGPT, see the [CLI Framew
|
|
308
325
|
|
309
326
|
### Command Line Options
|
310
327
|
|
311
|
-
You can configure
|
328
|
+
You can configure nGPT using the following options:
|
329
|
+
|
330
|
+
#### Mode Options (Mutually Exclusive)
|
331
|
+
|
332
|
+
| Option | Description |
|
333
|
+
|--------|-------------|
|
334
|
+
| `-i, --interactive` | Start an interactive chat session with conversation memory and special commands |
|
335
|
+
| `-s, --shell` | Generate and execute shell commands appropriate for your operating system |
|
336
|
+
| `-c, --code` | Generate clean code without markdown formatting or explanations |
|
337
|
+
| `-t, --text` | Open interactive multiline editor for complex prompts with syntax highlighting |
|
338
|
+
| `--stdin` | Read from stdin and use content with prompt. Use {} in prompt as placeholder for stdin content |
|
339
|
+
| `--rewrite` | Rewrite text to improve quality while preserving original tone and meaning |
|
340
|
+
|
341
|
+
#### Global Options
|
312
342
|
|
313
343
|
| Option | Description |
|
314
344
|
|--------|-------------|
|
315
|
-
| `--api-key` | API key for the service |
|
316
|
-
| `--base-url` | Base URL for the API |
|
317
|
-
| `--model` | Model to use |
|
318
|
-
| `--
|
319
|
-
| `--
|
345
|
+
| `--api-key KEY` | API key for the service |
|
346
|
+
| `--base-url URL` | Base URL for the API |
|
347
|
+
| `--model MODEL` | Model to use |
|
348
|
+
| `--web-search` | Enable web search capability (if your API endpoint supports it) |
|
349
|
+
| `--temperature VALUE` | Set temperature (controls randomness, default: 0.7) |
|
350
|
+
| `--top_p VALUE` | Set top_p (controls diversity, default: 1.0) |
|
351
|
+
| `--max_tokens NUMBER` | Set maximum response length in tokens |
|
352
|
+
| `--preprompt TEXT` | Set custom system prompt to control AI behavior |
|
353
|
+
| `--language LANG` | Programming language to generate code in (for code mode, default: python) |
|
320
354
|
| `--no-stream` | Return the whole response without streaming |
|
321
|
-
| `--
|
322
|
-
| `--
|
323
|
-
| `--
|
324
|
-
| `--
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
|
329
|
-
|
330
|
-
| `--config` | Path to a custom
|
331
|
-
| `--config-index` | Index of the configuration to use (default: 0) |
|
332
|
-
| `--provider` | Provider name to identify the configuration to use
|
355
|
+
| `--prettify` | Render markdown responses and code with syntax highlighting and formatting |
|
356
|
+
| `--stream-prettify` | Enable streaming with markdown rendering (automatically uses Rich renderer) |
|
357
|
+
| `--renderer {auto,rich,glow}` | Select which markdown renderer to use with --prettify (default: auto) |
|
358
|
+
| `--log [FILE]` | Set filepath to log conversation to, or create a temporary log file if no path provided |
|
359
|
+
|
360
|
+
#### Configuration Options
|
361
|
+
|
362
|
+
| Option | Description |
|
363
|
+
|--------|-------------|
|
364
|
+
| `--config [PATH]` | Path to a custom config file or, if no value provided, enter interactive configuration mode |
|
365
|
+
| `--config-index INDEX` | Index of the configuration to use or edit (default: 0) |
|
366
|
+
| `--provider NAME` | Provider name to identify the configuration to use |
|
333
367
|
| `--remove` | Remove the configuration at the specified index (requires --config and --config-index or --provider) |
|
334
|
-
| `--show-config` | Show configuration
|
335
|
-
| `--all` |
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
| `-
|
340
|
-
| `--language` | Programming language to generate code in (for code mode, default: python) |
|
341
|
-
| `--cli-config` | Manage CLI configuration settings (set, get, unset, list, help) |
|
342
|
-
| `-v, --version` | Show version information |
|
368
|
+
| `--show-config` | Show the current configuration(s) and exit |
|
369
|
+
| `--all` | Show details for all configurations (requires --show-config) |
|
370
|
+
| `--list-models` | List all available models for the current configuration and exit |
|
371
|
+
| `--list-renderers` | Show available markdown renderers for use with --prettify |
|
372
|
+
| `--cli-config [COMMAND]` | Manage CLI configuration (set, get, unset, list, help) |
|
373
|
+
| `-v, --version` | Show version information and exit |
|
343
374
|
|
344
375
|
For a complete reference of all available options, see the [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage.html).
|
345
376
|
|
@@ -1,4 +1,6 @@
|
|
1
1
|
---
|
2
|
+
title: Contributing to NGPT
|
3
|
+
description: Guidelines and instructions for contributing to the NGPT project
|
2
4
|
---
|
3
5
|
|
4
6
|
# Contributing to NGPT
|
@@ -23,7 +25,7 @@ Thank you for your interest in contributing to NGPT! This document provides guid
|
|
23
25
|
|
24
26
|
- `ngpt/` - Main package directory
|
25
27
|
- `__init__.py` - Package initialization
|
26
|
-
- `
|
28
|
+
- `__main__.py` - Entry point when run as a module
|
27
29
|
- `client.py` - Client implementation for API interaction
|
28
30
|
- `cli/` - Command-line interface implementation
|
29
31
|
- `__init__.py`
|
@@ -32,7 +34,12 @@ Thank you for your interest in contributing to NGPT! This document provides guid
|
|
32
34
|
- `config_manager.py` - CLI configuration handling
|
33
35
|
- `formatters.py` - Output formatting logic
|
34
36
|
- `interactive.py` - Interactive mode implementation
|
35
|
-
- `modes/` - Different operational modes
|
37
|
+
- `modes/` - Different operational modes
|
38
|
+
- `chat.py` - Chat mode functionality
|
39
|
+
- `code.py` - Code generation mode
|
40
|
+
- `shell.py` - Shell command generation
|
41
|
+
- `text.py` - Text generation mode
|
42
|
+
- `rewrite.py` - Text rewriting mode
|
36
43
|
- `renderers.py` - Output rendering logic (e.g., markdown)
|
37
44
|
- `ui.py` - User interface elements (e.g., prompts, spinners)
|
38
45
|
- `utils/` - Utility modules
|
@@ -40,6 +47,10 @@ Thank you for your interest in contributing to NGPT! This document provides guid
|
|
40
47
|
- `config.py` - API endpoint and general configuration management
|
41
48
|
- `cli_config.py` - CLI-specific option configuration management
|
42
49
|
- `log.py` - Logging setup and utilities
|
50
|
+
- `docs/` - Documentation files
|
51
|
+
- `api/` - API reference documentation
|
52
|
+
- `examples/` - Example code and usage
|
53
|
+
- `usage/` - Usage guides and tutorials
|
43
54
|
- `.github/` - GitHub workflows and templates
|
44
55
|
- `pyproject.toml` - Project configuration and dependencies
|
45
56
|
|
@@ -544,6 +544,136 @@ text_mode(
|
|
544
544
|
)
|
545
545
|
```
|
546
546
|
|
547
|
+
### Rewrite Mode
|
548
|
+
|
549
|
+
```python
|
550
|
+
from ngpt.cli.modes.rewrite import rewrite_mode
|
551
|
+
|
552
|
+
def rewrite_mode(
|
553
|
+
client,
|
554
|
+
args,
|
555
|
+
logger=None
|
556
|
+
)
|
557
|
+
```
|
558
|
+
|
559
|
+
Executes a text rewriting operation to improve text quality while preserving meaning and tone.
|
560
|
+
|
561
|
+
**Parameters:**
|
562
|
+
- `client` (NGPTClient): The initialized client for the operation
|
563
|
+
- `args` (namespace): Parsed command-line arguments including:
|
564
|
+
- `prompt` (str, optional): Text to rewrite from command line
|
565
|
+
- `temperature` (float): Temperature setting (0.0-1.0)
|
566
|
+
- `top_p` (float): Top-p sampling value (0.0-1.0)
|
567
|
+
- `max_tokens` (int, optional): Maximum tokens to generate
|
568
|
+
- `no_stream` (bool): Whether to disable streaming
|
569
|
+
- `prettify` (bool): Whether to prettify markdown output
|
570
|
+
- `stream_prettify` (bool): Enable real-time markdown rendering
|
571
|
+
- `renderer` (str): Markdown renderer to use
|
572
|
+
- `web_search` (bool): Whether to enable web search
|
573
|
+
- `logger` (object, optional): Logger instance
|
574
|
+
|
575
|
+
**Input Methods:**
|
576
|
+
The rewrite mode supports three input methods:
|
577
|
+
1. Stdin (piped input): Content read from stdin if available
|
578
|
+
2. Command-line argument: Text provided via args.prompt
|
579
|
+
3. Multiline editor: If neither stdin nor prompt is available, opens interactive editor
|
580
|
+
|
581
|
+
**Features:**
|
582
|
+
- **Text Quality Improvement**: Fixes grammar, flow, readability while preserving meaning
|
583
|
+
- **Multiline Editor**: Interactive editor with syntax highlighting for entering text when no input is piped or provided as argument
|
584
|
+
- **Clipboard Integration**: Offers to copy rewritten text to clipboard with cross-platform support
|
585
|
+
- **Format Preservation**: Maintains original formatting including code blocks, lists, and markdown
|
586
|
+
|
587
|
+
**Example with Stdin:**
|
588
|
+
```python
|
589
|
+
import sys
|
590
|
+
import subprocess
|
591
|
+
from ngpt import NGPTClient, load_config
|
592
|
+
from ngpt.cli.modes.rewrite import rewrite_mode
|
593
|
+
import argparse
|
594
|
+
|
595
|
+
client = NGPTClient(**load_config())
|
596
|
+
|
597
|
+
# Create args namespace with required parameters
|
598
|
+
args = argparse.Namespace()
|
599
|
+
args.prompt = None
|
600
|
+
args.temperature = 0.7
|
601
|
+
args.top_p = 1.0
|
602
|
+
args.max_tokens = None
|
603
|
+
args.no_stream = False
|
604
|
+
args.prettify = True
|
605
|
+
args.stream_prettify = False
|
606
|
+
args.renderer = 'rich'
|
607
|
+
args.web_search = False
|
608
|
+
|
609
|
+
# Redirect stdin from a string or file
|
610
|
+
original_stdin = sys.stdin
|
611
|
+
sys.stdin = open('text_to_rewrite.txt', 'r')
|
612
|
+
|
613
|
+
# Call rewrite mode
|
614
|
+
rewrite_mode(client=client, args=args)
|
615
|
+
|
616
|
+
# Restore stdin
|
617
|
+
sys.stdin = original_stdin
|
618
|
+
```
|
619
|
+
|
620
|
+
**Example with Command-line Argument:**
|
621
|
+
```python
|
622
|
+
from ngpt import NGPTClient, load_config
|
623
|
+
from ngpt.cli.modes.rewrite import rewrite_mode
|
624
|
+
import argparse
|
625
|
+
|
626
|
+
client = NGPTClient(**load_config())
|
627
|
+
|
628
|
+
# Create args namespace with required parameters
|
629
|
+
args = argparse.Namespace()
|
630
|
+
args.prompt = "We was hoping you could help with this issue what we are having with the server."
|
631
|
+
args.temperature = 0.7
|
632
|
+
args.top_p = 1.0
|
633
|
+
args.max_tokens = None
|
634
|
+
args.no_stream = False
|
635
|
+
args.prettify = True
|
636
|
+
args.stream_prettify = False
|
637
|
+
args.renderer = 'rich'
|
638
|
+
args.web_search = False
|
639
|
+
|
640
|
+
rewrite_mode(
|
641
|
+
client=client,
|
642
|
+
args=args
|
643
|
+
)
|
644
|
+
```
|
645
|
+
|
646
|
+
**Example with Multiline Editor:**
|
647
|
+
```python
|
648
|
+
from ngpt import NGPTClient, load_config
|
649
|
+
from ngpt.cli.modes.rewrite import rewrite_mode
|
650
|
+
import argparse
|
651
|
+
import sys
|
652
|
+
|
653
|
+
client = NGPTClient(**load_config())
|
654
|
+
|
655
|
+
# Create args namespace with required parameters
|
656
|
+
args = argparse.Namespace()
|
657
|
+
args.prompt = None
|
658
|
+
args.temperature = 0.7
|
659
|
+
args.top_p = 1.0
|
660
|
+
args.max_tokens = None
|
661
|
+
args.no_stream = False
|
662
|
+
args.prettify = True
|
663
|
+
args.stream_prettify = False
|
664
|
+
args.renderer = 'rich'
|
665
|
+
args.web_search = False
|
666
|
+
|
667
|
+
# Ensure stdin appears to be a TTY
|
668
|
+
# (This will trigger the multiline editor in a real terminal)
|
669
|
+
# Note: This is just to illustrate how the condition works
|
670
|
+
if sys.stdin.isatty():
|
671
|
+
print("Multiline editor will open in a real terminal")
|
672
|
+
rewrite_mode(client=client, args=args)
|
673
|
+
else:
|
674
|
+
print("This example would open a multiline editor in a real terminal")
|
675
|
+
```
|
676
|
+
|
547
677
|
## Reference Tables
|
548
678
|
|
549
679
|
### Markdown Renderers
|
@@ -124,6 +124,7 @@ You can also set configuration options directly via command-line arguments:
|
|
124
124
|
- `-c, --code`: Generate code.
|
125
125
|
- `--language <lang>`: Specify the programming language for code generation (e.g., `python`, `javascript`, default: `python`).
|
126
126
|
- `-t, --text`: Use a multiline editor for input.
|
127
|
+
- `--stdin`: Read from stdin and use content in your prompt with {} placeholder.
|
127
128
|
- `--no-stream`: Disable streaming output.
|
128
129
|
- `--prettify`: Enable formatted markdown/code output (disables streaming).
|
129
130
|
- `--renderer <name>`: Choose the renderer (`auto`, `rich`, `glow`).
|
@@ -162,6 +163,9 @@ ngpt --interactive --log conversation.log
|
|
162
163
|
|
163
164
|
# Create a temporary log file automatically
|
164
165
|
ngpt --log "Tell me about quantum computing"
|
166
|
+
|
167
|
+
# Process text from stdin using the {} placeholder
|
168
|
+
echo "What is this text about?" | ngpt --stdin "Analyze the following text: {}"
|
165
169
|
```
|
166
170
|
|
167
171
|
## Environment Variables
|