Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ import inspect
|
|
| 5 |
import pandas as pd
|
| 6 |
|
| 7 |
|
| 8 |
-
from duckduckgo_search import
|
| 9 |
from transformers import pipeline
|
| 10 |
from newspaper import Article
|
| 11 |
import hashlib, datetime
|
|
@@ -35,10 +35,12 @@ class SmartResearchAgent:
|
|
| 35 |
print("SmartResearchAgent initialized.")
|
| 36 |
|
| 37 |
def search_web(self, query: str) -> str:
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
| 42 |
|
| 43 |
def summarize(self, input_text: str) -> str:
|
| 44 |
if input_text.startswith("http"):
|
|
|
|
| 5 |
import pandas as pd
|
| 6 |
|
| 7 |
|
| 8 |
+
from duckduckgo_search import DDGS
|
| 9 |
from transformers import pipeline
|
| 10 |
from newspaper import Article
|
| 11 |
import hashlib, datetime
|
|
|
|
| 35 |
print("SmartResearchAgent initialized.")
|
| 36 |
|
| 37 |
def search_web(self, query: str) -> str:
|
| 38 |
+
results_text = ""
|
| 39 |
+
with DDGS() as ddgs:
|
| 40 |
+
results = ddgs.text(query, max_results=3)
|
| 41 |
+
for i, r in enumerate(results):
|
| 42 |
+
results_text += f"{i+1}. {r['title']}: {r['href']}\n"
|
| 43 |
+
return results_text or "No results found."
|
| 44 |
|
| 45 |
def summarize(self, input_text: str) -> str:
|
| 46 |
if input_text.startswith("http"):
|