ngpt 2.11.4__tar.gz → 2.12.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.4 → ngpt-2.12.0}/CONTRIBUTING.md +1 -1
- {ngpt-2.11.4 → ngpt-2.12.0}/PKG-INFO +10 -1
- {ngpt-2.11.4 → ngpt-2.12.0}/README.md +9 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/docs/CONTRIBUTING.md +1 -1
- {ngpt-2.11.4 → ngpt-2.12.0}/docs/installation.md +13 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/docs/usage/cli_usage.md +42 -4
- {ngpt-2.11.4 → ngpt-2.12.0}/ngpt/cli/args.py +6 -1
- {ngpt-2.11.4 → ngpt-2.12.0}/ngpt/cli/main.py +7 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/ngpt/cli/modes/chat.py +36 -9
- {ngpt-2.11.4 → ngpt-2.12.0}/pyproject.toml +2 -2
- {ngpt-2.11.4 → ngpt-2.12.0}/uv.lock +1 -1
- {ngpt-2.11.4 → ngpt-2.12.0}/.github/workflows/python-publish.yml +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/.gitignore +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/.python-version +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/COMMIT_GUIDELINES.md +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/LICENSE +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/docs/LICENSE.md +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/docs/README.md +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/docs/_config.yml +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/docs/api/README.md +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/docs/api/cli.md +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/docs/api/cli_config.md +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/docs/api/client.md +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/docs/api/config.md +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/docs/assets/css/style.scss +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/docs/configuration.md +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/docs/examples/README.md +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/docs/examples/advanced.md +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/docs/examples/basic.md +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/docs/examples/cli_components.md +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/docs/examples/integrations.md +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/docs/overview.md +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/docs/usage/README.md +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/docs/usage/cli_config.md +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/docs/usage/cli_framework.md +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/docs/usage/library_usage.md +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/ngpt/__init__.py +0 -0
- /ngpt-2.11.4/ngpt/cli.py → /ngpt-2.12.0/ngpt/__main__.py +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/ngpt/cli/__init__.py +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/ngpt/cli/config_manager.py +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/ngpt/cli/formatters.py +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/ngpt/cli/interactive.py +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/ngpt/cli/modes/__init__.py +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/ngpt/cli/modes/code.py +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/ngpt/cli/modes/shell.py +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/ngpt/cli/modes/text.py +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/ngpt/cli/renderers.py +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/ngpt/cli/ui.py +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/ngpt/client.py +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/ngpt/utils/__init__.py +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/ngpt/utils/cli_config.py +0 -0
- {ngpt-2.11.4 → ngpt-2.12.0}/ngpt/utils/config.py +0 -0
- {ngpt-2.11.4 → ngpt-2.12.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`
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ngpt
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.12.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
|
@@ -79,6 +79,9 @@ uv tool install ngpt
|
|
79
79
|
# Chat with default settings
|
80
80
|
ngpt "Tell me about quantum computing"
|
81
81
|
|
82
|
+
# Alternatively, run as a Python module
|
83
|
+
python -m ngpt "Tell me about quantum computing"
|
84
|
+
|
82
85
|
# Start an interactive chat session with conversation memory
|
83
86
|
ngpt -i
|
84
87
|
|
@@ -97,6 +100,9 @@ ngpt --code --stream-prettify "function to calculate the Fibonacci sequence"
|
|
97
100
|
# Generate and execute shell commands
|
98
101
|
ngpt --shell "list all files in the current directory"
|
99
102
|
|
103
|
+
# Read from stdin and use the content in your prompt
|
104
|
+
echo "What is this text about?" | ngpt --stdin "Analyze the following text: {}"
|
105
|
+
|
100
106
|
# Display markdown responses with beautiful formatting
|
101
107
|
ngpt --prettify "Explain markdown syntax with examples"
|
102
108
|
|
@@ -117,6 +123,9 @@ ngpt --interactive --log conversation.log
|
|
117
123
|
|
118
124
|
# Create a temporary log file automatically
|
119
125
|
ngpt --log "Tell me about quantum computing"
|
126
|
+
|
127
|
+
# Process text from stdin using the {} placeholder
|
128
|
+
cat README.md | ngpt --stdin "Summarize this document: {}"
|
120
129
|
```
|
121
130
|
|
122
131
|
For more examples and detailed usage, visit the [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage.html).
|
@@ -44,6 +44,9 @@ uv tool install ngpt
|
|
44
44
|
# Chat with default settings
|
45
45
|
ngpt "Tell me about quantum computing"
|
46
46
|
|
47
|
+
# Alternatively, run as a Python module
|
48
|
+
python -m ngpt "Tell me about quantum computing"
|
49
|
+
|
47
50
|
# Start an interactive chat session with conversation memory
|
48
51
|
ngpt -i
|
49
52
|
|
@@ -62,6 +65,9 @@ ngpt --code --stream-prettify "function to calculate the Fibonacci sequence"
|
|
62
65
|
# Generate and execute shell commands
|
63
66
|
ngpt --shell "list all files in the current directory"
|
64
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
|
+
|
65
71
|
# Display markdown responses with beautiful formatting
|
66
72
|
ngpt --prettify "Explain markdown syntax with examples"
|
67
73
|
|
@@ -82,6 +88,9 @@ ngpt --interactive --log conversation.log
|
|
82
88
|
|
83
89
|
# Create a temporary log file automatically
|
84
90
|
ngpt --log "Tell me about quantum computing"
|
91
|
+
|
92
|
+
# Process text from stdin using the {} placeholder
|
93
|
+
cat README.md | ngpt --stdin "Summarize this document: {}"
|
85
94
|
```
|
86
95
|
|
87
96
|
For more examples and detailed usage, visit the [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage.html).
|
@@ -23,7 +23,7 @@ Thank you for your interest in contributing to NGPT! This document provides guid
|
|
23
23
|
|
24
24
|
- `ngpt/` - Main package directory
|
25
25
|
- `__init__.py` - Package initialization
|
26
|
-
- `
|
26
|
+
- `__main__.py` - Entry point when run as a module
|
27
27
|
- `client.py` - Client implementation for API interaction
|
28
28
|
- `cli/` - Command-line interface implementation
|
29
29
|
- `__init__.py`
|
@@ -148,6 +148,19 @@ ngpt --version
|
|
148
148
|
|
149
149
|
You should see the version number of nGPT displayed.
|
150
150
|
|
151
|
+
Alternatively, you can run nGPT as a Python module:
|
152
|
+
|
153
|
+
```bash
|
154
|
+
python -m ngpt --version
|
155
|
+
```
|
156
|
+
|
157
|
+
This method is especially useful when:
|
158
|
+
- The `ngpt` command is not in your PATH
|
159
|
+
- You're working in a virtual environment
|
160
|
+
- You want to ensure you're using the correct Python interpreter
|
161
|
+
|
162
|
+
All the functionality available through the `ngpt` command is also available through `python -m ngpt`.
|
163
|
+
|
151
164
|
## Updating nGPT
|
152
165
|
|
153
166
|
To update to the latest version:
|
@@ -48,6 +48,7 @@ Below is a comprehensive list of all available command-line options, organized b
|
|
48
48
|
| `-s, --shell` | Generate and execute shell commands appropriate for your operating system |
|
49
49
|
| `-c, --code` | Generate clean code without markdown formatting or explanations |
|
50
50
|
| `-t, --text` | Open interactive multiline editor for complex prompts with syntax highlighting |
|
51
|
+
| `--stdin` | Read from stdin and use content in your prompt with {} placeholder |
|
51
52
|
| `--no-stream` | Return the whole response without streaming (useful for scripts) |
|
52
53
|
|
53
54
|
### Configuration Management
|
@@ -247,14 +248,48 @@ ngpt -s "clean up temporary files"
|
|
247
248
|
|
248
249
|
# Network diagnostics
|
249
250
|
ngpt -s "check if port 8080 is open"
|
251
|
+
```
|
252
|
+
|
253
|
+
### Stdin Mode
|
254
|
+
|
255
|
+
Process text from standard input and incorporate it into your prompt using the `{}` placeholder:
|
256
|
+
|
257
|
+
```bash
|
258
|
+
echo "Who are you?" | ngpt --stdin "answer {}"
|
259
|
+
```
|
260
|
+
|
261
|
+
The content from stdin replaces the `{}` placeholder in your prompt. This is useful for:
|
262
|
+
|
263
|
+
1. Processing files or command output
|
264
|
+
2. Integrating nGPT into shell pipelines
|
265
|
+
3. Analyzing text from other commands
|
266
|
+
|
267
|
+
#### Examples
|
268
|
+
|
269
|
+
Analyze command output:
|
270
|
+
```bash
|
271
|
+
ls -la | ngpt --stdin "Explain what these files do based on their names: {}"
|
272
|
+
```
|
273
|
+
|
274
|
+
Analyze a log file:
|
275
|
+
```bash
|
276
|
+
cat error.log | ngpt --stdin "What's causing these errors? {}"
|
277
|
+
```
|
250
278
|
|
251
|
-
|
252
|
-
|
279
|
+
Summarize documentation:
|
280
|
+
```bash
|
281
|
+
cat README.md | ngpt --stdin "Summarize this documentation: {}"
|
282
|
+
```
|
253
283
|
|
254
|
-
|
255
|
-
|
284
|
+
Translate text from a file:
|
285
|
+
```bash
|
286
|
+
cat french_text.txt | ngpt --stdin "Translate this French text to English: {}"
|
256
287
|
```
|
257
288
|
|
289
|
+
#### Placeholder Behavior
|
290
|
+
|
291
|
+
The `{}` placeholder will be replaced with stdin content. If the placeholder is not found in your prompt, stdin content will be appended to the end of your prompt with a warning.
|
292
|
+
|
258
293
|
### Generating Code
|
259
294
|
|
260
295
|
Generate clean code without markdown or explanations:
|
@@ -744,6 +779,9 @@ If the `ngpt` command is not found after installation:
|
|
744
779
|
|
745
780
|
- Ensure Python's bin directory is in your PATH
|
746
781
|
- Try using `python -m ngpt` instead of just `ngpt`
|
782
|
+
- This works because of the package's `__main__.py` module
|
783
|
+
- It's particularly useful in virtual environments or when the command isn't in your PATH
|
784
|
+
- All the same arguments and options work with this method: `python -m ngpt -i --prettify`
|
747
785
|
|
748
786
|
## Tips and Best Practices
|
749
787
|
|
@@ -99,7 +99,8 @@ def setup_argument_parser():
|
|
99
99
|
help='Generate code')
|
100
100
|
mode_exclusive_group.add_argument('-t', '--text', action='store_true',
|
101
101
|
help='Enter multi-line text input (submit with Ctrl+D)')
|
102
|
-
|
102
|
+
mode_exclusive_group.add_argument('--stdin', action='store_true',
|
103
|
+
help='Read from stdin and use content with prompt. Use {} in prompt as placeholder for stdin content')
|
103
104
|
|
104
105
|
return parser
|
105
106
|
|
@@ -122,6 +123,10 @@ def validate_args(args):
|
|
122
123
|
if args.stream_prettify and not has_markdown_renderer('rich'):
|
123
124
|
raise ValueError("--stream-prettify requires Rich to be installed. Install with: pip install \"ngpt[full]\" or pip install rich")
|
124
125
|
|
126
|
+
# If stdin mode is used, check if input is available
|
127
|
+
if args.stdin and sys.stdin.isatty():
|
128
|
+
raise ValueError("--stdin was specified but no input is piped. Use echo 'content' | ngpt --stdin 'prompt with {}'")
|
129
|
+
|
125
130
|
return args
|
126
131
|
|
127
132
|
def validate_markdown_renderer(args):
|
@@ -542,6 +542,13 @@ def main():
|
|
542
542
|
# Text mode (multiline input)
|
543
543
|
text_mode(client, args, logger=logger)
|
544
544
|
|
545
|
+
elif args.stdin:
|
546
|
+
# Apply CLI config for stdin mode (similar to chat mode)
|
547
|
+
args = apply_cli_config(args, "all")
|
548
|
+
|
549
|
+
# Stdin mode (using the chat mode with stdin input)
|
550
|
+
chat_mode(client, args, logger=logger)
|
551
|
+
|
545
552
|
else:
|
546
553
|
# Default to chat mode
|
547
554
|
# Apply CLI config for default chat mode
|
@@ -10,16 +10,43 @@ def chat_mode(client, args, logger=None):
|
|
10
10
|
args: The parsed command-line arguments
|
11
11
|
logger: Optional logger instance
|
12
12
|
"""
|
13
|
-
#
|
14
|
-
if args.
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
# Handle stdin mode
|
14
|
+
if args.stdin:
|
15
|
+
# Read input from stdin
|
16
|
+
stdin_content = sys.stdin.read().strip()
|
17
|
+
|
18
|
+
# Get the prompt - either use provided one or ask user
|
19
|
+
if args.prompt is None:
|
20
|
+
try:
|
21
|
+
print("Enter your prompt (use {} as placeholder for stdin): ", end='')
|
22
|
+
prompt = input()
|
23
|
+
except KeyboardInterrupt:
|
24
|
+
print("\nInput cancelled by user. Exiting gracefully.")
|
25
|
+
sys.exit(130)
|
26
|
+
else:
|
27
|
+
prompt = args.prompt
|
28
|
+
|
29
|
+
# Replace the placeholder in the prompt with stdin content
|
30
|
+
placeholder = "{}"
|
31
|
+
|
32
|
+
# Check if the placeholder exists in the prompt
|
33
|
+
if placeholder not in prompt:
|
34
|
+
print(f"{COLORS['yellow']}Warning: Placeholder '{placeholder}' not found in prompt. Appending stdin content to the end.{COLORS['reset']}")
|
35
|
+
prompt = f"{prompt} {stdin_content}"
|
36
|
+
else:
|
37
|
+
prompt = prompt.replace(placeholder, stdin_content)
|
38
|
+
# Handle regular chat mode
|
21
39
|
else:
|
22
|
-
|
40
|
+
# Get the prompt
|
41
|
+
if args.prompt is None:
|
42
|
+
try:
|
43
|
+
print("Enter your prompt: ", end='')
|
44
|
+
prompt = input()
|
45
|
+
except KeyboardInterrupt:
|
46
|
+
print("\nInput cancelled by user. Exiting gracefully.")
|
47
|
+
sys.exit(130)
|
48
|
+
else:
|
49
|
+
prompt = args.prompt
|
23
50
|
|
24
51
|
# Log the user message if logging is enabled
|
25
52
|
if logger:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[project]
|
2
2
|
name = "ngpt"
|
3
|
-
version = "2.
|
3
|
+
version = "2.12.0"
|
4
4
|
description = "A lightweight Python CLI and library for interacting with OpenAI-compatible APIs, supporting both official and self-hosted LLM endpoints."
|
5
5
|
authors = [
|
6
6
|
{name = "nazDridoy", email = "nazdridoy399@gmail.com"},
|
@@ -41,7 +41,7 @@ classifiers = [
|
|
41
41
|
"Bug Tracker" = "https://github.com/nazdridoy/ngpt/issues"
|
42
42
|
|
43
43
|
[project.scripts]
|
44
|
-
ngpt = "ngpt.
|
44
|
+
ngpt = "ngpt.__main__:main"
|
45
45
|
|
46
46
|
[build-system]
|
47
47
|
requires = ["hatchling"]
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|