ngpt 3.3.0__py3-none-any.whl → 3.4.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/args.py +35 -10
- ngpt/utils/cli_config.py +1 -1
- ngpt/utils/web_search.py +26 -5
- {ngpt-3.3.0.dist-info → ngpt-3.4.1.dist-info}/METADATA +1 -1
- {ngpt-3.3.0.dist-info → ngpt-3.4.1.dist-info}/RECORD +8 -8
- {ngpt-3.3.0.dist-info → ngpt-3.4.1.dist-info}/WHEEL +0 -0
- {ngpt-3.3.0.dist-info → ngpt-3.4.1.dist-info}/entry_points.txt +0 -0
- {ngpt-3.3.0.dist-info → ngpt-3.4.1.dist-info}/licenses/LICENSE +0 -0
ngpt/cli/args.py
CHANGED
@@ -79,14 +79,19 @@ def setup_argument_parser():
|
|
79
79
|
help='Set filepath to log conversation to, or create a temporary log file if no path provided')
|
80
80
|
global_group.add_argument('--preprompt',
|
81
81
|
help='Set custom system prompt to control AI behavior')
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
help='
|
82
|
+
|
83
|
+
# Output display options (mutually exclusive group)
|
84
|
+
output_group = parser.add_argument_group('Output Display Options (mutually exclusive)')
|
85
|
+
output_exclusive_group = output_group.add_mutually_exclusive_group()
|
86
|
+
output_exclusive_group.add_argument('--no-stream', action='store_true',
|
87
|
+
help='Return the whole response without streaming or formatting')
|
88
|
+
output_exclusive_group.add_argument('--prettify', action='store_const', const='auto',
|
89
|
+
help='Render complete response with markdown and code formatting (non-streaming)')
|
90
|
+
output_exclusive_group.add_argument('--stream-prettify', action='store_true', default=True,
|
91
|
+
help='Stream response with real-time markdown rendering (default)')
|
92
|
+
|
88
93
|
global_group.add_argument('--renderer', choices=['auto', 'rich', 'glow'], default='auto',
|
89
|
-
help='Select which markdown renderer to use with --prettify (auto, rich, or glow)')
|
94
|
+
help='Select which markdown renderer to use with --prettify or --stream-prettify (auto, rich, or glow)')
|
90
95
|
|
91
96
|
# GitCommit message options
|
92
97
|
gitcommsg_group = parser.add_argument_group('Git Commit Message Options')
|
@@ -134,9 +139,29 @@ def validate_args(args):
|
|
134
139
|
if args.all and not args.show_config:
|
135
140
|
raise ValueError("--all can only be used with --show-config")
|
136
141
|
|
137
|
-
#
|
138
|
-
|
139
|
-
|
142
|
+
# These three options are mutually exclusive rendering modes
|
143
|
+
provided_modes = []
|
144
|
+
if '--no-stream' in sys.argv:
|
145
|
+
provided_modes.append('--no-stream')
|
146
|
+
if '--prettify' in sys.argv:
|
147
|
+
provided_modes.append('--prettify')
|
148
|
+
if '--stream-prettify' in sys.argv:
|
149
|
+
provided_modes.append('--stream-prettify')
|
150
|
+
|
151
|
+
# If more than one rendering mode explicitly provided, raise error
|
152
|
+
if len(provided_modes) > 1:
|
153
|
+
raise ValueError(f"The options {', '.join(provided_modes)} cannot be used together. These options are mutually exclusive.")
|
154
|
+
|
155
|
+
# Handle the conflict between default stream-prettify and explicitly provided options
|
156
|
+
if args.no_stream:
|
157
|
+
args.stream_prettify = False
|
158
|
+
args.prettify = False
|
159
|
+
elif args.prettify:
|
160
|
+
args.stream_prettify = False
|
161
|
+
args.no_stream = False
|
162
|
+
elif args.stream_prettify:
|
163
|
+
args.no_stream = False
|
164
|
+
args.prettify = False
|
140
165
|
|
141
166
|
# Check if --stream-prettify is used but Rich is not available
|
142
167
|
if args.stream_prettify and not has_markdown_renderer('rich'):
|
ngpt/utils/cli_config.py
CHANGED
@@ -15,7 +15,7 @@ CLI_CONFIG_OPTIONS = {
|
|
15
15
|
"preprompt": {"type": "str", "default": None, "context": ["all"]},
|
16
16
|
"no-stream": {"type": "bool", "default": False, "context": ["all"], "exclusive": ["prettify", "stream-prettify"]},
|
17
17
|
"prettify": {"type": "bool", "default": False, "context": ["all"], "exclusive": ["no-stream", "stream-prettify"]},
|
18
|
-
"stream-prettify": {"type": "bool", "default":
|
18
|
+
"stream-prettify": {"type": "bool", "default": True, "context": ["all"], "exclusive": ["no-stream", "prettify"]},
|
19
19
|
"renderer": {"type": "str", "default": "auto", "context": ["all"]},
|
20
20
|
"config-index": {"type": "int", "default": 0, "context": ["all"], "exclusive": ["provider"]},
|
21
21
|
"web-search": {"type": "bool", "default": False, "context": ["all"]},
|
ngpt/utils/web_search.py
CHANGED
@@ -11,6 +11,7 @@ from duckduckgo_search import DDGS
|
|
11
11
|
from urllib.parse import urlparse
|
12
12
|
import requests
|
13
13
|
import sys
|
14
|
+
import datetime
|
14
15
|
|
15
16
|
# Get actual logger from global context instead of using standard logging
|
16
17
|
from . import log
|
@@ -36,7 +37,7 @@ def get_logger():
|
|
36
37
|
def debug(self, msg): pass
|
37
38
|
return DefaultLogger()
|
38
39
|
|
39
|
-
def perform_web_search(query: str, max_results: int =
|
40
|
+
def perform_web_search(query: str, max_results: int = 5) -> List[Dict[str, Any]]:
|
40
41
|
"""
|
41
42
|
Search the web using DuckDuckGo and return relevant results.
|
42
43
|
|
@@ -211,10 +212,13 @@ def get_web_search_results(query: str, max_results: int = 3, max_chars_per_resul
|
|
211
212
|
logger.info(f"Successfully retrieved content from all {success_count} sources")
|
212
213
|
else:
|
213
214
|
logger.error("No search results were found")
|
215
|
+
|
216
|
+
# Add current timestamp
|
217
|
+
current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
214
218
|
|
215
219
|
return {
|
216
220
|
'query': query,
|
217
|
-
'timestamp':
|
221
|
+
'timestamp': current_time,
|
218
222
|
'results': enhanced_results
|
219
223
|
}
|
220
224
|
|
@@ -230,8 +234,9 @@ def format_web_search_results_for_prompt(search_results: Dict[str, Any]) -> str:
|
|
230
234
|
"""
|
231
235
|
query = search_results['query']
|
232
236
|
results = search_results['results']
|
237
|
+
timestamp = search_results['timestamp']
|
233
238
|
|
234
|
-
formatted_text = f"[Web Search Results for: {query}]\n\n"
|
239
|
+
formatted_text = f"[Web Search Results for: {query} (searched at {timestamp})]\n\n"
|
235
240
|
|
236
241
|
for i, result in enumerate(results, 1):
|
237
242
|
formatted_text += f"RESULT {i}: {result['title']}\n"
|
@@ -239,11 +244,27 @@ def format_web_search_results_for_prompt(search_results: Dict[str, Any]) -> str:
|
|
239
244
|
formatted_text += f"CONTENT:\n{result['content']}\n\n"
|
240
245
|
|
241
246
|
formatted_text += f"[End of Web Search Results]\n\n"
|
242
|
-
formatted_text += "
|
247
|
+
formatted_text += "Use the above web search information to help answer the user's question. When using this information:\n"
|
248
|
+
formatted_text += "1. Use numbered citations in square brackets [1], [2], etc. when presenting information from search results\n"
|
249
|
+
formatted_text += "2. Include a numbered reference list at the end of your response with the source URLs\n"
|
250
|
+
formatted_text += "3. Format citations like 'According to [1]...' or 'Research indicates [2]...' or add citations at the end of sentences or paragraphs\n"
|
251
|
+
formatted_text += "4. If search results contain conflicting information, acknowledge the differences and explain them with citations\n"
|
252
|
+
formatted_text += "5. If the search results don't provide sufficient information, acknowledge the limitations\n"
|
253
|
+
formatted_text += "6. Balance information from multiple sources when appropriate\n"
|
254
|
+
formatted_text += "7. YOU MUST include an empty blockquote line ('>') between each reference in the reference list\n"
|
255
|
+
formatted_text += "8. YOU MUST include ALL available references (between 2-7 sources) in your reference list\n\n"
|
256
|
+
formatted_text += "Example citation format in text:\n"
|
257
|
+
formatted_text += "Today is Thursday [1] and it's expected to rain tomorrow [2].\n\n"
|
258
|
+
formatted_text += "Example reference format (YOU MUST FOLLOW THIS EXACT FORMAT WITH EMPTY LINES BETWEEN REFERENCES):\n"
|
259
|
+
formatted_text += "> [0] https://example.com/date\n"
|
260
|
+
formatted_text += ">\n"
|
261
|
+
formatted_text += "> [1] https://weather.com/forecast\n"
|
262
|
+
formatted_text += ">\n"
|
263
|
+
formatted_text += "> [2] https://www.timeanddate.com\n\n"
|
243
264
|
|
244
265
|
return formatted_text
|
245
266
|
|
246
|
-
def enhance_prompt_with_web_search(prompt: str, max_results: int =
|
267
|
+
def enhance_prompt_with_web_search(prompt: str, max_results: int = 5, logger=None) -> str:
|
247
268
|
"""
|
248
269
|
Enhance a prompt with web search results.
|
249
270
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ngpt
|
3
|
-
Version: 3.
|
3
|
+
Version: 3.4.1
|
4
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.
|
5
5
|
Project-URL: Homepage, https://github.com/nazdridoy/ngpt
|
6
6
|
Project-URL: Repository, https://github.com/nazdridoy/ngpt
|
@@ -2,7 +2,7 @@ ngpt/__init__.py,sha256=kpKhViLakwMdHZkuLht2vWcjt0uD_5gR33gvMhfXr6w,664
|
|
2
2
|
ngpt/__main__.py,sha256=j3eFYPOtCCFBOGh7NK5IWEnADnTMMSEB9GLyIDoW724,66
|
3
3
|
ngpt/client.py,sha256=1kn-kVQ2ZYhOlQ5OPM9c_btVKajfk1qb52QbMyGdYtU,14645
|
4
4
|
ngpt/cli/__init__.py,sha256=hebbDSMGiOd43YNnQP67uzr67Ue6rZPwm2czynr5iZY,43
|
5
|
-
ngpt/cli/args.py,sha256=
|
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
8
|
ngpt/cli/interactive.py,sha256=6SrnANvE5T9Luu-CSGPfW7lub4-yog9aqruAfs1XEIg,16392
|
@@ -17,12 +17,12 @@ ngpt/cli/modes/rewrite.py,sha256=ftD-6M9iQ7g4rLdlKyyLTRiJWYtbz64LIG4PIByxmOk,114
|
|
17
17
|
ngpt/cli/modes/shell.py,sha256=fxE9LEEo4arSn5-q_6zxdnUH7RlqifWmk-_kcA76OhM,4070
|
18
18
|
ngpt/cli/modes/text.py,sha256=gdn4opioZ6G3nvfrTkp-dpoD-Of_ZvjVVRggVd6edkg,5528
|
19
19
|
ngpt/utils/__init__.py,sha256=qu_66I1Vtav2f1LDiPn5J3DUsbK7o1CSScMcTkYqxoM,1179
|
20
|
-
ngpt/utils/cli_config.py,sha256=
|
20
|
+
ngpt/utils/cli_config.py,sha256=Ug8cECBTIuzOwkBWidLTfs-OAdOsCMJ2bNa70pOADfw,11195
|
21
21
|
ngpt/utils/config.py,sha256=wsArA4osnh8fKqOvtsPqqBxAz3DpdjtaWUFaRtnUdyc,10452
|
22
22
|
ngpt/utils/log.py,sha256=f1jg2iFo35PAmsarH8FVL_62plq4VXH0Mu2QiP6RJGw,15934
|
23
|
-
ngpt/utils/web_search.py,sha256=
|
24
|
-
ngpt-3.
|
25
|
-
ngpt-3.
|
26
|
-
ngpt-3.
|
27
|
-
ngpt-3.
|
28
|
-
ngpt-3.
|
23
|
+
ngpt/utils/web_search.py,sha256=xHfAymkVkx5b7rOITee2smxpH7waRUpaX8aqTf5WBeA,11599
|
24
|
+
ngpt-3.4.1.dist-info/METADATA,sha256=z2jPQJa1kWQZmTsYgoEbln4TREkW3YPbwdrU0gqTx40,29100
|
25
|
+
ngpt-3.4.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
26
|
+
ngpt-3.4.1.dist-info/entry_points.txt,sha256=SqAAvLhMrsEpkIr4YFRdUeyuXQ9o0IBCeYgE6AVojoI,44
|
27
|
+
ngpt-3.4.1.dist-info/licenses/LICENSE,sha256=mQkpWoADxbHqE0HRefYLJdm7OpdrXBr3vNv5bZ8w72M,1065
|
28
|
+
ngpt-3.4.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|