ngpt 3.5.2__py3-none-any.whl → 3.5.3__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/cli/modes/code.py CHANGED
@@ -4,6 +4,29 @@ from ..ui import spinner
4
4
  from ...utils import enhance_prompt_with_web_search
5
5
  import sys
6
6
  import threading
7
+ import platform
8
+
9
+ def get_terminal_input():
10
+ """Get input from terminal in a cross-platform way, even when stdin is redirected."""
11
+ if platform.system() == 'Windows':
12
+ # Windows-specific solution
13
+ try:
14
+ import msvcrt
15
+ sys.stdout.flush()
16
+ # Wait for a keypress
17
+ char = msvcrt.getch().decode('utf-8').lower()
18
+ print(char) # Echo the character
19
+ return char
20
+ except ImportError:
21
+ # Fallback if msvcrt is not available
22
+ return None
23
+ else:
24
+ # Unix-like systems (Linux, macOS)
25
+ try:
26
+ with open('/dev/tty', 'r') as tty:
27
+ return tty.readline().strip().lower()
28
+ except (IOError, OSError):
29
+ return None
7
30
 
8
31
  # System prompt for code generation with markdown formatting
9
32
  CODE_SYSTEM_PROMPT_MARKDOWN = """Your Role: Provide only code as output without any description with proper markdown formatting.
@@ -298,4 +321,27 @@ def code_mode(client, args, logger=None):
298
321
  prettify_markdown(generated_code, args.renderer)
299
322
  else:
300
323
  # Should only happen if --no-stream was used without prettify
301
- print(f"\nGenerated code:\n{generated_code}")
324
+ print(f"\nGenerated code:\n{generated_code}")
325
+
326
+ # Offer to copy to clipboard if not in a redirected output
327
+ if generated_code and not args.no_stream and sys.stdout.isatty():
328
+ try:
329
+ # Make sure to flush output before asking for input
330
+ # Make the prompt more visible with colors and formatting
331
+ clipboard_prompt = f"{COLORS['cyan']}{COLORS['bold']}Copy to clipboard? (y/n){COLORS['reset']} "
332
+ print(clipboard_prompt, end="")
333
+ sys.stdout.flush()
334
+
335
+ # Cross-platform terminal input
336
+ answer = get_terminal_input()
337
+
338
+ if answer == 'y':
339
+ try:
340
+ import pyperclip
341
+ pyperclip.copy(generated_code)
342
+ print(f"{COLORS['green']}Copied to clipboard.{COLORS['reset']}")
343
+ except ImportError:
344
+ print(f"{COLORS['yellow']}pyperclip not installed. Try: pip install \"ngpt[clipboard]\" {COLORS['reset']}")
345
+
346
+ except (KeyboardInterrupt, EOFError):
347
+ pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ngpt
3
- Version: 3.5.2
3
+ Version: 3.5.3
4
4
  Summary: Swiss army knife for LLMs: powerful CLI and interactive chatbot in one package. Seamlessly work with OpenAI, Ollama, Groq, Claude, Gemini, or any OpenAI-compatible API to generate code, craft git commits, rewrite text, and execute shell commands.
5
5
  Project-URL: Homepage, https://github.com/nazdridoy/ngpt
6
6
  Project-URL: Repository, https://github.com/nazdridoy/ngpt
@@ -54,7 +54,7 @@ Description-Content-Type: text/markdown
54
54
  🤖 nGPT: A Swiss army knife for LLMs: powerful CLI and interactive chatbot in one package. Seamlessly work with OpenAI, Ollama, Groq, Claude, Gemini, or any OpenAI-compatible API to generate code, craft git commits, rewrite text, and execute shell commands. Fast, lightweight, and designed for both casual users and developers.
55
55
 
56
56
 
57
- ![2025-04-23_16-18-01](https://github.com/user-attachments/assets/b8e58926-5165-4352-b48b-9f4a982da86e)
57
+ ![ngpt-i](https://raw.githubusercontent.com/nazdridoy/ngpt/main/previews/ngpt-i.png)
58
58
 
59
59
 
60
60
  ## Features
@@ -10,7 +10,7 @@ ngpt/cli/renderers.py,sha256=m71BeUXKynpKKGXFzwRSW1XngvyKiZ_xEsdujUbU0MA,16597
10
10
  ngpt/cli/ui.py,sha256=HoHDFpLiwMBP5wtMb8YYo244FMiqiPFRoBNcNGp6N0A,7310
11
11
  ngpt/cli/modes/__init__.py,sha256=KP7VR6Xw9k1p5Jcu0F38RDxSFvFIzH3j1ThDLNwznUI,363
12
12
  ngpt/cli/modes/chat.py,sha256=jfKkrtSkx1gKPsKXDMxZ7BiJiMsCtFHyZCGIdmNQ0fk,7816
13
- ngpt/cli/modes/code.py,sha256=VYpAHXNLDmrOznTIy4XgQPM7gunSnw3VorvrjPG_1Wg,12359
13
+ ngpt/cli/modes/code.py,sha256=RvVojJIm0jQnwzJ4tlKd4j4CFZuJOGc_YJ3RDjUNXOs,14181
14
14
  ngpt/cli/modes/gitcommsg.py,sha256=rsfMoeOupmNp-5p5fsMSPAf18BbzXWq-4PF2HjEz6SY,46991
15
15
  ngpt/cli/modes/interactive.py,sha256=TtBrZUX45CVfKOPvkb1ya7dIQhXLILtn7ajmfM9ohso,17419
16
16
  ngpt/cli/modes/rewrite.py,sha256=9o37-o5Q8SGfJ91-8pD4h7d5RsJeu85OEdv3nXKzQiA,12361
@@ -21,8 +21,8 @@ ngpt/utils/cli_config.py,sha256=Ug8cECBTIuzOwkBWidLTfs-OAdOsCMJ2bNa70pOADfw,1119
21
21
  ngpt/utils/config.py,sha256=wsArA4osnh8fKqOvtsPqqBxAz3DpdjtaWUFaRtnUdyc,10452
22
22
  ngpt/utils/log.py,sha256=f1jg2iFo35PAmsarH8FVL_62plq4VXH0Mu2QiP6RJGw,15934
23
23
  ngpt/utils/web_search.py,sha256=w5ke4KJMRxq7r5jtbUXvspja6XhjoPZloVkZ0IvBXIE,30731
24
- ngpt-3.5.2.dist-info/METADATA,sha256=sC8YBnPKWY39E1CMiaYzcxW5JWMWkPOoZ05K8KgspuQ,23931
25
- ngpt-3.5.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
26
- ngpt-3.5.2.dist-info/entry_points.txt,sha256=SqAAvLhMrsEpkIr4YFRdUeyuXQ9o0IBCeYgE6AVojoI,44
27
- ngpt-3.5.2.dist-info/licenses/LICENSE,sha256=mQkpWoADxbHqE0HRefYLJdm7OpdrXBr3vNv5bZ8w72M,1065
28
- ngpt-3.5.2.dist-info/RECORD,,
24
+ ngpt-3.5.3.dist-info/METADATA,sha256=_Z2B2bvNXf-h03702SQ85UFPWLJUTFqcfXBJRtr2fTE,23912
25
+ ngpt-3.5.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
26
+ ngpt-3.5.3.dist-info/entry_points.txt,sha256=SqAAvLhMrsEpkIr4YFRdUeyuXQ9o0IBCeYgE6AVojoI,44
27
+ ngpt-3.5.3.dist-info/licenses/LICENSE,sha256=mQkpWoADxbHqE0HRefYLJdm7OpdrXBr3vNv5bZ8w72M,1065
28
+ ngpt-3.5.3.dist-info/RECORD,,
File without changes