Format: text/x-python
⬇ Download File (1.1 KB)
   1  from .schemas import ToolDefinition, FetchNewsParams, FetchArxivParams, FetchDDGParams, FetchTorrentsParams, FetchWikiParams, FetchIMDBParams, FetchYouTubeParams, FetchFinanceParams
   2  from modules.search.web import (
   3      fetch_torrents,
   4      fetch_news,
   5      fetch_wikipedia,
   6      fetch_imdb,
   7      fetch_youtube,
   8      fetch_finance,
   9      search_google
  10  )
  11  from modules.search.news import fetch_news
  12  from modules.search.arxiv import fetch_arxiv
  13  
  14  def schema_to_tool(name: str, model: type) -> ToolDefinition:
  15      return ToolDefinition(
  16          name=name,
  17          description=model.__doc__.strip(),
  18          parameters=model.model_json_schema()
  19      )
  20  
  21  tool_definitions: list[ToolDefinition] = [
  22      schema_to_tool("fetch_news", FetchNewsParams),
  23      schema_to_tool("fetch_arxiv", FetchArxivParams),
  24      schema_to_tool("search_google", FetchDDGParams),
  25      schema_to_tool("fetch_torrents", FetchTorrentsParams),
  26      schema_to_tool("fetch_wikipedia", FetchWikiParams),
  27      schema_to_tool("fetch_imdb", FetchIMDBParams),
  28      schema_to_tool("fetch_youtube", FetchYouTubeParams),
  29      schema_to_tool("fetch_finance", FetchFinanceParams)
  30  ]