ngpt 2.11.5__py3-none-any.whl → 2.12.0__py3-none-any.whl

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/__main__.py CHANGED
@@ -1,4 +1,4 @@
1
- from .cli import main
1
+ from .cli.main import main
2
2
 
3
3
  if __name__ == "__main__":
4
4
  main()
ngpt/cli/args.py CHANGED
@@ -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):
ngpt/cli/main.py CHANGED
@@ -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
ngpt/cli/modes/chat.py CHANGED
@@ -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
  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).
@@ -1,17 +1,16 @@
1
1
  ngpt/__init__.py,sha256=kpKhViLakwMdHZkuLht2vWcjt0uD_5gR33gvMhfXr6w,664
2
- ngpt/__main__.py,sha256=8jnUtGyV5HLiixnmWKxRK9nrWOSgE7yr95XbdmemvxE,61
3
- ngpt/cli.py,sha256=j3eFYPOtCCFBOGh7NK5IWEnADnTMMSEB9GLyIDoW724,66
2
+ ngpt/__main__.py,sha256=j3eFYPOtCCFBOGh7NK5IWEnADnTMMSEB9GLyIDoW724,66
4
3
  ngpt/client.py,sha256=rLgDPmJe8_yi13-XUiHJ45z54rJVrupxWmeb-fQZGF4,15129
5
4
  ngpt/cli/__init__.py,sha256=hebbDSMGiOd43YNnQP67uzr67Ue6rZPwm2czynr5iZY,43
6
- ngpt/cli/args.py,sha256=3yrTkgd5N0IiQyalV1sDs2-jMBRicWkYg3x3RKk8SgI,9409
5
+ ngpt/cli/args.py,sha256=5MxWHkE6bW6bH5IAITTj2WrkXf2sV3FPV8LJanb-yw0,9770
7
6
  ngpt/cli/config_manager.py,sha256=NQQcWnjUppAAd0s0p9YAf8EyKS1ex5-0EB4DvKdB4dk,3662
8
7
  ngpt/cli/formatters.py,sha256=1ofNEWEZtFr0MJ3oWomoL_mFmZHlUdT3I5qGtbDQ4g0,9378
9
8
  ngpt/cli/interactive.py,sha256=DZFbExcXd7RylkpBiZBhiI6N8FBaT0m_lBes0Pvhi48,10894
10
- ngpt/cli/main.py,sha256=lDJOeaXTiiqXbcYDwCLFixMfAZZ8zN4wzBew1lOdr4w,27440
9
+ ngpt/cli/main.py,sha256=y0L-GlA3oDRup_4nDVTWtVCv70ijswKXx3m3kG0zkjI,27720
11
10
  ngpt/cli/renderers.py,sha256=gJ3WdVvCGkNxrLEkLCh6gk9HBFMK8y7an6CsEkqt2Z8,10535
12
11
  ngpt/cli/ui.py,sha256=iMinm_QdsmwrEUpb7CBRexyyBqf4sviFI9M3E8D-hhA,5303
13
12
  ngpt/cli/modes/__init__.py,sha256=11znFpqzHyRsEtaTrms5M3q2SrscT9VvUgr7C2B1o-E,179
14
- ngpt/cli/modes/chat.py,sha256=gXgy8lZNIfu-UTCsRpZJzW_vEriUl19QB_oFQtXRRL0,3138
13
+ ngpt/cli/modes/chat.py,sha256=4a5EgM_5A1zCSrLrjgQMDnBwIHd1Rnu5_BjSKSm7p24,4255
15
14
  ngpt/cli/modes/code.py,sha256=RjOAj7BDO5vLUdIPkUfPtyIkI_W6qEHsZvYh-sIdVaM,4293
16
15
  ngpt/cli/modes/shell.py,sha256=lF9f7w-0bl_FdZl-WJnZuV736BKrWQtrwoKr3ejPXFE,2682
17
16
  ngpt/cli/modes/text.py,sha256=ncYnfLFMdTPuHiOvAaHNiOWhox6GF6S-2fTwMIrAz-g,3140
@@ -19,8 +18,8 @@ ngpt/utils/__init__.py,sha256=E46suk2-QgYBI0Qrs6WXOajOUOebF3ETAFY7ah8DTWs,942
19
18
  ngpt/utils/cli_config.py,sha256=A1TgO1rkRs6zgfNwIw5v8-N5jxqrHMZ4B6r3w48egi8,10687
20
19
  ngpt/utils/config.py,sha256=WYOk_b1eiYjo6hpV3pfXr2RjqhOnmKqwZwKid1T41I4,10363
21
20
  ngpt/utils/log.py,sha256=3AJiry9vUbo9Rzzrgj6-NMM4lCbgoZhrGcXvdxMqtrs,6353
22
- ngpt-2.11.5.dist-info/METADATA,sha256=4SN84RPaPPQj5uHmppF9CPfZiwLsMyytqt3JJyElbew,20722
23
- ngpt-2.11.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
24
- ngpt-2.11.5.dist-info/entry_points.txt,sha256=1cnAMujyy34DlOahrJg19lePSnb08bLbkUs_kVerqdk,39
25
- ngpt-2.11.5.dist-info/licenses/LICENSE,sha256=mQkpWoADxbHqE0HRefYLJdm7OpdrXBr3vNv5bZ8w72M,1065
26
- ngpt-2.11.5.dist-info/RECORD,,
21
+ ngpt-2.12.0.dist-info/METADATA,sha256=e9iyCtLNNs5dFaX35FlOa1XqeVQw6h-B8SiWHGe2QHU,20967
22
+ ngpt-2.12.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
+ ngpt-2.12.0.dist-info/entry_points.txt,sha256=SqAAvLhMrsEpkIr4YFRdUeyuXQ9o0IBCeYgE6AVojoI,44
24
+ ngpt-2.12.0.dist-info/licenses/LICENSE,sha256=mQkpWoADxbHqE0HRefYLJdm7OpdrXBr3vNv5bZ8w72M,1065
25
+ ngpt-2.12.0.dist-info/RECORD,,
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ngpt = ngpt.__main__:main
ngpt/cli.py DELETED
@@ -1,4 +0,0 @@
1
- from .cli.main import main
2
-
3
- if __name__ == "__main__":
4
- main()
@@ -1,2 +0,0 @@
1
- [console_scripts]
2
- ngpt = ngpt.cli:main
File without changes