ngpt 3.4.3__py3-none-any.whl → 3.4.5__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/main.py CHANGED
@@ -18,7 +18,7 @@ from .. import __version__
18
18
  from .formatters import COLORS
19
19
  from .renderers import show_available_renderers
20
20
  from .config_manager import check_config
21
- from .interactive import interactive_chat_session
21
+ from .modes.interactive import interactive_chat_session
22
22
  from .modes.chat import chat_mode
23
23
  from .modes.code import code_mode
24
24
  from .modes.shell import shell_mode
@@ -4,5 +4,6 @@ from .shell import shell_mode
4
4
  from .text import text_mode
5
5
  from .rewrite import rewrite_mode
6
6
  from .gitcommsg import gitcommsg_mode
7
+ from .interactive import interactive_chat_session
7
8
 
8
- __all__ = ['chat_mode', 'code_mode', 'shell_mode', 'text_mode', 'rewrite_mode', 'gitcommsg_mode']
9
+ __all__ = ['chat_mode', 'code_mode', 'shell_mode', 'text_mode', 'rewrite_mode', 'gitcommsg_mode', 'interactive_chat_session']
ngpt/cli/modes/chat.py CHANGED
@@ -70,17 +70,21 @@ def chat_mode(client, args, logger=None):
70
70
  print(f"{COLORS['yellow']}Warning: Failed to enhance prompt with web search: {str(e)}{COLORS['reset']}")
71
71
  # Continue with the original prompt if web search fails
72
72
 
73
- # Create messages array with preprompt if available
74
- messages = None
75
- if args.preprompt:
76
- # Log the system message if logging is enabled
77
- if logger:
78
- logger.log("system", args.preprompt)
79
-
80
- messages = [
81
- {"role": "system", "content": args.preprompt},
82
- {"role": "user", "content": prompt}
83
- ]
73
+ # Create messages array with system prompt
74
+ default_system_prompt = "You are a helpful assistant."
75
+ if args.prettify or args.stream_prettify:
76
+ default_system_prompt += " You can use markdown formatting in your responses where appropriate."
77
+
78
+ system_prompt = args.preprompt if args.preprompt else default_system_prompt
79
+
80
+ # Log the system message if logging is enabled
81
+ if logger:
82
+ logger.log("system", system_prompt)
83
+
84
+ messages = [
85
+ {"role": "system", "content": system_prompt},
86
+ {"role": "user", "content": prompt}
87
+ ]
84
88
 
85
89
  # Set default streaming behavior based on --no-stream and --prettify arguments
86
90
  should_stream = not args.no_stream and not args.prettify
@@ -4,9 +4,9 @@ import traceback
4
4
  import threading
5
5
  import sys
6
6
  import time
7
- from .formatters import COLORS
8
- from .renderers import prettify_markdown, prettify_streaming_markdown
9
- from ..utils import enhance_prompt_with_web_search
7
+ from ..formatters import COLORS
8
+ from ..renderers import prettify_markdown, prettify_streaming_markdown
9
+ from ...utils import enhance_prompt_with_web_search
10
10
 
11
11
  # Optional imports for enhanced UI
12
12
  try:
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ngpt
3
- Version: 3.4.3
4
- Summary: Swiss army knife for LLMs: powerful CLI, interactive chatbot, and flexible Python library. Works with OpenAI, Ollama, Groq, Claude, Gemini, and any OpenAI-compatible API.
3
+ Version: 3.4.5
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
7
7
  Project-URL: Bug Tracker, https://github.com/nazdridoy/ngpt/issues
@@ -46,13 +46,13 @@ Description-Content-Type: text/markdown
46
46
  </p>
47
47
 
48
48
  <p align="center">
49
- <a href="https://nazdridoy.github.io/ngpt/installation.html"><img src="https://img.shields.io/badge/Linux-support-blue?logo=linux" alt="Linux"></a>
50
- <a href="https://nazdridoy.github.io/ngpt/installation.html"><img src="https://img.shields.io/badge/Windows-support-blue?logo=windows" alt="Windows"></a>
51
- <a href="https://nazdridoy.github.io/ngpt/installation.html"><img src="https://img.shields.io/badge/macOS-support-blue?logo=apple" alt="macOS"></a>
52
- <a href="https://nazdridoy.github.io/ngpt/installation.html"><img src="https://img.shields.io/badge/Android-Termux-blue?logo=android" alt="Android"></a>
49
+ <a href="https://nazdridoy.github.io/ngpt/installation/"><img src="https://img.shields.io/badge/Linux-support-blue?logo=linux" alt="Linux"></a>
50
+ <a href="https://nazdridoy.github.io/ngpt/installation/"><img src="https://img.shields.io/badge/Windows-support-blue?logo=windows" alt="Windows"></a>
51
+ <a href="https://nazdridoy.github.io/ngpt/installation/"><img src="https://img.shields.io/badge/macOS-support-blue?logo=apple" alt="macOS"></a>
52
+ <a href="https://nazdridoy.github.io/ngpt/installation/"><img src="https://img.shields.io/badge/Android-Termux-blue?logo=android" alt="Android"></a>
53
53
  </p>
54
54
 
55
- 🤖 nGPT: A Swiss army knife for LLMs: powerful CLI, interactive chatbot, and flexible library all 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
+ 🤖 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.
56
56
 
57
57
 
58
58
  ![2025-04-23_16-18-01](https://github.com/user-attachments/assets/b8e58926-5165-4352-b48b-9f4a982da86e)
@@ -60,7 +60,7 @@ Description-Content-Type: text/markdown
60
60
 
61
61
  ## Features
62
62
 
63
- - ✅ **Versatile**: Use as a CLI tool, Python library, or CLI framework for building custom tools
63
+ - ✅ **Versatile**: Powerful and easy-to-use CLI tool for various AI tasks
64
64
  - 🪶 **Lightweight**: Minimal dependencies with everything you need included
65
65
  - 🔄 **API Flexibility**: Works with OpenAI, Ollama, Groq, Claude, Gemini, and any compatible endpoint
66
66
  - 💬 **Interactive Chat**: Continuous conversation with memory in modern UI
@@ -77,12 +77,11 @@ Description-Content-Type: text/markdown
77
77
  - 📑 **Git Commit Messages**: AI-powered generation of conventional, detailed commit messages from git diffs
78
78
  - 🎭 **System Prompts**: Customize model behavior with custom system prompts
79
79
  - 📃 **Conversation Logging**: Save your conversations to text files for later reference
80
- - 🧰 **CLI Components**: Reusable components for building custom AI-powered command-line tools
81
80
  - 🔌 **Modular Architecture**: Well-structured codebase with clean separation of concerns
82
81
  - 🔄 **Provider Switching**: Easily switch between different LLM providers with a single parameter
83
82
  - 🚀 **Performance Optimized**: Fast response times and minimal resource usage
84
83
 
85
- See the [Feature Overview](https://nazdridoy.github.io/ngpt/overview.html) for more details.
84
+ See the [Feature Overview](https://nazdridoy.github.io/ngpt/overview/) for more details.
86
85
 
87
86
 
88
87
  ## Table of Contents
@@ -93,8 +92,6 @@ See the [Feature Overview](https://nazdridoy.github.io/ngpt/overview.html) for m
93
92
  - [Usage](#usage)
94
93
  - [Documentation](https://nazdridoy.github.io/ngpt/)
95
94
  - [CLI Tool](#as-a-cli-tool)
96
- - [Python Library](#as-a-library)
97
- - [CLI Framework](#as-a-cli-framework)
98
95
  - [Configuration](#configuration)
99
96
  - [Command Line Options](#command-line-options)
100
97
  - [CLI Configuration](#cli-configuration)
@@ -205,21 +202,19 @@ ngpt --provider OpenAI "Explain quantum physics" > openai_response.txt
205
202
  ngpt --provider Ollama "Explain quantum physics" > ollama_response.txt
206
203
  ```
207
204
 
208
- For more examples and detailed usage, visit the [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage.html).
205
+ For more examples and detailed usage, visit the [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage/).
209
206
 
210
207
  ## Documentation
211
208
 
212
- Comprehensive documentation, including API reference, usage guides, and examples, is available at:
209
+ Comprehensive documentation, including usage guides and examples, is available at:
213
210
 
214
211
  **[https://nazdridoy.github.io/ngpt/](https://nazdridoy.github.io/ngpt/)**
215
212
 
216
213
  Key documentation sections:
217
- - [Installation Guide](https://nazdridoy.github.io/ngpt/installation.html)
218
- - [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage.html)
219
- - [Library Usage Guide](https://nazdridoy.github.io/ngpt/usage/library_usage.html)
220
- - [CLI Framework Guide](https://nazdridoy.github.io/ngpt/usage/cli_framework.html)
221
- - [Configuration Guide](https://nazdridoy.github.io/ngpt/configuration.html)
222
- - [Examples & Tutorials](https://nazdridoy.github.io/ngpt/examples/basic.html)
214
+ - [Installation Guide](https://nazdridoy.github.io/ngpt/installation/)
215
+ - [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage/)
216
+ - [Configuration Guide](https://nazdridoy.github.io/ngpt/configuration/)
217
+ - [Examples & Tutorials](https://nazdridoy.github.io/ngpt/examples/basic/)
223
218
 
224
219
  ## Installation
225
220
 
@@ -239,7 +234,7 @@ paru -S ngpt
239
234
 
240
235
  Requires Python 3.8 or newer.
241
236
 
242
- For detailed installation instructions, see the [Installation Guide](https://nazdridoy.github.io/ngpt/installation.html).
237
+ For detailed installation instructions, see the [Installation Guide](https://nazdridoy.github.io/ngpt/installation/).
243
238
 
244
239
  ## Usage
245
240
 
@@ -291,125 +286,7 @@ ngpt -c "create a python function that calculates fibonacci numbers"
291
286
  ngpt -t
292
287
  ```
293
288
 
294
- For more CLI examples and detailed usage information, see the [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage.html).
295
-
296
- ### As a Library
297
-
298
- ```python
299
- from ngpt import NGPTClient
300
- from ngpt.utils.config import load_config
301
-
302
- # Load the first configuration (index 0) from config file
303
- config = load_config(config_index=0)
304
-
305
- # Initialize the client with config
306
- client = NGPTClient(**config)
307
-
308
- # Or initialize with custom parameters
309
- client = NGPTClient(
310
- api_key="your-key",
311
- base_url="http://your-endpoint",
312
- provider="openai",
313
- model="o3-mini"
314
- )
315
-
316
- # Chat
317
- response = client.chat("Hello, how are you?")
318
-
319
- # Chat with web search (if your API endpoint supports it)
320
- response = client.chat("What's the latest news about AI?", web_search=True)
321
-
322
- # Generate shell command
323
- command = client.generate_shell_command("list all files")
324
-
325
- # Generate code
326
- code = client.generate_code("create a python function that calculates fibonacci numbers")
327
- ```
328
-
329
- For more library examples and advanced usage, see the [Library Usage Guide](https://nazdridoy.github.io/ngpt/usage/library_usage.html).
330
-
331
- #### Advanced Library Usage
332
-
333
- ```python
334
- # Stream responses
335
- for chunk in client.chat("Write a poem about Python", stream=True):
336
- print(chunk, end="", flush=True)
337
-
338
- # Customize system prompt
339
- response = client.chat(
340
- "Explain quantum computing",
341
- system_prompt="You are a quantum physics professor. Explain complex concepts simply."
342
- )
343
-
344
- # OS-aware shell commands
345
- # Automatically generates appropriate commands for the current OS
346
- command = client.generate_shell_command("find large files")
347
- import subprocess
348
- result = subprocess.run(command, shell=True, capture_output=True, text=True)
349
- print(result.stdout)
350
-
351
- # Clean code generation
352
- # Returns only code without markdown or explanations
353
- code = client.generate_code("function that converts Celsius to Fahrenheit")
354
- print(code)
355
-
356
- # Compare responses from different providers
357
- openai_config = load_config(config_index=0) # OpenAI
358
- groq_config = load_config(config_index=1) # Groq
359
-
360
- openai_client = NGPTClient(**openai_config)
361
- groq_client = NGPTClient(**groq_config)
362
-
363
- openai_response = openai_client.chat("Explain quantum computing")
364
- groq_response = groq_client.chat("Explain quantum computing")
365
- ```
366
-
367
- For advanced usage patterns and integrations, check out the [Advanced Examples](https://nazdridoy.github.io/ngpt/examples/advanced.html).
368
-
369
- ### As a CLI Framework
370
-
371
- nGPT can also be used as a framework to build your own AI-powered command-line tools. You can leverage nGPT's pre-built CLI components to quickly develop sophisticated CLI applications.
372
-
373
- ```python
374
- from ngpt import NGPTClient
375
- from ngpt.utils.config import load_config
376
- from ngpt.cli.interactive import interactive_chat_session
377
- from ngpt.cli.renderers import prettify_markdown
378
- from ngpt.cli.args import setup_argument_parser
379
- import sys
380
-
381
- # Create a custom CLI tool with colorized help
382
- parser = setup_argument_parser()
383
- parser.description = "Specialized Code Assistant"
384
- parser.add_argument("prompt", nargs="?", help="Code description")
385
- parser.add_argument("--language", "-l", default="python", help="Programming language")
386
- parser.add_argument("--interactive", "-i", action="store_true", help="Start interactive mode")
387
- args = parser.parse_args()
388
-
389
- # Initialize client
390
- client = NGPTClient(**load_config())
391
-
392
- # Use interactive session for conversation
393
- if args.interactive:
394
- system_prompt = f"You are an expert {args.language} developer. Provide clear, detailed answers."
395
- interactive_chat_session(client=client, preprompt=system_prompt, prettify=True)
396
- elif args.prompt:
397
- # Generate and prettify code
398
- code = client.generate_code(args.prompt, language=args.language)
399
- print(prettify_markdown(f"```{args.language}\n{code}\n```"))
400
- else:
401
- parser.print_help()
402
- sys.exit(1)
403
- ```
404
-
405
- This allows you to build specialized AI tools like:
406
- - Code generators for specific languages or frameworks
407
- - Domain-specific assistants (SQL, legal, finance, etc.)
408
- - Documentation generators
409
- - Translation tools
410
- - And much more
411
-
412
- For detailed information about building CLI tools with nGPT, see the [CLI Framework Guide](https://nazdridoy.github.io/ngpt/usage/cli_framework.html) and explore the [CLI Component Examples](https://nazdridoy.github.io/ngpt/examples/cli_components.html).
289
+ For more CLI examples and detailed usage information, see the [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage/).
413
290
 
414
291
  ## Configuration
415
292
 
@@ -525,7 +402,7 @@ Modes (mutually exclusive)::
525
402
 
526
403
  > **Note**: For better visualization of conventional commit messages on GitHub, you can use the [GitHub Commit Labels](https://greasyfork.org/en/scripts/526153-github-commit-labels) userscript, which adds colorful labels to your commits.
527
404
 
528
- For a complete reference of all available options, see the [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage.html).
405
+ For a complete reference of all available options, see the [CLI Usage Guide](https://nazdridoy.github.io/ngpt/usage/cli_usage/).
529
406
 
530
407
  ### CLI Configuration
531
408
 
@@ -598,7 +475,7 @@ CLI Configuration Help:
598
475
 
599
476
  ```
600
477
 
601
- For more details, see the [CLI Configuration Guide](https://nazdridoy.github.io/ngpt/usage/cli_config.html).
478
+ For more details, see the [CLI Configuration Guide](https://nazdridoy.github.io/ngpt/usage/cli_config/).
602
479
 
603
480
  ### Interactive Configuration
604
481
 
@@ -630,7 +507,7 @@ In interactive mode:
630
507
  - For security, your API key is not displayed when editing configurations
631
508
  - When removing a configuration, you'll be asked to confirm before deletion
632
509
 
633
- For more details on configuring nGPT, see the [Configuration Guide](https://nazdridoy.github.io/ngpt/configuration.html).
510
+ For more details on configuring nGPT, see the [Configuration Guide](https://nazdridoy.github.io/ngpt/configuration/).
634
511
 
635
512
  ### Configuration File
636
513
 
@@ -666,7 +543,7 @@ The configuration file uses a JSON list format, allowing you to store multiple c
666
543
  ]
667
544
  ```
668
545
 
669
- For details on the configuration file format and structure, see the [Configuration Guide](https://nazdridoy.github.io/ngpt/configuration.html).
546
+ For details on the configuration file format and structure, see the [Configuration Guide](https://nazdridoy.github.io/ngpt/configuration/).
670
547
 
671
548
  ### Configuration Priority
672
549
 
@@ -5,14 +5,14 @@ ngpt/cli/__init__.py,sha256=hebbDSMGiOd43YNnQP67uzr67Ue6rZPwm2czynr5iZY,43
5
5
  ngpt/cli/args.py,sha256=4Yeik1kAb2nEOjiGYauf9Rg7wQ5NHFJWAS350D6a_zo,12411
6
6
  ngpt/cli/config_manager.py,sha256=NQQcWnjUppAAd0s0p9YAf8EyKS1ex5-0EB4DvKdB4dk,3662
7
7
  ngpt/cli/formatters.py,sha256=HBYGlx_7eoAKyzfy0Vq5L0yn8yVKjngqYBukMmXCcz0,9401
8
- ngpt/cli/interactive.py,sha256=6SrnANvE5T9Luu-CSGPfW7lub4-yog9aqruAfs1XEIg,16392
9
- ngpt/cli/main.py,sha256=9um40RplKHSW5UHcUUO2cwMNqkGUhfQwikI1CHHFbnk,28926
8
+ ngpt/cli/main.py,sha256=oKX7ryTIrsvQRJHVnH2a763pGyNZthq81wkrRILwHLw,28932
10
9
  ngpt/cli/renderers.py,sha256=m71BeUXKynpKKGXFzwRSW1XngvyKiZ_xEsdujUbU0MA,16597
11
10
  ngpt/cli/ui.py,sha256=HoHDFpLiwMBP5wtMb8YYo244FMiqiPFRoBNcNGp6N0A,7310
12
- ngpt/cli/modes/__init__.py,sha256=R3aO662RIzWEOvr3moTrEI8Tpg0zDDyMGGh1-OxiRgM,285
13
- ngpt/cli/modes/chat.py,sha256=UlnZWqvxL_CSyVIDZKGVXNlG-KufDfo05E8-8xTcM_Y,6713
11
+ ngpt/cli/modes/__init__.py,sha256=KP7VR6Xw9k1p5Jcu0F38RDxSFvFIzH3j1ThDLNwznUI,363
12
+ ngpt/cli/modes/chat.py,sha256=pv8Ec1l3XsHnW1o3iukxmKg3pK4UJeODl8mC73MH0qg,6927
14
13
  ngpt/cli/modes/code.py,sha256=ounayP8exu8Bb8QFL4TcyF2d3QI_QlsG5tf6v1FktxE,11470
15
14
  ngpt/cli/modes/gitcommsg.py,sha256=rsfMoeOupmNp-5p5fsMSPAf18BbzXWq-4PF2HjEz6SY,46991
15
+ ngpt/cli/modes/interactive.py,sha256=COJABbSgfyVC98lvFD1K2yqKPqyH20vbVrYYh8oiPUk,16395
16
16
  ngpt/cli/modes/rewrite.py,sha256=ftD-6M9iQ7g4rLdlKyyLTRiJWYtbz64LIG4PIByxmOk,11472
17
17
  ngpt/cli/modes/shell.py,sha256=9oaOvzKc0VZ0Hjervbzo_kryMlYVZH0IXhc0MaBTYVk,8008
18
18
  ngpt/cli/modes/text.py,sha256=gdn4opioZ6G3nvfrTkp-dpoD-Of_ZvjVVRggVd6edkg,5528
@@ -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=yvCUDNhwcIcKZ_hWESFQQ-vB-LKsDDCDT17YFzFcGR4,12598
24
- ngpt-3.4.3.dist-info/METADATA,sha256=oM_uL8vOKuK4Ou4F2yHt1vBnoIFrTuJaSrGKECcMwkM,29100
25
- ngpt-3.4.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
26
- ngpt-3.4.3.dist-info/entry_points.txt,sha256=SqAAvLhMrsEpkIr4YFRdUeyuXQ9o0IBCeYgE6AVojoI,44
27
- ngpt-3.4.3.dist-info/licenses/LICENSE,sha256=mQkpWoADxbHqE0HRefYLJdm7OpdrXBr3vNv5bZ8w72M,1065
28
- ngpt-3.4.3.dist-info/RECORD,,
24
+ ngpt-3.4.5.dist-info/METADATA,sha256=ofAuga74DmRxU0xIJ_FNHMYIEu-wAzVZPpjpiKwPHqw,24585
25
+ ngpt-3.4.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
26
+ ngpt-3.4.5.dist-info/entry_points.txt,sha256=SqAAvLhMrsEpkIr4YFRdUeyuXQ9o0IBCeYgE6AVojoI,44
27
+ ngpt-3.4.5.dist-info/licenses/LICENSE,sha256=mQkpWoADxbHqE0HRefYLJdm7OpdrXBr3vNv5bZ8w72M,1065
28
+ ngpt-3.4.5.dist-info/RECORD,,
File without changes