ngpt 2.5.0__py3-none-any.whl → 2.5.1__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 +17 -7
- ngpt/client.py +22 -3
- {ngpt-2.5.0.dist-info → ngpt-2.5.1.dist-info}/METADATA +1 -2
- ngpt-2.5.1.dist-info/RECORD +9 -0
- ngpt-2.5.0.dist-info/RECORD +0 -9
- {ngpt-2.5.0.dist-info → ngpt-2.5.1.dist-info}/WHEEL +0 -0
- {ngpt-2.5.0.dist-info → ngpt-2.5.1.dist-info}/entry_points.txt +0 -0
- {ngpt-2.5.0.dist-info → ngpt-2.5.1.dist-info}/licenses/LICENSE +0 -0
ngpt/cli.py
CHANGED
@@ -553,6 +553,14 @@ def interactive_chat_session(client, web_search=False, no_stream=False, temperat
|
|
553
553
|
|
554
554
|
# Initialize conversation history
|
555
555
|
system_prompt = preprompt if preprompt else "You are a helpful assistant."
|
556
|
+
|
557
|
+
# Add markdown formatting instruction to system prompt if prettify is enabled
|
558
|
+
if prettify:
|
559
|
+
if system_prompt:
|
560
|
+
system_prompt += " You can use markdown formatting in your responses where appropriate."
|
561
|
+
else:
|
562
|
+
system_prompt = "You are a helpful assistant. You can use markdown formatting in your responses where appropriate."
|
563
|
+
|
556
564
|
conversation = []
|
557
565
|
system_message = {"role": "system", "content": system_prompt}
|
558
566
|
conversation.append(system_message)
|
@@ -681,7 +689,8 @@ def interactive_chat_session(client, web_search=False, no_stream=False, temperat
|
|
681
689
|
web_search=web_search,
|
682
690
|
temperature=temperature,
|
683
691
|
top_p=top_p,
|
684
|
-
max_tokens=max_tokens
|
692
|
+
max_tokens=max_tokens,
|
693
|
+
markdown_format=prettify
|
685
694
|
)
|
686
695
|
|
687
696
|
# Add AI response to conversation history
|
@@ -1091,13 +1100,12 @@ def main():
|
|
1091
1100
|
|
1092
1101
|
generated_code = client.generate_code(prompt, args.language, web_search=args.web_search,
|
1093
1102
|
temperature=args.temperature, top_p=args.top_p,
|
1094
|
-
max_tokens=args.max_tokens
|
1103
|
+
max_tokens=args.max_tokens,
|
1104
|
+
markdown_format=args.prettify)
|
1095
1105
|
if generated_code:
|
1096
1106
|
if args.prettify:
|
1097
|
-
# Format code as markdown with proper syntax highlighting
|
1098
|
-
markdown_code = f"```{args.language}\n{generated_code}\n```"
|
1099
1107
|
print("\nGenerated code:")
|
1100
|
-
prettify_markdown(
|
1108
|
+
prettify_markdown(generated_code, args.renderer)
|
1101
1109
|
else:
|
1102
1110
|
print(f"\nGenerated code:\n{generated_code}")
|
1103
1111
|
|
@@ -1227,7 +1235,8 @@ def main():
|
|
1227
1235
|
|
1228
1236
|
response = client.chat(prompt, stream=should_stream, web_search=args.web_search,
|
1229
1237
|
temperature=args.temperature, top_p=args.top_p,
|
1230
|
-
max_tokens=args.max_tokens, messages=messages
|
1238
|
+
max_tokens=args.max_tokens, messages=messages,
|
1239
|
+
markdown_format=args.prettify)
|
1231
1240
|
|
1232
1241
|
# Handle non-stream response (either because no_stream was set or prettify forced it)
|
1233
1242
|
if (args.no_stream or args.prettify) and response:
|
@@ -1265,7 +1274,8 @@ def main():
|
|
1265
1274
|
|
1266
1275
|
response = client.chat(prompt, stream=should_stream, web_search=args.web_search,
|
1267
1276
|
temperature=args.temperature, top_p=args.top_p,
|
1268
|
-
max_tokens=args.max_tokens, messages=messages
|
1277
|
+
max_tokens=args.max_tokens, messages=messages,
|
1278
|
+
markdown_format=args.prettify)
|
1269
1279
|
|
1270
1280
|
# Handle non-stream response (either because no_stream was set or prettify forced it)
|
1271
1281
|
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
|
-
|
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
|
-
|
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.
|
3
|
+
Version: 2.5.1
|
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
|
@@ -30,7 +30,6 @@ Classifier: Topic :: Utilities
|
|
30
30
|
Requires-Python: >=3.8
|
31
31
|
Requires-Dist: prompt-toolkit>=3.0.0
|
32
32
|
Requires-Dist: requests>=2.31.0
|
33
|
-
Requires-Dist: rich>=14.0.0
|
34
33
|
Provides-Extra: prettify
|
35
34
|
Requires-Dist: rich>=10.0.0; extra == 'prettify'
|
36
35
|
Description-Content-Type: text/markdown
|
@@ -0,0 +1,9 @@
|
|
1
|
+
ngpt/__init__.py,sha256=ehInP9w0MZlS1vZ1g6Cm4YE1ftmgF72CnEddQ3Le9n4,368
|
2
|
+
ngpt/cli.py,sha256=IiBVelrzhrRDu75B5wbf5GlCbBqgQXMh7tJ3Nk_WDsQ,60095
|
3
|
+
ngpt/client.py,sha256=QyPw93oJrMnStOzRqK6AldVqHATH1QgdbJ3vfkFjUsQ,14152
|
4
|
+
ngpt/config.py,sha256=WYOk_b1eiYjo6hpV3pfXr2RjqhOnmKqwZwKid1T41I4,10363
|
5
|
+
ngpt-2.5.1.dist-info/METADATA,sha256=wdJY5g_7LG2hvj5U3I_uY9Zho02lrqfolgj0G2Gjr0A,14657
|
6
|
+
ngpt-2.5.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
7
|
+
ngpt-2.5.1.dist-info/entry_points.txt,sha256=1cnAMujyy34DlOahrJg19lePSnb08bLbkUs_kVerqdk,39
|
8
|
+
ngpt-2.5.1.dist-info/licenses/LICENSE,sha256=mQkpWoADxbHqE0HRefYLJdm7OpdrXBr3vNv5bZ8w72M,1065
|
9
|
+
ngpt-2.5.1.dist-info/RECORD,,
|
ngpt-2.5.0.dist-info/RECORD
DELETED
@@ -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
|
File without changes
|
File without changes
|