ngpt 2.11.5__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.
Files changed (54) hide show
  1. {ngpt-2.11.5 → ngpt-2.12.0}/CONTRIBUTING.md +1 -1
  2. {ngpt-2.11.5 → ngpt-2.12.0}/PKG-INFO +7 -1
  3. {ngpt-2.11.5 → ngpt-2.12.0}/README.md +6 -0
  4. {ngpt-2.11.5 → ngpt-2.12.0}/docs/CONTRIBUTING.md +1 -1
  5. {ngpt-2.11.5 → ngpt-2.12.0}/docs/usage/cli_usage.md +39 -4
  6. {ngpt-2.11.5 → ngpt-2.12.0}/ngpt/cli/args.py +6 -1
  7. {ngpt-2.11.5 → ngpt-2.12.0}/ngpt/cli/main.py +7 -0
  8. {ngpt-2.11.5 → ngpt-2.12.0}/ngpt/cli/modes/chat.py +36 -9
  9. {ngpt-2.11.5 → ngpt-2.12.0}/pyproject.toml +2 -2
  10. {ngpt-2.11.5 → ngpt-2.12.0}/uv.lock +1 -1
  11. ngpt-2.11.5/ngpt/__main__.py +0 -4
  12. {ngpt-2.11.5 → ngpt-2.12.0}/.github/workflows/python-publish.yml +0 -0
  13. {ngpt-2.11.5 → ngpt-2.12.0}/.gitignore +0 -0
  14. {ngpt-2.11.5 → ngpt-2.12.0}/.python-version +0 -0
  15. {ngpt-2.11.5 → ngpt-2.12.0}/COMMIT_GUIDELINES.md +0 -0
  16. {ngpt-2.11.5 → ngpt-2.12.0}/LICENSE +0 -0
  17. {ngpt-2.11.5 → ngpt-2.12.0}/docs/LICENSE.md +0 -0
  18. {ngpt-2.11.5 → ngpt-2.12.0}/docs/README.md +0 -0
  19. {ngpt-2.11.5 → ngpt-2.12.0}/docs/_config.yml +0 -0
  20. {ngpt-2.11.5 → ngpt-2.12.0}/docs/api/README.md +0 -0
  21. {ngpt-2.11.5 → ngpt-2.12.0}/docs/api/cli.md +0 -0
  22. {ngpt-2.11.5 → ngpt-2.12.0}/docs/api/cli_config.md +0 -0
  23. {ngpt-2.11.5 → ngpt-2.12.0}/docs/api/client.md +0 -0
  24. {ngpt-2.11.5 → ngpt-2.12.0}/docs/api/config.md +0 -0
  25. {ngpt-2.11.5 → ngpt-2.12.0}/docs/assets/css/style.scss +0 -0
  26. {ngpt-2.11.5 → ngpt-2.12.0}/docs/configuration.md +0 -0
  27. {ngpt-2.11.5 → ngpt-2.12.0}/docs/examples/README.md +0 -0
  28. {ngpt-2.11.5 → ngpt-2.12.0}/docs/examples/advanced.md +0 -0
  29. {ngpt-2.11.5 → ngpt-2.12.0}/docs/examples/basic.md +0 -0
  30. {ngpt-2.11.5 → ngpt-2.12.0}/docs/examples/cli_components.md +0 -0
  31. {ngpt-2.11.5 → ngpt-2.12.0}/docs/examples/integrations.md +0 -0
  32. {ngpt-2.11.5 → ngpt-2.12.0}/docs/installation.md +0 -0
  33. {ngpt-2.11.5 → ngpt-2.12.0}/docs/overview.md +0 -0
  34. {ngpt-2.11.5 → ngpt-2.12.0}/docs/usage/README.md +0 -0
  35. {ngpt-2.11.5 → ngpt-2.12.0}/docs/usage/cli_config.md +0 -0
  36. {ngpt-2.11.5 → ngpt-2.12.0}/docs/usage/cli_framework.md +0 -0
  37. {ngpt-2.11.5 → ngpt-2.12.0}/docs/usage/library_usage.md +0 -0
  38. {ngpt-2.11.5 → ngpt-2.12.0}/ngpt/__init__.py +0 -0
  39. /ngpt-2.11.5/ngpt/cli.py → /ngpt-2.12.0/ngpt/__main__.py +0 -0
  40. {ngpt-2.11.5 → ngpt-2.12.0}/ngpt/cli/__init__.py +0 -0
  41. {ngpt-2.11.5 → ngpt-2.12.0}/ngpt/cli/config_manager.py +0 -0
  42. {ngpt-2.11.5 → ngpt-2.12.0}/ngpt/cli/formatters.py +0 -0
  43. {ngpt-2.11.5 → ngpt-2.12.0}/ngpt/cli/interactive.py +0 -0
  44. {ngpt-2.11.5 → ngpt-2.12.0}/ngpt/cli/modes/__init__.py +0 -0
  45. {ngpt-2.11.5 → ngpt-2.12.0}/ngpt/cli/modes/code.py +0 -0
  46. {ngpt-2.11.5 → ngpt-2.12.0}/ngpt/cli/modes/shell.py +0 -0
  47. {ngpt-2.11.5 → ngpt-2.12.0}/ngpt/cli/modes/text.py +0 -0
  48. {ngpt-2.11.5 → ngpt-2.12.0}/ngpt/cli/renderers.py +0 -0
  49. {ngpt-2.11.5 → ngpt-2.12.0}/ngpt/cli/ui.py +0 -0
  50. {ngpt-2.11.5 → ngpt-2.12.0}/ngpt/client.py +0 -0
  51. {ngpt-2.11.5 → ngpt-2.12.0}/ngpt/utils/__init__.py +0 -0
  52. {ngpt-2.11.5 → ngpt-2.12.0}/ngpt/utils/cli_config.py +0 -0
  53. {ngpt-2.11.5 → ngpt-2.12.0}/ngpt/utils/config.py +0 -0
  54. {ngpt-2.11.5 → 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
- - `cli.py` - Top-level CLI script (potentially legacy)
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.11.5
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
@@ -100,6 +100,9 @@ ngpt --code --stream-prettify "function to calculate the Fibonacci sequence"
100
100
  # Generate and execute shell commands
101
101
  ngpt --shell "list all files in the current directory"
102
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
+
103
106
  # Display markdown responses with beautiful formatting
104
107
  ngpt --prettify "Explain markdown syntax with examples"
105
108
 
@@ -120,6 +123,9 @@ ngpt --interactive --log conversation.log
120
123
 
121
124
  # Create a temporary log file automatically
122
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: {}"
123
129
  ```
124
130
 
125
131
  For more examples and detailed usage, visit the [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage.html).
@@ -65,6 +65,9 @@ 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
+
68
71
  # Display markdown responses with beautiful formatting
69
72
  ngpt --prettify "Explain markdown syntax with examples"
70
73
 
@@ -85,6 +88,9 @@ ngpt --interactive --log conversation.log
85
88
 
86
89
  # Create a temporary log file automatically
87
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: {}"
88
94
  ```
89
95
 
90
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
- - `cli.py` - Top-level CLI script (potentially legacy)
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`
@@ -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
- # Process management
252
- ngpt -s "find processes using too much memory"
279
+ Summarize documentation:
280
+ ```bash
281
+ cat README.md | ngpt --stdin "Summarize this documentation: {}"
282
+ ```
253
283
 
254
- # Package management
255
- ngpt -s "install the latest version of numpy"
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:
@@ -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
- # Note: --show-config is handled separately and implicitly acts as a mode
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
- # Get the prompt
14
- if args.prompt is None:
15
- try:
16
- print("Enter your prompt: ", end='')
17
- prompt = input()
18
- except KeyboardInterrupt:
19
- print("\nInput cancelled by user. Exiting gracefully.")
20
- sys.exit(130)
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
- prompt = args.prompt
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.11.5"
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.cli:main"
44
+ ngpt = "ngpt.__main__:main"
45
45
 
46
46
  [build-system]
47
47
  requires = ["hatchling"]
@@ -134,7 +134,7 @@ wheels = [
134
134
 
135
135
  [[package]]
136
136
  name = "ngpt"
137
- version = "2.11.5"
137
+ version = "2.12.0"
138
138
  source = { editable = "." }
139
139
  dependencies = [
140
140
  { name = "prompt-toolkit" },
@@ -1,4 +0,0 @@
1
- from .cli import main
2
-
3
- if __name__ == "__main__":
4
- main()
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