Spaces:
Runtime error
Runtime error
Charles Azam
commited on
Commit
·
bcce487
1
Parent(s):
55e85a1
tmp: maybe add a temporary database
Browse files
src/deepengineer/deepsearch/scawl_web_agent.py
CHANGED
|
@@ -11,6 +11,25 @@ from mistralai import OCRResponse
|
|
| 11 |
from enum import Enum
|
| 12 |
from pathlib import Path
|
| 13 |
import asyncio
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
class ToolNames(Enum):
|
| 16 |
# Search tools
|
|
@@ -32,23 +51,9 @@ class ToolNames(Enum):
|
|
| 32 |
GET_PAGES_CONTENT = "get_pages_content"
|
| 33 |
FIND_IN_MARKDOWN = "find_in_markdown"
|
| 34 |
|
| 35 |
-
class TavilySearchTool(Tool):
|
| 36 |
-
name = ToolNames.TAVILY_SEARCH.value
|
| 37 |
-
description = "Search the web using Tavily API. Good for general web searches with advanced features."
|
| 38 |
-
inputs = {
|
| 39 |
-
"search_query": {
|
| 40 |
-
"type": "string",
|
| 41 |
-
"description": "The search query to execute"
|
| 42 |
-
},
|
| 43 |
-
}
|
| 44 |
-
output_type = "object"
|
| 45 |
-
def forward(self, search_query: str) -> dict:
|
| 46 |
-
result = asyncio.run(tavily_search_async(
|
| 47 |
-
search_query=search_query,
|
| 48 |
-
))
|
| 49 |
-
return result.model_dump()
|
| 50 |
|
| 51 |
-
class
|
|
|
|
| 52 |
name = ToolNames.LINKUP_SEARCH.value
|
| 53 |
description = "Search the web using Linkup API. Good for deep research with sourced answers."
|
| 54 |
inputs = {
|
|
@@ -288,8 +293,6 @@ def create_web_search_agent(model_id="deepseek/deepseek-chat"):
|
|
| 288 |
|
| 289 |
return web_search_agent
|
| 290 |
|
| 291 |
-
|
| 292 |
-
|
| 293 |
def create_web_search_agent_with_pdf_analysis(markdown: OCRResponse, model_id="deepseek/deepseek-chat"):
|
| 294 |
"""Create a web search agent that also includes PDF analysis capabilities."""
|
| 295 |
|
|
|
|
| 11 |
from enum import Enum
|
| 12 |
from pathlib import Path
|
| 13 |
import asyncio
|
| 14 |
+
from typing import Literal
|
| 15 |
+
from deepengineer.webcrawler.utils import sanitize_filename
|
| 16 |
+
from deepengineer.common_path import DATA_DIR
|
| 17 |
+
from deepengineer.webcrawler.async_search import SearchResult
|
| 18 |
+
|
| 19 |
+
class DataBase():
|
| 20 |
+
def __init__(self):
|
| 21 |
+
self.storage_path = DATA_DIR
|
| 22 |
+
self.storage_path.mkdir(exist_ok=True, parents=True)
|
| 23 |
+
self.sources = dict[str, SearchResult]
|
| 24 |
+
|
| 25 |
+
def add_sources(self, sources: list[SearchResult]):
|
| 26 |
+
for source in sources:
|
| 27 |
+
self.sources[source.url] = source
|
| 28 |
+
|
| 29 |
+
def get_sources_by_url(self, url: str) -> SearchResult:
|
| 30 |
+
return self.sources[url]
|
| 31 |
+
|
| 32 |
+
|
| 33 |
|
| 34 |
class ToolNames(Enum):
|
| 35 |
# Search tools
|
|
|
|
| 51 |
GET_PAGES_CONTENT = "get_pages_content"
|
| 52 |
FIND_IN_MARKDOWN = "find_in_markdown"
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
+
class SearchTool(Tool):
|
| 56 |
+
provider: Literal["tavily", "linkup"]
|
| 57 |
name = ToolNames.LINKUP_SEARCH.value
|
| 58 |
description = "Search the web using Linkup API. Good for deep research with sourced answers."
|
| 59 |
inputs = {
|
|
|
|
| 293 |
|
| 294 |
return web_search_agent
|
| 295 |
|
|
|
|
|
|
|
| 296 |
def create_web_search_agent_with_pdf_analysis(markdown: OCRResponse, model_id="deepseek/deepseek-chat"):
|
| 297 |
"""Create a web search agent that also includes PDF analysis capabilities."""
|
| 298 |
|