Spaces:
Running
Running
abdoh-alkhateeb
commited on
Commit
•
3c08e7b
1
Parent(s):
c5f0fb9
Create research_agent.py
Browse files- agents/research_agent.py +19 -0
agents/research_agent.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from .dataset_semantic_search_agent import DatasetSemanticSearchAgent
|
2 |
+
from .google_serper_search_agent import GoogleSerperSearchAgent
|
3 |
+
|
4 |
+
|
5 |
+
class ResearchAgent:
|
6 |
+
def __init__(self, web_sources_path: str = "sources.txt", local_sources_path: str = "articles") -> None:
|
7 |
+
self._google_serper_search_agent = GoogleSerperSearchAgent(web_sources_path)
|
8 |
+
self._dataset_semantic_search_agent = DatasetSemanticSearchAgent(local_sources_path)
|
9 |
+
|
10 |
+
def run(self, themes: list[list[str]]) -> dict[str, dict[str, list]]:
|
11 |
+
sources = {}
|
12 |
+
|
13 |
+
for theme in themes:
|
14 |
+
web_sources = self._google_serper_search_agent.run(theme["query"])
|
15 |
+
dataset_sources = self._dataset_semantic_search_agent.run(theme["query"])
|
16 |
+
|
17 |
+
sources[theme] = {"web_sources": web_sources, "dataset_sources": dataset_sources}
|
18 |
+
|
19 |
+
return sources
|