File size: 972 Bytes
01aa6b9
 
 
 
 
afb4047
01aa6b9
 
 
 
 
 
 
 
 
 
 
 
afb4047
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from typing import Any, Callable, List, Optional, cast

from langchain_tavily import TavilySearch  # type: ignore[import-not-found]

from src.config import Configuration
from src.custom_tools import wikipedia, files, downloads

def search(query: str) -> Optional[dict[str, Any]]:
    """Search for general web results.

    This function performs a search using the Tavily search engine, which is designed
    to provide comprehensive, accurate, and trusted results. It's particularly useful
    for answering questions about current events.
    """
    configuration = Configuration.from_context()
    wrapped = TavilySearch(max_results=configuration.max_search_results)
    return cast(dict[str, Any], wrapped.invoke({"query": query}))

TOOLS: List[Callable[..., Any]] = [
    search,
    wikipedia.get_wiki_page_sections,
    wikipedia.get_wiki_page_by_section,
    downloads.download_file,
    files.read_python,
    files.read_excel,
    files.transcribe_audio,
    ]