ngpt 2.5.0__py3-none-any.whl → 2.6.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/cli.py CHANGED
@@ -115,10 +115,11 @@ def show_available_renderers():
115
115
  if HAS_RICH:
116
116
  print(f" {COLORS['green']}✓ Rich{COLORS['reset']} - Python library for terminal formatting (Recommended)")
117
117
  else:
118
- print(f" {COLORS['yellow']}✗ Rich{COLORS['reset']} - Not installed (pip install rich)")
118
+ print(f" {COLORS['yellow']}✗ Rich{COLORS['reset']} - Not installed (pip install \"ngpt[full]\" or pip install rich)")
119
119
 
120
120
  if not HAS_GLOW and not HAS_RICH:
121
121
  print(f"\n{COLORS['yellow']}To enable prettified markdown output, install one of the above renderers.{COLORS['reset']}")
122
+ print(f"{COLORS['yellow']}For Rich: pip install \"ngpt[full]\" or pip install rich{COLORS['reset']}")
122
123
  else:
123
124
  renderers = []
124
125
  if HAS_RICH:
@@ -148,11 +149,11 @@ def warn_if_no_markdown_renderer(renderer='auto'):
148
149
 
149
150
  if renderer == 'auto':
150
151
  print(f"{COLORS['yellow']}Warning: No markdown rendering library available.{COLORS['reset']}")
151
- print(f"{COLORS['yellow']}Install 'rich' package with: pip install rich{COLORS['reset']}")
152
+ print(f"{COLORS['yellow']}Install with: pip install \"ngpt[full]\"{COLORS['reset']}")
152
153
  print(f"{COLORS['yellow']}Or install 'glow' from https://github.com/charmbracelet/glow{COLORS['reset']}")
153
154
  elif renderer == 'rich':
154
155
  print(f"{COLORS['yellow']}Warning: Rich is not available.{COLORS['reset']}")
155
- print(f"{COLORS['yellow']}Install with: pip install rich{COLORS['reset']}")
156
+ print(f"{COLORS['yellow']}Install with: pip install \"ngpt[full]\" or pip install rich{COLORS['reset']}")
156
157
  elif renderer == 'glow':
157
158
  print(f"{COLORS['yellow']}Warning: Glow is not available.{COLORS['reset']}")
158
159
  print(f"{COLORS['yellow']}Install from https://github.com/charmbracelet/glow{COLORS['reset']}")
@@ -219,7 +220,8 @@ def prettify_markdown(text, renderer='auto'):
219
220
  # Use rich for rendering
220
221
  elif renderer == 'rich':
221
222
  if not HAS_RICH:
222
- print(f"{COLORS['yellow']}Warning: Rich is not available. Install with: pip install rich{COLORS['reset']}")
223
+ print(f"{COLORS['yellow']}Warning: Rich is not available.{COLORS['reset']}")
224
+ print(f"{COLORS['yellow']}Install with: pip install \"ngpt[full]\" or pip install rich{COLORS['reset']}")
223
225
  # Fall back to glow if available
224
226
  if HAS_GLOW:
225
227
  print(f"{COLORS['yellow']}Falling back to Glow renderer.{COLORS['reset']}")
@@ -553,6 +555,14 @@ def interactive_chat_session(client, web_search=False, no_stream=False, temperat
553
555
 
554
556
  # Initialize conversation history
555
557
  system_prompt = preprompt if preprompt else "You are a helpful assistant."
558
+
559
+ # Add markdown formatting instruction to system prompt if prettify is enabled
560
+ if prettify:
561
+ if system_prompt:
562
+ system_prompt += " You can use markdown formatting in your responses where appropriate."
563
+ else:
564
+ system_prompt = "You are a helpful assistant. You can use markdown formatting in your responses where appropriate."
565
+
556
566
  conversation = []
557
567
  system_message = {"role": "system", "content": system_prompt}
558
568
  conversation.append(system_message)
@@ -681,7 +691,8 @@ def interactive_chat_session(client, web_search=False, no_stream=False, temperat
681
691
  web_search=web_search,
682
692
  temperature=temperature,
683
693
  top_p=top_p,
684
- max_tokens=max_tokens
694
+ max_tokens=max_tokens,
695
+ markdown_format=prettify
685
696
  )
686
697
 
687
698
  # Add AI response to conversation history
@@ -1091,13 +1102,12 @@ def main():
1091
1102
 
1092
1103
  generated_code = client.generate_code(prompt, args.language, web_search=args.web_search,
1093
1104
  temperature=args.temperature, top_p=args.top_p,
1094
- max_tokens=args.max_tokens)
1105
+ max_tokens=args.max_tokens,
1106
+ markdown_format=args.prettify)
1095
1107
  if generated_code:
1096
1108
  if args.prettify:
1097
- # Format code as markdown with proper syntax highlighting
1098
- markdown_code = f"```{args.language}\n{generated_code}\n```"
1099
1109
  print("\nGenerated code:")
1100
- prettify_markdown(markdown_code, args.renderer)
1110
+ prettify_markdown(generated_code, args.renderer)
1101
1111
  else:
1102
1112
  print(f"\nGenerated code:\n{generated_code}")
1103
1113
 
@@ -1227,7 +1237,8 @@ def main():
1227
1237
 
1228
1238
  response = client.chat(prompt, stream=should_stream, web_search=args.web_search,
1229
1239
  temperature=args.temperature, top_p=args.top_p,
1230
- max_tokens=args.max_tokens, messages=messages)
1240
+ max_tokens=args.max_tokens, messages=messages,
1241
+ markdown_format=args.prettify)
1231
1242
 
1232
1243
  # Handle non-stream response (either because no_stream was set or prettify forced it)
1233
1244
  if (args.no_stream or args.prettify) and response:
@@ -1265,7 +1276,8 @@ def main():
1265
1276
 
1266
1277
  response = client.chat(prompt, stream=should_stream, web_search=args.web_search,
1267
1278
  temperature=args.temperature, top_p=args.top_p,
1268
- max_tokens=args.max_tokens, messages=messages)
1279
+ max_tokens=args.max_tokens, messages=messages,
1280
+ markdown_format=args.prettify)
1269
1281
 
1270
1282
  # Handle non-stream response (either because no_stream was set or prettify forced it)
1271
1283
  if (args.no_stream or args.prettify) and response:
ngpt/client.py CHANGED
@@ -33,6 +33,7 @@ class NGPTClient:
33
33
  top_p: float = 1.0,
34
34
  messages: Optional[List[Dict[str, str]]] = None,
35
35
  web_search: bool = False,
36
+ markdown_format: bool = False,
36
37
  **kwargs
37
38
  ) -> str:
38
39
  """
@@ -46,6 +47,7 @@ class NGPTClient:
46
47
  top_p: Controls diversity via nucleus sampling
47
48
  messages: Optional list of message objects to override default behavior
48
49
  web_search: Whether to enable web search capability
50
+ markdown_format: If True, allow markdown-formatted responses, otherwise plain text
49
51
  **kwargs: Additional arguments to pass to the API
50
52
 
51
53
  Returns:
@@ -56,7 +58,11 @@ class NGPTClient:
56
58
  return ""
57
59
 
58
60
  if messages is None:
59
- messages = [{"role": "user", "content": prompt}]
61
+ if markdown_format:
62
+ system_message = {"role": "system", "content": "You can use markdown formatting in your responses where appropriate."}
63
+ messages = [system_message, {"role": "user", "content": prompt}]
64
+ else:
65
+ messages = [{"role": "user", "content": prompt}]
60
66
 
61
67
  # Prepare API parameters
62
68
  payload = {
@@ -241,7 +247,8 @@ Command:"""
241
247
  web_search: bool = False,
242
248
  temperature: float = 0.4,
243
249
  top_p: float = 0.95,
244
- max_tokens: Optional[int] = None
250
+ max_tokens: Optional[int] = None,
251
+ markdown_format: bool = False
245
252
  ) -> str:
246
253
  """
247
254
  Generate code based on the prompt.
@@ -253,6 +260,7 @@ Command:"""
253
260
  temperature: Controls randomness in the response
254
261
  top_p: Controls diversity via nucleus sampling
255
262
  max_tokens: Maximum number of tokens to generate
263
+ markdown_format: If True, request markdown-formatted code, otherwise plain text
256
264
 
257
265
  Returns:
258
266
  The generated code
@@ -262,7 +270,18 @@ Command:"""
262
270
  print("Error: API key is not set. Please configure your API key in the config file or provide it with --api-key.")
263
271
  return ""
264
272
 
265
- system_prompt = f"""Your Role: Provide only code as output without any description.
273
+ if markdown_format:
274
+ system_prompt = f"""Your Role: Provide only code as output without any description with proper markdown formatting.
275
+ IMPORTANT: Format the code using markdown code blocks with the appropriate language syntax highlighting.
276
+ IMPORTANT: You must use markdown code blocks. with ```{language}
277
+ If there is a lack of details, provide most logical solution. You are not allowed to ask for more details.
278
+ Ignore any potential risk of errors or confusion.
279
+
280
+ Language: {language}
281
+ Request: {prompt}
282
+ Code:"""
283
+ else:
284
+ system_prompt = f"""Your Role: Provide only code as output without any description.
266
285
  IMPORTANT: Provide only plain text without Markdown formatting.
267
286
  IMPORTANT: Do not include markdown formatting.
268
287
  If there is a lack of details, provide most logical solution. You are not allowed to ask for more details.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ngpt
3
- Version: 2.5.0
3
+ Version: 2.6.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
@@ -28,11 +28,10 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
28
28
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
29
29
  Classifier: Topic :: Utilities
30
30
  Requires-Python: >=3.8
31
- Requires-Dist: prompt-toolkit>=3.0.0
32
31
  Requires-Dist: requests>=2.31.0
33
- Requires-Dist: rich>=14.0.0
34
- Provides-Extra: prettify
35
- Requires-Dist: rich>=10.0.0; extra == 'prettify'
32
+ Provides-Extra: full
33
+ Requires-Dist: prompt-toolkit>=3.0.0; extra == 'full'
34
+ Requires-Dist: rich>=10.0.0; extra == 'full'
36
35
  Description-Content-Type: text/markdown
37
36
 
38
37
  # nGPT
@@ -67,6 +66,9 @@ A lightweight Python CLI and library for interacting with OpenAI-compatible APIs
67
66
  # Install
68
67
  pip install ngpt
69
68
 
69
+ # Install with additional features
70
+ pip install "ngpt[full]"
71
+
70
72
  # Chat with default settings
71
73
  ngpt "Tell me about quantum computing"
72
74
 
@@ -137,11 +139,19 @@ Key documentation sections:
137
139
  ## Installation
138
140
 
139
141
  ```bash
142
+ # Basic installation (minimal dependencies)
140
143
  pip install ngpt
144
+
145
+ # Full installation with all features (recommended)
146
+ pip install "ngpt[full]"
141
147
  ```
142
148
 
143
149
  Requires Python 3.8 or newer.
144
150
 
151
+ The full installation includes:
152
+ - Enhanced markdown rendering with syntax highlighting
153
+ - Improved interactive input experience with multiline editing
154
+
145
155
  For detailed installation instructions, see the [Installation Guide](https://nazdridoy.github.io/ngpt/installation.html).
146
156
 
147
157
  ## Usage
@@ -0,0 +1,9 @@
1
+ ngpt/__init__.py,sha256=ehInP9w0MZlS1vZ1g6Cm4YE1ftmgF72CnEddQ3Le9n4,368
2
+ ngpt/cli.py,sha256=4PN0iHSxwhifg3x5MDlwDg-ZMiZIoLYGBHqBROyo6e0,60347
3
+ ngpt/client.py,sha256=QyPw93oJrMnStOzRqK6AldVqHATH1QgdbJ3vfkFjUsQ,14152
4
+ ngpt/config.py,sha256=WYOk_b1eiYjo6hpV3pfXr2RjqhOnmKqwZwKid1T41I4,10363
5
+ ngpt-2.6.0.dist-info/METADATA,sha256=RDCx6SGlvdZ0LlifLxBagznn9pP5f2kBQ564UO7HZvk,15000
6
+ ngpt-2.6.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
+ ngpt-2.6.0.dist-info/entry_points.txt,sha256=1cnAMujyy34DlOahrJg19lePSnb08bLbkUs_kVerqdk,39
8
+ ngpt-2.6.0.dist-info/licenses/LICENSE,sha256=mQkpWoADxbHqE0HRefYLJdm7OpdrXBr3vNv5bZ8w72M,1065
9
+ ngpt-2.6.0.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- ngpt/__init__.py,sha256=ehInP9w0MZlS1vZ1g6Cm4YE1ftmgF72CnEddQ3Le9n4,368
2
- ngpt/cli.py,sha256=VE-Zp7mx-GC6p0o9CcKAnAJCDbLjwiV_UKxwikceDaM,59632
3
- ngpt/client.py,sha256=lJfyLONeBU7YqMVJJys6zPay7gcJTq108_rJ4wvOtok,13067
4
- ngpt/config.py,sha256=WYOk_b1eiYjo6hpV3pfXr2RjqhOnmKqwZwKid1T41I4,10363
5
- ngpt-2.5.0.dist-info/METADATA,sha256=Guk41uYFdF-_hWqi6QgUHhWXXuhgU2CMai0GvIOnkHA,14685
6
- ngpt-2.5.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
- ngpt-2.5.0.dist-info/entry_points.txt,sha256=1cnAMujyy34DlOahrJg19lePSnb08bLbkUs_kVerqdk,39
8
- ngpt-2.5.0.dist-info/licenses/LICENSE,sha256=mQkpWoADxbHqE0HRefYLJdm7OpdrXBr3vNv5bZ8w72M,1065
9
- ngpt-2.5.0.dist-info/RECORD,,
File without changes