Spaces:
Running
Running
Update agent.py
Browse files
agent.py
CHANGED
@@ -136,6 +136,9 @@ class ValidatedExcelReader(Tool):
|
|
136 |
# --------------------------
|
137 |
|
138 |
class UniversalLoader(Tool):
|
|
|
|
|
|
|
139 |
def __init__(self):
|
140 |
self.loaders = {
|
141 |
'excel': ValidatedExcelReader(),
|
@@ -274,6 +277,11 @@ class EnhancedExcelReader(Tool):
|
|
274 |
# Cross-Verified Search
|
275 |
# --------------------------
|
276 |
class CrossVerifiedSearch:
|
|
|
|
|
|
|
|
|
|
|
277 |
SOURCES = [
|
278 |
DuckDuckGoSearchTool(),
|
279 |
WikipediaSearchTool(),
|
@@ -288,7 +296,16 @@ class CrossVerifiedSearch:
|
|
288 |
except Exception as e:
|
289 |
continue
|
290 |
return self._consensus(results)
|
291 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
292 |
def _consensus(self, results):
|
293 |
# Simple majority voting implementation
|
294 |
counts = {}
|
@@ -315,12 +332,11 @@ class MagAgent:
|
|
315 |
|
316 |
self.tools = [
|
317 |
UniversalLoader(),
|
318 |
-
|
319 |
ValidatedExcelReader(),
|
320 |
VisitWebpageTool(),
|
321 |
DownloadTaskAttachmentTool(),
|
322 |
SpeechToTextTool(),
|
323 |
-
CrossVerifiedSearch()
|
324 |
]
|
325 |
|
326 |
with open("prompts.yaml") as f:
|
|
|
136 |
# --------------------------
|
137 |
|
138 |
class UniversalLoader(Tool):
|
139 |
+
name = "universal_loader"
|
140 |
+
description = "Loads various file types and web content using appropriate sub-tools."
|
141 |
+
|
142 |
def __init__(self):
|
143 |
self.loaders = {
|
144 |
'excel': ValidatedExcelReader(),
|
|
|
277 |
# Cross-Verified Search
|
278 |
# --------------------------
|
279 |
class CrossVerifiedSearch:
|
280 |
+
name = "cross_verified_search"
|
281 |
+
description = "Searches multiple sources and returns consensus results."
|
282 |
+
inputs = {'query': {'type': 'string', 'description': 'Search query'}}
|
283 |
+
output_type = "string"
|
284 |
+
|
285 |
SOURCES = [
|
286 |
DuckDuckGoSearchTool(),
|
287 |
WikipediaSearchTool(),
|
|
|
296 |
except Exception as e:
|
297 |
continue
|
298 |
return self._consensus(results)
|
299 |
+
|
300 |
+
def forward(self, query: str) -> str:
|
301 |
+
results = []
|
302 |
+
for source in self.SOURCES:
|
303 |
+
try:
|
304 |
+
results.append(source(query))
|
305 |
+
except Exception as e:
|
306 |
+
continue
|
307 |
+
return self._consensus(results)
|
308 |
+
|
309 |
def _consensus(self, results):
|
310 |
# Simple majority voting implementation
|
311 |
counts = {}
|
|
|
332 |
|
333 |
self.tools = [
|
334 |
UniversalLoader(),
|
335 |
+
CrossVerifiedSearch(), # Replaces individual search tools
|
336 |
ValidatedExcelReader(),
|
337 |
VisitWebpageTool(),
|
338 |
DownloadTaskAttachmentTool(),
|
339 |
SpeechToTextTool(),
|
|
|
340 |
]
|
341 |
|
342 |
with open("prompts.yaml") as f:
|