ngpt 3.3.0__py3-none-any.whl → 3.4.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/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 = 3) -> List[Dict[str, Any]]:
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': 'current_time', # Could replace with actual 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 += "Consider the above information when answering the following question:\n\n"
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 = 3, logger=None) -> str:
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.0
3
+ Version: 3.4.0
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
@@ -20,9 +20,9 @@ ngpt/utils/__init__.py,sha256=qu_66I1Vtav2f1LDiPn5J3DUsbK7o1CSScMcTkYqxoM,1179
20
20
  ngpt/utils/cli_config.py,sha256=IlHnOEEGpLoGZInynM778wgpxLVcJ_STKWxg2Ypvir4,11196
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=DXjf5zJW4jXbmpir6Oqv7abfrFxjqJqvnuAA9gJIFJk,9919
24
- ngpt-3.3.0.dist-info/METADATA,sha256=1gGlQ6gzQwnnB8wfdmzcwlf3DRV9JNup7HgfXsSRo2Y,29100
25
- ngpt-3.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
26
- ngpt-3.3.0.dist-info/entry_points.txt,sha256=SqAAvLhMrsEpkIr4YFRdUeyuXQ9o0IBCeYgE6AVojoI,44
27
- ngpt-3.3.0.dist-info/licenses/LICENSE,sha256=mQkpWoADxbHqE0HRefYLJdm7OpdrXBr3vNv5bZ8w72M,1065
28
- ngpt-3.3.0.dist-info/RECORD,,
23
+ ngpt/utils/web_search.py,sha256=xHfAymkVkx5b7rOITee2smxpH7waRUpaX8aqTf5WBeA,11599
24
+ ngpt-3.4.0.dist-info/METADATA,sha256=1xkrTK7mKFEVilhnLdkNqsRmuczpphjRCgSD8t89Gp8,29100
25
+ ngpt-3.4.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
26
+ ngpt-3.4.0.dist-info/entry_points.txt,sha256=SqAAvLhMrsEpkIr4YFRdUeyuXQ9o0IBCeYgE6AVojoI,44
27
+ ngpt-3.4.0.dist-info/licenses/LICENSE,sha256=mQkpWoADxbHqE0HRefYLJdm7OpdrXBr3vNv5bZ8w72M,1065
28
+ ngpt-3.4.0.dist-info/RECORD,,
File without changes