ngpt 3.4.1__py3-none-any.whl → 3.4.2__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
@@ -31,7 +31,7 @@ def code_mode(client, args, logger=None):
31
31
  if args.web_search:
32
32
  try:
33
33
  original_prompt = prompt
34
- prompt = enhance_prompt_with_web_search(prompt, logger=logger)
34
+ prompt = enhance_prompt_with_web_search(prompt, logger=logger, disable_citations=True)
35
35
  print("Enhanced input with web search results.")
36
36
 
37
37
  # Log the enhanced prompt if logging is enabled
ngpt/cli/modes/shell.py CHANGED
@@ -31,7 +31,7 @@ def shell_mode(client, args, logger=None):
31
31
  if args.web_search:
32
32
  try:
33
33
  original_prompt = prompt
34
- prompt = enhance_prompt_with_web_search(prompt, logger=logger)
34
+ prompt = enhance_prompt_with_web_search(prompt, logger=logger, disable_citations=True)
35
35
  print("Enhanced input with web search results.")
36
36
 
37
37
  # Log the enhanced prompt if logging is enabled
ngpt/utils/web_search.py CHANGED
@@ -29,11 +29,11 @@ def get_logger():
29
29
  if _logger is not None:
30
30
  return _logger
31
31
  else:
32
- # Default logging to stderr if no logger provided
32
+ # Default logging to stderr if no logger provided, but only for errors
33
33
  class DefaultLogger:
34
- def info(self, msg): print(f"INFO: {msg}", file=sys.stderr)
34
+ def info(self, msg): pass # Suppress INFO messages
35
35
  def error(self, msg): print(f"ERROR: {msg}", file=sys.stderr)
36
- def warning(self, msg): print(f"WARNING: {msg}", file=sys.stderr)
36
+ def warning(self, msg): pass # Suppress WARNING messages
37
37
  def debug(self, msg): pass
38
38
  return DefaultLogger()
39
39
 
@@ -256,15 +256,15 @@ def format_web_search_results_for_prompt(search_results: Dict[str, Any]) -> str:
256
256
  formatted_text += "Example citation format in text:\n"
257
257
  formatted_text += "Today is Thursday [1] and it's expected to rain tomorrow [2].\n\n"
258
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"
259
+ formatted_text += "> [1] https://example.com/date\n"
260
260
  formatted_text += ">\n"
261
- formatted_text += "> [1] https://weather.com/forecast\n"
261
+ formatted_text += "> [2] https://weather.com/forecast\n"
262
262
  formatted_text += ">\n"
263
- formatted_text += "> [2] https://www.timeanddate.com\n\n"
263
+ formatted_text += "> [3] https://www.timeanddate.com\n\n"
264
264
 
265
265
  return formatted_text
266
266
 
267
- def enhance_prompt_with_web_search(prompt: str, max_results: int = 5, logger=None) -> str:
267
+ def enhance_prompt_with_web_search(prompt: str, max_results: int = 5, logger=None, disable_citations: bool = False) -> str:
268
268
  """
269
269
  Enhance a prompt with web search results.
270
270
 
@@ -272,6 +272,7 @@ def enhance_prompt_with_web_search(prompt: str, max_results: int = 5, logger=Non
272
272
  prompt: The original user prompt
273
273
  max_results: Maximum number of search results to include
274
274
  logger: Optional logger to use
275
+ disable_citations: If True, disables citation instructions (used for code and shell modes)
275
276
 
276
277
  Returns:
277
278
  Enhanced prompt with web search results prepended
@@ -282,10 +283,28 @@ def enhance_prompt_with_web_search(prompt: str, max_results: int = 5, logger=Non
282
283
 
283
284
  logger = get_logger()
284
285
  search_results = get_web_search_results(prompt, max_results)
285
- formatted_results = format_web_search_results_for_prompt(search_results)
286
+
287
+ if disable_citations:
288
+ # Modified version without citation instructions for code/shell modes
289
+ query = search_results['query']
290
+ results = search_results['results']
291
+ timestamp = search_results['timestamp']
292
+
293
+ formatted_text = f"[Web Search Results for: {query} (searched at {timestamp})]\n\n"
294
+
295
+ for i, result in enumerate(results, 1):
296
+ formatted_text += f"RESULT {i}: {result['title']}\n"
297
+ formatted_text += f"URL: {result['url']}\n"
298
+ formatted_text += f"CONTENT:\n{result['content']}\n\n"
299
+
300
+ formatted_text += f"[End of Web Search Results]\n\n"
301
+ formatted_text += "Use the above web search information to help you, but do not include citations or references in your response.\n\n"
302
+ else:
303
+ # Standard version with citation instructions
304
+ formatted_text = format_web_search_results_for_prompt(search_results)
286
305
 
287
306
  # Combine results with original prompt
288
- enhanced_prompt = formatted_results + prompt
307
+ enhanced_prompt = formatted_text + prompt
289
308
 
290
309
  logger.info("Enhanced input with web search results")
291
310
  return enhanced_prompt
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ngpt
3
- Version: 3.4.1
3
+ Version: 3.4.2
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
@@ -11,18 +11,18 @@ ngpt/cli/renderers.py,sha256=m71BeUXKynpKKGXFzwRSW1XngvyKiZ_xEsdujUbU0MA,16597
11
11
  ngpt/cli/ui.py,sha256=HoHDFpLiwMBP5wtMb8YYo244FMiqiPFRoBNcNGp6N0A,7310
12
12
  ngpt/cli/modes/__init__.py,sha256=R3aO662RIzWEOvr3moTrEI8Tpg0zDDyMGGh1-OxiRgM,285
13
13
  ngpt/cli/modes/chat.py,sha256=UlnZWqvxL_CSyVIDZKGVXNlG-KufDfo05E8-8xTcM_Y,6713
14
- ngpt/cli/modes/code.py,sha256=4TpIV-EkyXb8d3XJKrsLs9Wxq5P9jC82z94PI2Zck_g,6730
14
+ ngpt/cli/modes/code.py,sha256=Pdyfde_elIyZKp-pcArkRfWMJcucpBCwY2bVAMk5nzc,6754
15
15
  ngpt/cli/modes/gitcommsg.py,sha256=rsfMoeOupmNp-5p5fsMSPAf18BbzXWq-4PF2HjEz6SY,46991
16
16
  ngpt/cli/modes/rewrite.py,sha256=ftD-6M9iQ7g4rLdlKyyLTRiJWYtbz64LIG4PIByxmOk,11472
17
- ngpt/cli/modes/shell.py,sha256=fxE9LEEo4arSn5-q_6zxdnUH7RlqifWmk-_kcA76OhM,4070
17
+ ngpt/cli/modes/shell.py,sha256=KPhIfB-fCtyJLa4PJC9ztoKLaRtkNolAAo5-fuGh-eM,4094
18
18
  ngpt/cli/modes/text.py,sha256=gdn4opioZ6G3nvfrTkp-dpoD-Of_ZvjVVRggVd6edkg,5528
19
19
  ngpt/utils/__init__.py,sha256=qu_66I1Vtav2f1LDiPn5J3DUsbK7o1CSScMcTkYqxoM,1179
20
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=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,,
23
+ ngpt/utils/web_search.py,sha256=yvCUDNhwcIcKZ_hWESFQQ-vB-LKsDDCDT17YFzFcGR4,12598
24
+ ngpt-3.4.2.dist-info/METADATA,sha256=2ulru5egoGUkDG3bHm-gUYD7-wpj-ogt12J9fcBfoCM,29100
25
+ ngpt-3.4.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
26
+ ngpt-3.4.2.dist-info/entry_points.txt,sha256=SqAAvLhMrsEpkIr4YFRdUeyuXQ9o0IBCeYgE6AVojoI,44
27
+ ngpt-3.4.2.dist-info/licenses/LICENSE,sha256=mQkpWoADxbHqE0HRefYLJdm7OpdrXBr3vNv5bZ8w72M,1065
28
+ ngpt-3.4.2.dist-info/RECORD,,
File without changes