ngpt 2.12.0__tar.gz → 2.14.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 (58) hide show
  1. {ngpt-2.12.0 → ngpt-2.14.0}/CONTRIBUTING.md +10 -1
  2. {ngpt-2.12.0 → ngpt-2.14.0}/PKG-INFO +73 -28
  3. {ngpt-2.12.0 → ngpt-2.14.0}/README.md +71 -27
  4. {ngpt-2.12.0 → ngpt-2.14.0}/docs/CONTRIBUTING.md +12 -1
  5. {ngpt-2.12.0 → ngpt-2.14.0}/docs/api/cli.md +131 -0
  6. {ngpt-2.12.0 → ngpt-2.14.0}/docs/configuration.md +4 -0
  7. {ngpt-2.12.0 → ngpt-2.14.0}/docs/examples/cli_components.md +191 -0
  8. {ngpt-2.12.0 → ngpt-2.14.0}/docs/usage/cli_framework.md +5 -0
  9. {ngpt-2.12.0 → ngpt-2.14.0}/docs/usage/cli_usage.md +153 -1
  10. ngpt-2.14.0/docs/usage/gitcommsg.md +147 -0
  11. {ngpt-2.12.0 → ngpt-2.14.0}/ngpt/cli/args.py +17 -0
  12. {ngpt-2.12.0 → ngpt-2.14.0}/ngpt/cli/formatters.py +1 -0
  13. {ngpt-2.12.0 → ngpt-2.14.0}/ngpt/cli/main.py +28 -10
  14. ngpt-2.14.0/ngpt/cli/modes/__init__.py +8 -0
  15. ngpt-2.14.0/ngpt/cli/modes/gitcommsg.py +730 -0
  16. ngpt-2.14.0/ngpt/cli/modes/rewrite.py +209 -0
  17. {ngpt-2.12.0 → ngpt-2.14.0}/ngpt/utils/cli_config.py +6 -0
  18. ngpt-2.14.0/ngpt/utils/log.py +479 -0
  19. {ngpt-2.12.0 → ngpt-2.14.0}/pyproject.toml +2 -1
  20. {ngpt-2.12.0 → ngpt-2.14.0}/uv.lock +114 -106
  21. ngpt-2.12.0/ngpt/cli/modes/__init__.py +0 -6
  22. ngpt-2.12.0/ngpt/utils/log.py +0 -179
  23. {ngpt-2.12.0 → ngpt-2.14.0}/.github/workflows/python-publish.yml +0 -0
  24. {ngpt-2.12.0 → ngpt-2.14.0}/.gitignore +0 -0
  25. {ngpt-2.12.0 → ngpt-2.14.0}/.python-version +0 -0
  26. {ngpt-2.12.0 → ngpt-2.14.0}/COMMIT_GUIDELINES.md +0 -0
  27. {ngpt-2.12.0 → ngpt-2.14.0}/LICENSE +0 -0
  28. {ngpt-2.12.0 → ngpt-2.14.0}/docs/LICENSE.md +0 -0
  29. {ngpt-2.12.0 → ngpt-2.14.0}/docs/README.md +0 -0
  30. {ngpt-2.12.0 → ngpt-2.14.0}/docs/_config.yml +0 -0
  31. {ngpt-2.12.0 → ngpt-2.14.0}/docs/api/README.md +0 -0
  32. {ngpt-2.12.0 → ngpt-2.14.0}/docs/api/cli_config.md +0 -0
  33. {ngpt-2.12.0 → ngpt-2.14.0}/docs/api/client.md +0 -0
  34. {ngpt-2.12.0 → ngpt-2.14.0}/docs/api/config.md +0 -0
  35. {ngpt-2.12.0 → ngpt-2.14.0}/docs/assets/css/style.scss +0 -0
  36. {ngpt-2.12.0 → ngpt-2.14.0}/docs/examples/README.md +0 -0
  37. {ngpt-2.12.0 → ngpt-2.14.0}/docs/examples/advanced.md +0 -0
  38. {ngpt-2.12.0 → ngpt-2.14.0}/docs/examples/basic.md +0 -0
  39. {ngpt-2.12.0 → ngpt-2.14.0}/docs/examples/integrations.md +0 -0
  40. {ngpt-2.12.0 → ngpt-2.14.0}/docs/installation.md +0 -0
  41. {ngpt-2.12.0 → ngpt-2.14.0}/docs/overview.md +0 -0
  42. {ngpt-2.12.0 → ngpt-2.14.0}/docs/usage/README.md +0 -0
  43. {ngpt-2.12.0 → ngpt-2.14.0}/docs/usage/cli_config.md +0 -0
  44. {ngpt-2.12.0 → ngpt-2.14.0}/docs/usage/library_usage.md +0 -0
  45. {ngpt-2.12.0 → ngpt-2.14.0}/ngpt/__init__.py +0 -0
  46. {ngpt-2.12.0 → ngpt-2.14.0}/ngpt/__main__.py +0 -0
  47. {ngpt-2.12.0 → ngpt-2.14.0}/ngpt/cli/__init__.py +0 -0
  48. {ngpt-2.12.0 → ngpt-2.14.0}/ngpt/cli/config_manager.py +0 -0
  49. {ngpt-2.12.0 → ngpt-2.14.0}/ngpt/cli/interactive.py +0 -0
  50. {ngpt-2.12.0 → ngpt-2.14.0}/ngpt/cli/modes/chat.py +0 -0
  51. {ngpt-2.12.0 → ngpt-2.14.0}/ngpt/cli/modes/code.py +0 -0
  52. {ngpt-2.12.0 → ngpt-2.14.0}/ngpt/cli/modes/shell.py +0 -0
  53. {ngpt-2.12.0 → ngpt-2.14.0}/ngpt/cli/modes/text.py +0 -0
  54. {ngpt-2.12.0 → ngpt-2.14.0}/ngpt/cli/renderers.py +0 -0
  55. {ngpt-2.12.0 → ngpt-2.14.0}/ngpt/cli/ui.py +0 -0
  56. {ngpt-2.12.0 → ngpt-2.14.0}/ngpt/client.py +0 -0
  57. {ngpt-2.12.0 → ngpt-2.14.0}/ngpt/utils/__init__.py +0 -0
  58. {ngpt-2.12.0 → ngpt-2.14.0}/ngpt/utils/config.py +0 -0
@@ -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 (e.g., chat, run)
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.12.0
3
+ Version: 2.14.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
@@ -103,6 +104,33 @@ ngpt --shell "list all files in the current directory"
103
104
  # Read from stdin and use the content in your prompt
104
105
  echo "What is this text about?" | ngpt --stdin "Analyze the following text: {}"
105
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
+ # Rewrite text from a file
114
+ cat file.txt | ngpt --rewrite
115
+
116
+ # Generate AI-powered git commit messages for staged changes
117
+ ngpt --gitcommsg
118
+
119
+ # Generate commit message with context
120
+ ngpt --gitcommsg -m "type:feat"
121
+
122
+ # Process large diffs in chunks with recursive analysis
123
+ ngpt --gitcommsg -r
124
+
125
+ # Process a diff file instead of staged changes
126
+ ngpt --gitcommsg --diff /path/to/changes.diff
127
+
128
+ # Generate a commit message with logging for debugging
129
+ ngpt --gitcommsg --log commit_log.txt
130
+
131
+ # Use interactive multiline editor to enter text to rewrite
132
+ ngpt --rewrite
133
+
106
134
  # Display markdown responses with beautiful formatting
107
135
  ngpt --prettify "Explain markdown syntax with examples"
108
136
 
@@ -138,12 +166,15 @@ For more examples and detailed usage, visit the [CLI Usage Guide](https://nazdri
138
166
  - 💬 **Interactive Chat**: Continuous conversation with memory in modern UI
139
167
  - 📊 **Streaming Responses**: Real-time output for better user experience
140
168
  - 🔍 **Web Search**: Integrated with compatible API endpoints
169
+ - 📥 **Stdin Processing**: Process piped content by using `{}` placeholder in prompts
141
170
  - 🎨 **Markdown Rendering**: Beautiful formatting of markdown and code with syntax highlighting
142
171
  - ⚡ **Real-time Markdown**: Stream responses with live updating syntax highlighting and formatting
143
172
  - ⚙️ **Multiple Configurations**: Cross-platform config system supporting different profiles
144
173
  - 💻 **Shell Command Generation**: OS-aware command execution
174
+ - 🧠 **Text Rewriting**: Improve text quality while maintaining original tone and meaning
145
175
  - 🧩 **Clean Code Generation**: Output code without markdown or explanations
146
176
  - 📝 **Rich Multiline Editor**: Interactive multiline text input with syntax highlighting and intuitive controls
177
+ - 📑 **Git Commit Messages**: AI-powered generation of conventional, detailed commit messages from git diffs
147
178
  - 🎭 **System Prompts**: Customize model behavior with custom system prompts
148
179
  - 📃 **Conversation Logging**: Save your conversations to text files for later reference
149
180
  - 🧰 **CLI Components**: Reusable components for building custom AI-powered command-line tools
@@ -349,38 +380,52 @@ For detailed information about building CLI tools with nGPT, see the [CLI Framew
349
380
 
350
381
  ### Command Line Options
351
382
 
352
- You can configure the client using the following options:
383
+ You can configure nGPT using the following options:
384
+
385
+ #### Mode Options (Mutually Exclusive)
353
386
 
354
387
  | Option | Description |
355
388
  |--------|-------------|
356
- | `--api-key` | API key for the service |
357
- | `--base-url` | Base URL for the API |
358
- | `--model` | Model to use |
359
- | `--list-models` | List all available models for the selected configuration (can be combined with --config-index) |
360
- | `--web-search` | Enable web search capability |
389
+ | `-i, --interactive` | Start an interactive chat session with conversation memory and special commands |
390
+ | `-s, --shell` | Generate and execute shell commands appropriate for your operating system |
391
+ | `-c, --code` | Generate clean code without markdown formatting or explanations |
392
+ | `-t, --text` | Open interactive multiline editor for complex prompts with syntax highlighting |
393
+ | `--stdin` | Read from stdin and use content with prompt. Use {} in prompt as placeholder for stdin content |
394
+ | `--rewrite` | Rewrite text to improve quality while preserving original tone and meaning |
395
+
396
+ #### Global Options
397
+
398
+ | Option | Description |
399
+ |--------|-------------|
400
+ | `--api-key KEY` | API key for the service |
401
+ | `--base-url URL` | Base URL for the API |
402
+ | `--model MODEL` | Model to use |
403
+ | `--web-search` | Enable web search capability (if your API endpoint supports it) |
404
+ | `--temperature VALUE` | Set temperature (controls randomness, default: 0.7) |
405
+ | `--top_p VALUE` | Set top_p (controls diversity, default: 1.0) |
406
+ | `--max_tokens NUMBER` | Set maximum response length in tokens |
407
+ | `--preprompt TEXT` | Set custom system prompt to control AI behavior |
408
+ | `--language LANG` | Programming language to generate code in (for code mode, default: python) |
361
409
  | `--no-stream` | Return the whole response without streaming |
362
- | `--temperature` | Set temperature (controls randomness, default: 0.7) |
363
- | `--top_p` | Set top_p (controls diversity, default: 1.0) |
364
- | `--max_tokens` | Set maximum response length in tokens |
365
- | `--preprompt` | Set custom system prompt to control AI behavior |
366
- | `--log` | Enable logging: use `--log` to create a temporary log file, or `--log PATH` for a specific location |
367
- | `--prettify` | Render markdown responses and code with syntax highlighting |
368
- | `--stream-prettify` | Enable real-time markdown rendering with syntax highlighting while streaming |
369
- | `--renderer` | Select which markdown renderer to use with --prettify (auto, rich, or glow) |
370
- | `--list-renderers` | Show available markdown renderers for use with --prettify |
371
- | `--config` | Path to a custom configuration file or, when used without a value, enters interactive configuration mode |
372
- | `--config-index` | Index of the configuration to use (default: 0) |
373
- | `--provider` | Provider name to identify the configuration to use (alternative to --config-index) |
410
+ | `--prettify` | Render markdown responses and code with syntax highlighting and formatting |
411
+ | `--stream-prettify` | Enable streaming with markdown rendering (automatically uses Rich renderer) |
412
+ | `--renderer {auto,rich,glow}` | Select which markdown renderer to use with --prettify (default: auto) |
413
+ | `--log [FILE]` | Set filepath to log conversation to, or create a temporary log file if no path provided |
414
+
415
+ #### Configuration Options
416
+
417
+ | Option | Description |
418
+ |--------|-------------|
419
+ | `--config [PATH]` | Path to a custom config file or, if no value provided, enter interactive configuration mode |
420
+ | `--config-index INDEX` | Index of the configuration to use or edit (default: 0) |
421
+ | `--provider NAME` | Provider name to identify the configuration to use |
374
422
  | `--remove` | Remove the configuration at the specified index (requires --config and --config-index or --provider) |
375
- | `--show-config` | Show configuration details and exit |
376
- | `--all` | Used with `--show-config` to display all configurations |
377
- | `-i, --interactive` | Start an interactive chat session with stylish UI, conversation history, and special commands |
378
- | `-s, --shell` | Generate and execute shell commands |
379
- | `-c, --code` | Generate clean code output |
380
- | `-t, --text` | Open interactive multiline editor for complex prompts |
381
- | `--language` | Programming language to generate code in (for code mode, default: python) |
382
- | `--cli-config` | Manage CLI configuration settings (set, get, unset, list, help) |
383
- | `-v, --version` | Show version information |
423
+ | `--show-config` | Show the current configuration(s) and exit |
424
+ | `--all` | Show details for all configurations (requires --show-config) |
425
+ | `--list-models` | List all available models for the current configuration and exit |
426
+ | `--list-renderers` | Show available markdown renderers for use with --prettify |
427
+ | `--cli-config [COMMAND]` | Manage CLI configuration (set, get, unset, list, help) |
428
+ | `-v, --version` | Show version information and exit |
384
429
 
385
430
  For a complete reference of all available options, see the [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage.html).
386
431
 
@@ -68,6 +68,33 @@ ngpt --shell "list all files in the current directory"
68
68
  # Read from stdin and use the content in your prompt
69
69
  echo "What is this text about?" | ngpt --stdin "Analyze the following text: {}"
70
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
+ # Rewrite text from a file
78
+ cat file.txt | ngpt --rewrite
79
+
80
+ # Generate AI-powered git commit messages for staged changes
81
+ ngpt --gitcommsg
82
+
83
+ # Generate commit message with context
84
+ ngpt --gitcommsg -m "type:feat"
85
+
86
+ # Process large diffs in chunks with recursive analysis
87
+ ngpt --gitcommsg -r
88
+
89
+ # Process a diff file instead of staged changes
90
+ ngpt --gitcommsg --diff /path/to/changes.diff
91
+
92
+ # Generate a commit message with logging for debugging
93
+ ngpt --gitcommsg --log commit_log.txt
94
+
95
+ # Use interactive multiline editor to enter text to rewrite
96
+ ngpt --rewrite
97
+
71
98
  # Display markdown responses with beautiful formatting
72
99
  ngpt --prettify "Explain markdown syntax with examples"
73
100
 
@@ -103,12 +130,15 @@ For more examples and detailed usage, visit the [CLI Usage Guide](https://nazdri
103
130
  - 💬 **Interactive Chat**: Continuous conversation with memory in modern UI
104
131
  - 📊 **Streaming Responses**: Real-time output for better user experience
105
132
  - 🔍 **Web Search**: Integrated with compatible API endpoints
133
+ - 📥 **Stdin Processing**: Process piped content by using `{}` placeholder in prompts
106
134
  - 🎨 **Markdown Rendering**: Beautiful formatting of markdown and code with syntax highlighting
107
135
  - ⚡ **Real-time Markdown**: Stream responses with live updating syntax highlighting and formatting
108
136
  - ⚙️ **Multiple Configurations**: Cross-platform config system supporting different profiles
109
137
  - 💻 **Shell Command Generation**: OS-aware command execution
138
+ - 🧠 **Text Rewriting**: Improve text quality while maintaining original tone and meaning
110
139
  - 🧩 **Clean Code Generation**: Output code without markdown or explanations
111
140
  - 📝 **Rich Multiline Editor**: Interactive multiline text input with syntax highlighting and intuitive controls
141
+ - 📑 **Git Commit Messages**: AI-powered generation of conventional, detailed commit messages from git diffs
112
142
  - 🎭 **System Prompts**: Customize model behavior with custom system prompts
113
143
  - 📃 **Conversation Logging**: Save your conversations to text files for later reference
114
144
  - 🧰 **CLI Components**: Reusable components for building custom AI-powered command-line tools
@@ -314,38 +344,52 @@ For detailed information about building CLI tools with nGPT, see the [CLI Framew
314
344
 
315
345
  ### Command Line Options
316
346
 
317
- You can configure the client using the following options:
347
+ You can configure nGPT using the following options:
348
+
349
+ #### Mode Options (Mutually Exclusive)
318
350
 
319
351
  | Option | Description |
320
352
  |--------|-------------|
321
- | `--api-key` | API key for the service |
322
- | `--base-url` | Base URL for the API |
323
- | `--model` | Model to use |
324
- | `--list-models` | List all available models for the selected configuration (can be combined with --config-index) |
325
- | `--web-search` | Enable web search capability |
353
+ | `-i, --interactive` | Start an interactive chat session with conversation memory and special commands |
354
+ | `-s, --shell` | Generate and execute shell commands appropriate for your operating system |
355
+ | `-c, --code` | Generate clean code without markdown formatting or explanations |
356
+ | `-t, --text` | Open interactive multiline editor for complex prompts with syntax highlighting |
357
+ | `--stdin` | Read from stdin and use content with prompt. Use {} in prompt as placeholder for stdin content |
358
+ | `--rewrite` | Rewrite text to improve quality while preserving original tone and meaning |
359
+
360
+ #### Global Options
361
+
362
+ | Option | Description |
363
+ |--------|-------------|
364
+ | `--api-key KEY` | API key for the service |
365
+ | `--base-url URL` | Base URL for the API |
366
+ | `--model MODEL` | Model to use |
367
+ | `--web-search` | Enable web search capability (if your API endpoint supports it) |
368
+ | `--temperature VALUE` | Set temperature (controls randomness, default: 0.7) |
369
+ | `--top_p VALUE` | Set top_p (controls diversity, default: 1.0) |
370
+ | `--max_tokens NUMBER` | Set maximum response length in tokens |
371
+ | `--preprompt TEXT` | Set custom system prompt to control AI behavior |
372
+ | `--language LANG` | Programming language to generate code in (for code mode, default: python) |
326
373
  | `--no-stream` | Return the whole response without streaming |
327
- | `--temperature` | Set temperature (controls randomness, default: 0.7) |
328
- | `--top_p` | Set top_p (controls diversity, default: 1.0) |
329
- | `--max_tokens` | Set maximum response length in tokens |
330
- | `--preprompt` | Set custom system prompt to control AI behavior |
331
- | `--log` | Enable logging: use `--log` to create a temporary log file, or `--log PATH` for a specific location |
332
- | `--prettify` | Render markdown responses and code with syntax highlighting |
333
- | `--stream-prettify` | Enable real-time markdown rendering with syntax highlighting while streaming |
334
- | `--renderer` | Select which markdown renderer to use with --prettify (auto, rich, or glow) |
335
- | `--list-renderers` | Show available markdown renderers for use with --prettify |
336
- | `--config` | Path to a custom configuration file or, when used without a value, enters interactive configuration mode |
337
- | `--config-index` | Index of the configuration to use (default: 0) |
338
- | `--provider` | Provider name to identify the configuration to use (alternative to --config-index) |
374
+ | `--prettify` | Render markdown responses and code with syntax highlighting and formatting |
375
+ | `--stream-prettify` | Enable streaming with markdown rendering (automatically uses Rich renderer) |
376
+ | `--renderer {auto,rich,glow}` | Select which markdown renderer to use with --prettify (default: auto) |
377
+ | `--log [FILE]` | Set filepath to log conversation to, or create a temporary log file if no path provided |
378
+
379
+ #### Configuration Options
380
+
381
+ | Option | Description |
382
+ |--------|-------------|
383
+ | `--config [PATH]` | Path to a custom config file or, if no value provided, enter interactive configuration mode |
384
+ | `--config-index INDEX` | Index of the configuration to use or edit (default: 0) |
385
+ | `--provider NAME` | Provider name to identify the configuration to use |
339
386
  | `--remove` | Remove the configuration at the specified index (requires --config and --config-index or --provider) |
340
- | `--show-config` | Show configuration details and exit |
341
- | `--all` | Used with `--show-config` to display all configurations |
342
- | `-i, --interactive` | Start an interactive chat session with stylish UI, conversation history, and special commands |
343
- | `-s, --shell` | Generate and execute shell commands |
344
- | `-c, --code` | Generate clean code output |
345
- | `-t, --text` | Open interactive multiline editor for complex prompts |
346
- | `--language` | Programming language to generate code in (for code mode, default: python) |
347
- | `--cli-config` | Manage CLI configuration settings (set, get, unset, list, help) |
348
- | `-v, --version` | Show version information |
387
+ | `--show-config` | Show the current configuration(s) and exit |
388
+ | `--all` | Show details for all configurations (requires --show-config) |
389
+ | `--list-models` | List all available models for the current configuration and exit |
390
+ | `--list-renderers` | Show available markdown renderers for use with --prettify |
391
+ | `--cli-config [COMMAND]` | Manage CLI configuration (set, get, unset, list, help) |
392
+ | `-v, --version` | Show version information and exit |
349
393
 
350
394
  For a complete reference of all available options, see the [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage.html).
351
395
 
@@ -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
@@ -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 (e.g., chat, run)
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
 
@@ -21,6 +21,7 @@ The CLI components for nGPT are organized into a modular structure under the `ng
21
21
  - `ngpt.cli.modes.code`: Code generation mode functionality
22
22
  - `ngpt.cli.modes.shell`: Shell command generation mode functionality
23
23
  - `ngpt.cli.modes.text`: Text generation mode functionality
24
+ - `ngpt.cli.modes.rewrite`: Text rewriting mode functionality
24
25
 
25
26
  ## Interactive Chat Module
26
27
 
@@ -544,6 +545,136 @@ text_mode(
544
545
  )
545
546
  ```
546
547
 
548
+ ### Rewrite Mode
549
+
550
+ ```python
551
+ from ngpt.cli.modes.rewrite import rewrite_mode
552
+
553
+ def rewrite_mode(
554
+ client,
555
+ args,
556
+ logger=None
557
+ )
558
+ ```
559
+
560
+ Executes a text rewriting operation to improve text quality while preserving meaning and tone.
561
+
562
+ **Parameters:**
563
+ - `client` (NGPTClient): The initialized client for the operation
564
+ - `args` (namespace): Parsed command-line arguments including:
565
+ - `prompt` (str, optional): Text to rewrite from command line
566
+ - `temperature` (float): Temperature setting (0.0-1.0)
567
+ - `top_p` (float): Top-p sampling value (0.0-1.0)
568
+ - `max_tokens` (int, optional): Maximum tokens to generate
569
+ - `no_stream` (bool): Whether to disable streaming
570
+ - `prettify` (bool): Whether to prettify markdown output
571
+ - `stream_prettify` (bool): Enable real-time markdown rendering
572
+ - `renderer` (str): Markdown renderer to use
573
+ - `web_search` (bool): Whether to enable web search
574
+ - `logger` (object, optional): Logger instance
575
+
576
+ **Input Methods:**
577
+ The rewrite mode supports three input methods:
578
+ 1. Stdin (piped input): Content read from stdin if available
579
+ 2. Command-line argument: Text provided via args.prompt
580
+ 3. Multiline editor: If neither stdin nor prompt is available, opens interactive editor
581
+
582
+ **Features:**
583
+ - **Text Quality Improvement**: Fixes grammar, flow, readability while preserving meaning
584
+ - **Multiline Editor**: Interactive editor with syntax highlighting for entering text when no input is piped or provided as argument
585
+ - **Clipboard Integration**: Offers to copy rewritten text to clipboard with cross-platform support
586
+ - **Format Preservation**: Maintains original formatting including code blocks, lists, and markdown
587
+
588
+ **Example with Stdin:**
589
+ ```python
590
+ import sys
591
+ import subprocess
592
+ from ngpt import NGPTClient, load_config
593
+ from ngpt.cli.modes.rewrite import rewrite_mode
594
+ import argparse
595
+
596
+ client = NGPTClient(**load_config())
597
+
598
+ # Create args namespace with required parameters
599
+ args = argparse.Namespace()
600
+ args.prompt = None
601
+ args.temperature = 0.7
602
+ args.top_p = 1.0
603
+ args.max_tokens = None
604
+ args.no_stream = False
605
+ args.prettify = True
606
+ args.stream_prettify = False
607
+ args.renderer = 'rich'
608
+ args.web_search = False
609
+
610
+ # Redirect stdin from a string or file
611
+ original_stdin = sys.stdin
612
+ sys.stdin = open('text_to_rewrite.txt', 'r')
613
+
614
+ # Call rewrite mode
615
+ rewrite_mode(client=client, args=args)
616
+
617
+ # Restore stdin
618
+ sys.stdin = original_stdin
619
+ ```
620
+
621
+ **Example with Command-line Argument:**
622
+ ```python
623
+ from ngpt import NGPTClient, load_config
624
+ from ngpt.cli.modes.rewrite import rewrite_mode
625
+ import argparse
626
+
627
+ client = NGPTClient(**load_config())
628
+
629
+ # Create args namespace with required parameters
630
+ args = argparse.Namespace()
631
+ args.prompt = "We was hoping you could help with this issue what we are having with the server."
632
+ args.temperature = 0.7
633
+ args.top_p = 1.0
634
+ args.max_tokens = None
635
+ args.no_stream = False
636
+ args.prettify = True
637
+ args.stream_prettify = False
638
+ args.renderer = 'rich'
639
+ args.web_search = False
640
+
641
+ rewrite_mode(
642
+ client=client,
643
+ args=args
644
+ )
645
+ ```
646
+
647
+ **Example with Multiline Editor:**
648
+ ```python
649
+ from ngpt import NGPTClient, load_config
650
+ from ngpt.cli.modes.rewrite import rewrite_mode
651
+ import argparse
652
+ import sys
653
+
654
+ client = NGPTClient(**load_config())
655
+
656
+ # Create args namespace with required parameters
657
+ args = argparse.Namespace()
658
+ args.prompt = None
659
+ args.temperature = 0.7
660
+ args.top_p = 1.0
661
+ args.max_tokens = None
662
+ args.no_stream = False
663
+ args.prettify = True
664
+ args.stream_prettify = False
665
+ args.renderer = 'rich'
666
+ args.web_search = False
667
+
668
+ # Ensure stdin appears to be a TTY
669
+ # (This will trigger the multiline editor in a real terminal)
670
+ # Note: This is just to illustrate how the condition works
671
+ if sys.stdin.isatty():
672
+ print("Multiline editor will open in a real terminal")
673
+ rewrite_mode(client=client, args=args)
674
+ else:
675
+ print("This example would open a multiline editor in a real terminal")
676
+ ```
677
+
547
678
  ## Reference Tables
548
679
 
549
680
  ### 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