Update app.py
Browse files
app.py
CHANGED
@@ -15,9 +15,11 @@ class DuckDuckGoSearchTool(SearchInformationTool):
|
|
15 |
"""Search tool that uses DuckDuckGo's HTML interface"""
|
16 |
|
17 |
def forward(self, query: str, filter_year: Optional[int] = None) -> str:
|
18 |
-
"""Performs search using DuckDuckGo"""
|
19 |
encoded_query = quote_plus(query)
|
20 |
-
|
|
|
|
|
21 |
self.browser.visit_page(url)
|
22 |
header, content = self.browser._state()
|
23 |
return header.strip() + "\n=======================\n" + content
|
@@ -66,7 +68,12 @@ class ResearchSystem:
|
|
66 |
request_kwargs={
|
67 |
"cookies": COOKIES,
|
68 |
"headers": {
|
69 |
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
|
|
|
|
|
|
|
|
|
|
|
70 |
}
|
71 |
}
|
72 |
)
|
@@ -133,7 +140,7 @@ class ResearchSystem:
|
|
133 |
print(f"\nDEBUG: Processing query: {query}")
|
134 |
|
135 |
# Get search results using the browser
|
136 |
-
search_results = self.researcher.run(f"Search
|
137 |
print(f"\nDEBUG: Search completed. Results:\n{search_results}")
|
138 |
|
139 |
# Analyze the results
|
|
|
15 |
"""Search tool that uses DuckDuckGo's HTML interface"""
|
16 |
|
17 |
def forward(self, query: str, filter_year: Optional[int] = None) -> str:
|
18 |
+
"""Performs search using DuckDuckGo's HTML endpoint"""
|
19 |
encoded_query = quote_plus(query)
|
20 |
+
# Use the HTML endpoint directly
|
21 |
+
url = f"https://html.duckduckgo.com/html/?q={encoded_query}"
|
22 |
+
print(f"DEBUG: Searching with URL: {url}")
|
23 |
self.browser.visit_page(url)
|
24 |
header, content = self.browser._state()
|
25 |
return header.strip() + "\n=======================\n" + content
|
|
|
68 |
request_kwargs={
|
69 |
"cookies": COOKIES,
|
70 |
"headers": {
|
71 |
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
|
72 |
+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
|
73 |
+
"Accept-Language": "en-US,en;q=0.5",
|
74 |
+
"DNT": "1",
|
75 |
+
"Connection": "keep-alive",
|
76 |
+
"Upgrade-Insecure-Requests": "1"
|
77 |
}
|
78 |
}
|
79 |
)
|
|
|
140 |
print(f"\nDEBUG: Processing query: {query}")
|
141 |
|
142 |
# Get search results using the browser
|
143 |
+
search_results = self.researcher.run(f"Search for information about: {query}")
|
144 |
print(f"\nDEBUG: Search completed. Results:\n{search_results}")
|
145 |
|
146 |
# Analyze the results
|