
    ~h_                        d dl mZ d dlmZ ddlmZmZmZ ddlm	Z	m
Z
 e G d d             Z G d d	e
      Z G d
 de
      Z G d de
      Z G d de
      Z G d de
      Z G d de
      Z G d de
      Z G d de
      Z G d de
      Z G d de	      ZeeefD  ci c]  } | j,                  |  c} Zg dZyc c} w )    )	dataclass)Any   )BASE_BUILTIN_MODULESBASE_PYTHON_TOOLSevaluate_python_code)PipelineToolToolc                   T    e Zd ZU eed<   eeef   ed<   eed<   eed<   eed<   eed<   y)PreToolnameinputsoutput_typetaskdescriptionrepo_idN)__name__
__module____qualname__str__annotations__dicttype     T/opt/mcp/mcp-sentiment/venv/lib/python3.12/site-packages/smolagents/default_tools.pyr   r      s+    
IcN
ILr   r   c                   N     e Zd ZdZdZddddiZdZdd fd	
Zded
efdZ	 xZ
S )PythonInterpreterToolpython_interpreterzRThis is a tool that evaluates python code. It can be used to perform calculations.codestringz%The python code to run in interpreterr   r   N)authorized_importsc                   |t        t        t                    | _        n)t        t        t              t        |      z        | _        ddd| j                   ddi| _        t
        | _        t        | _        t        | (  |i | y )Nr    r!   zThe code snippet to evaluate. All variables used in this snippet must be defined in this same snippet, else you will get an error. This code can only import the following python libraries: .r"   )listsetr   r#   r   r   base_python_toolsr   python_evaluatorsuper__init__)selfr#   argskwargs	__class__s       r   r+   zPythonInterpreterTool.__init__1   s    %&*3/C+D&ED#&*3/C+DsK]G^+^&_D# mmq  nE  nE  mF  FGH
 "3 4$)&)r   returnc                     i }t        | j                  ||| j                  | j                        d         }dt        |d          d| S )N)statestatic_toolsr#   r   zStdout:
_print_outputsz	
Output: )r   r)   r(   r#   )r,   r    r2   outputs       r   forwardzPythonInterpreterTool.forwardC   sg    !!!33#'#:#:	 " 
 
 3u%5678
6(KKr   )r   r   r   r   r   r   r   r+   r   r6   __classcell__r/   s   @r   r   r   &   sG    DfKB
F K15 *$
LC 
LC 
Lr   r   c                   6    e Zd ZdZdZddddiZdZdedefdZy	)
FinalAnswerToolfinal_answerz-Provides a final answer to the given problem.answeranyzThe final answer to the problemr"   r0   c                     |S Nr   )r,   r<   s     r   r6   zFinalAnswerTool.forwardV   s    r   N)	r   r   r   r   r   r   r   r   r6   r   r   r   r:   r:   P   s4    DAK7XYZFKc c r   r:   c                   ,    e Zd ZdZdZddddiZdZd Zy)	UserInputTool
user_inputz,Asks for user's input on a specific questionquestionr!   zThe question to ask the userr"   c                 "    t        | d      }|S )Nz => Type your answer here:)input)r,   rC   rB   s      r   r6   zUserInputTool.forward`   s    hZ'ABC
r   N)r   r   r   r   r   r   r   r6   r   r   r   rA   rA   Z   s&    D@K8<Z[\FKr   rA   c                   f     e Zd ZdZdZdZddddiZdZdded	e	d
z  f fdZ
dedefdZddZ xZS )DuckDuckGoSearchToolap  Web search tool that performs searches using the DuckDuckGo search engine.

    Args:
        max_results (`int`, default `10`): Maximum number of search results to return.
        rate_limit (`float`, default `1.0`): Maximum queries per second. Set to `None` to disable rate limiting.
        **kwargs: Additional keyword arguments for the `DDGS` client.

    Examples:
        ```python
        >>> from smolagents import DuckDuckGoSearchTool
        >>> web_search_tool = DuckDuckGoSearchTool(max_results=5, rate_limit=2.0)
        >>> results = web_search_tool("Hugging Face")
        >>> print(results)
        ```
    
web_searchzqPerforms a duckduckgo web search based on your query (think a Google search) then returns the top search results.queryr!   The search query to perform.r"   max_results
rate_limitNc                     t         |           || _        || _        |rd|z  nd| _        d| _        	 ddlm}  |di || _	        y # t        $ r}t        d      |d }~ww xY w)N      ?        r   )DDGSzpYou must install package `duckduckgo_search` to run this tool: for instance run `pip install duckduckgo-search`.r   )
r*   r+   rK   rL   _min_interval_last_request_timeduckduckgo_searchrP   ImportErrorddgs)r,   rK   rL   r.   rP   er/   s         r   r+   zDuckDuckGoSearchTool.__init__{   su    &$1;S:-"%	.
 N6N		  	 C	s   A 	A"AA"r0   c           
         | j                          | j                  j                  || j                        }t	        |      dk(  rt        d      |D cg c]  }d|d    d|d    d|d	     }}d
dj                  |      z   S c c}w )N)rK   r   7No results found! Try a less restrictive/shorter query.[title](href)
body## Search Results



)_enforce_rate_limitrU   textrK   len	Exceptionjoin)r,   rI   resultsresultpostprocessed_resultss        r   r6   zDuckDuckGoSearchTool.forward   s      "))..D4D4D.Ew<1UVVjq r`f1VG_$5Rv7Gs6RX>JZ![ r r&5J)KKK !ss   Bc                     dd l }| j                  sy |j                         }|| j                  z
  }|| j                  k  r|j	                  | j                  |z
         |j                         | _        y Nr   timerL   rR   rQ   sleepr,   rl   nowelapseds       r   ra   z(DuckDuckGoSearchTool._enforce_rate_limit   _     iik///T'''JJt))G34"&))+r   )
   rN   r0   N)r   r   r   __doc__r   r   r   r   intfloatr+   r   r6   ra   r7   r8   s   @r   rG   rG   e   s^      D JK9WXYFK#C #%$, #LS LS L.r   rG   c                   f     e Zd ZdZdZddddddd	d
ZdZddef fdZddede	dz  defdZ
 xZS )GoogleSearchToolrH   z\Performs a google web search for your query then returns a string of the top search results.r!   rJ   r"   integerz-Optionally restrict results to a certain yearT)r   r   nullable)rI   filter_yearproviderc                     t         |           dd l}|| _        |dk(  r
d| _        d}n	d| _        d}|j                  |      | _        | j                  t        d| d      y )	Nr   serpapiorganic_resultsSERPAPI_API_KEYorganicSERPER_API_KEYz%Missing API key. Make sure you have 'z' in your env variables.)r*   r+   osr|   organic_keygetenvapi_key
ValueError)r,   r|   r   api_key_env_namer/   s       r   r+   zGoogleSearchTool.__init__   st     y 0D0(D/yy!12<<DEUDVVnopp  r   NrI   r{   r0   c                 *   dd l }| j                  dk(  r|| j                  ddd}d}n|| j                  d}d}|d	| d
| |d<   |j                  ||      }|j                  dk(  r|j                         }nt        |j                               | j                  |j                         vr#|t        d| d| d      t        d| d      t        || j                           dk(  r|d| nd}d| d| dS g }	| j                  |v rst        || j                           D ]X  \  }
}d}d|v rd|d   z   }d}d|v rd|d   z   }d}d|v rd|d   z   }|
 d|d    d|d     d!| | d| 
}|	j                  |       Z d"d#j                  |	      z   S )$Nr   r~   googlez
google.com)qr   enginegoogle_domainzhttps://serpapi.com/search.json)r   r   z https://google.serper.dev/searchzcdr:1,cd_min:01/01/z,cd_max:12/31/tbsparams   zNo results found for query: 'z' with filtering on year=z8. Use a less restrictive query or do not filter on year.z '. Use a less restrictive query.z with filter year= zNo results found for ''z;. Try with a more general query, or remove the year filter.datez
Date published: sourcez	
Source: snippet
. [rZ   r[   link)z## Search Results
r`   )requestsr|   r   getstatus_codejsonr   r   keysrd   rc   	enumerateappendre   )r,   rI   r{   r   r   base_urlresponserf   year_filter_messageweb_snippetsidxpagedate_publishedr   r   redacted_versions                   r   r6   zGoogleSearchTool.forward   s-   ==I%<<"!-	F 9H <<F :H"1+n[MZF5M<<<83&mmoGX]]_--7<<>1&3E7:ST_S`  aY  Z   "?wFf ghhwt''()Q.HSH_$6{m"Deg+E7!4G3H  ID  E  Ew&&wt/?/?'@A 6	T!#T>%9DL%HNt#)DN:F$"T)_4G&)U#d7m_BtF|nAnM]^d]eeghogp#q ##$456  %v{{<'@@@r   )r~   r?   )r   r   r   r   r   r   r   r   r+   ru   r6   r7   r8   s   @r   rx   rx      sb    DtK"3QRJ
F Kq q8AS 8AsTz 8AS 8Ar   rx   c                        e Zd ZdZdZdZddddiZdZ	 	 	 	 	 	 dd	ed
edede	de	de
dz  f fdZddZdedefdZde	defdZdedefdZ xZS )ApiWebSearchToola  Web search tool that performs API-based searches.
    By default, it uses the Brave Search API.

    This tool implements a rate limiting mechanism to ensure compliance with API usage policies.
    By default, it limits requests to 1 query per second.

    Args:
        endpoint (`str`): API endpoint URL. Defaults to Brave Search API.
        api_key (`str`): API key for authentication.
        api_key_name (`str`): Environment variable name containing the API key. Defaults to "BRAVE_API_KEY".
        headers (`dict`, *optional*): Headers for API requests.
        params (`dict`, *optional*): Parameters for API requests.
        rate_limit (`float`, default `1.0`): Maximum queries per second. Set to `None` to disable rate limiting.

    Examples:
        ```python
        >>> from smolagents import ApiWebSearchTool
        >>> web_search_tool = ApiWebSearchTool(rate_limit=50.0)
        >>> results = web_search_tool("Hugging Face")
        >>> print(results)
        ```
    rH   zPerforms a web search for a query and returns a string of the top search results formatted as markdown with titles, URLs, and descriptions.rI   r!   rJ   r"   Nendpointr   api_key_nameheadersr   rL   c                    dd l }t        | 	          |xs d| _        |xs d| _        |xs |j                  | j                        | _        |xs d| j                  i| _        |xs ddi| _        || _	        |rd|z  nd| _
        d| _        y )	Nr   z.https://api.search.brave.com/res/v1/web/searchBRAVE_API_KEYzX-Subscription-Tokencountrr   rN   rO   )r   r*   r+   r   r   r   r   r   r   rL   rQ   rR   )	r,   r   r   r   r   r   rL   r   r/   s	           r   r+   zApiWebSearchTool.__init__  s     	 T$T(;O>"))D,=,=">H#94<<"H-"$1;S:-"%r   r0   c                     dd l }| j                  sy |j                         }|| j                  z
  }|| j                  k  r|j	                  | j                  |z
         |j                         | _        y rj   rk   rn   s       r   ra   z$ApiWebSearchTool._enforce_rate_limit(  rq   r   c                 "   dd l }| j                          i | j                  d|i}|j                  | j                  | j
                  |      }|j                          |j                         }| j                  |      }| j                  |      S )Nr   r   )r   r   )
r   ra   r   r   r   r   raise_for_statusr   extract_resultsformat_markdown)r,   rI   r   r   r   datarf   s          r   r6   zApiWebSearchTool.forward5  sz      ",DKK,e,<<t||F<S!!#}}&&t,##G,,r   r   c           	          g }|j                  di       j                  dg       D ]-  }|j                  |d   |d   |j                  dd      d       / |S )Nwebrf   rZ   urlr   r   )rZ   r   r   )r   r   )r,   r   rf   rg   s       r   r   z ApiWebSearchTool.extract_results@  sc    hhub)--i< 	FNN /&-PVPZPZ[hjlPmn	 r   rf   c                     |syddj                  t        |d      D cg c]  \  }}| d|d    d|d	    d
|d     c}}      z   S c c}}w )NzNo results found.r_   r`   r   )startr   rZ   r[   r   r]   r   )re   r   )r,   rf   r   rg   s       r   r   z ApiWebSearchTool.format_markdownH  sn    && $-WA#>C %s6'?+2fUm_C}@U?VW*
 
 	
s    A
)r   r   r   NNrN   rs   )r   r   r   rt   r   r   r   r   r   r   rv   r+   ra   r6   r&   r   r   r7   r8   s   @r   r   r      s    . D `K9WXYFK #&&& & 	&
 & & DL&*.	-S 	-S 	-D T 
t 
 
r   r   c                        e Zd ZdZdZddddiZdZddedef fd	Z	ded
efdZ
ded
efdZded
efdZded
efdZd Zded
efdZ xZS )WebSearchToolrH   zPerforms a web search for a query and returns a string of the top search results formatted as markdown with titles, links, and descriptions.rI   r!   rJ   r"   rK   r   c                 >    t         |           || _        || _        y r?   )r*   r+   rK   r   )r,   rK   r   r/   s      r   r+   zWebSearchTool.__init__Y  s    &r   r0   c                 x    | j                  |      }t        |      dk(  rt        d      | j                  |      S )Nr   rX   )searchrc   rd   parse_results)r,   rI   rf   s      r   r6   zWebSearchTool.forward^  s9    ++e$w<1UVV!!'**r   c                     | j                   dk(  r| j                  |      S | j                   dk(  r| j                  |      S t        d| j                          )N
duckduckgobingzUnsupported engine: )r   search_duckduckgosearch_bingr   )r,   rI   s     r   r   zWebSearchTool.searchd  sS    ;;,&))%00[[F"##E**3DKK=ABBr   rf   c                 t    ddj                  |D cg c]  }d|d    d|d    d|d     c}      z   S c c}w )	Nr_   r`   rY   rZ   r[   r   r]   r   )re   )r,   rf   rg   s      r   r   zWebSearchTool.parse_resultsl  sO    &]deSYq!F6N#33vm7L6MNe*
 
 	
es   5
c                     dd l }|j                  dd|iddi      }|j                          | j                         }|j	                  |j
                         |j                  S )Nr   z!https://lite.duckduckgo.com/lite/r   z
User-AgentzMozilla/5.0)r   r   )r   r   r   _create_duckduckgo_parserfeedrb   rf   )r,   rI   r   r   parsers        r   r   zWebSearchTool.search_duckduckgoq  s`    <</<!=1   

 	!!#//1HMM"~~r   c                 2    ddl m}  G d d|      } |       S )Nr   )
HTMLParserc                   0     e Zd Z fdZd Zd Zd Z xZS )CWebSearchTool._create_duckduckgo_parser.<locals>.SimpleResultParserc                 h    t         |           g | _        i | _        d| _        d| _        d| _        y )NF)r*   r+   rf   currentcapture_titlecapture_descriptioncapture_link)r,   r/   s    r   r+   zLWebSearchTool._create_duckduckgo_parser.<locals>.SimpleResultParser.__init__  s4     "!!%*"+0($)!r   c                     t        |      }|dk(  r|j                  d      dk(  rd| _        y |dk(  r|j                  d      dk(  rd| _        y |dk(  r|j                  d      dk(  rd| _        y y y )	Naclasszresult-linkTtdzresult-snippetspanz	link-text)r   r   r   r   r   )r,   tagattrss      r   handle_starttagzSWebSearchTool._create_duckduckgo_parser.<locals>.SimpleResultParser.handle_starttag  sq    U#:%))G"4"E)-D&D[UYYw%7;K%K/3D,F]uyy'9['H(,D% (I]r   c                    |dk(  r| j                   rd| _         y |dk(  r| j                  rd| _        y |dk(  r| j                  rd| _        y |dk(  rxh d| j                  j	                         k  rXdj                  | j                  d         | j                  d<   | j                  j                  | j                         i | _        y y y )	Nr   Fr   r   tr>   r   rZ   r    r   )r   r   r   r   r   re   rf   r   )r,   r   s     r   handle_endtagzQWebSearchTool._create_duckduckgo_parser.<locals>.SimpleResultParser.handle_endtag  s    #:$"4"4).D&D[T%=%=/4D,F]t'8'8(-D%D[74<<;L;L;NN69hht||M?Z6[]3++DLL9') O !r   c                 \   | j                   r|j                         | j                  d<   y | j                  rI| j                  j	                  dg        | j                  d   j                  |j                                y | j                  r!d|j                         z   | j                  d<   y y )NrZ   r   zhttps://r   )r   stripr   r   
setdefaultr   r   )r,   r   s     r   handle_datazOWebSearchTool._create_duckduckgo_parser.<locals>.SimpleResultParser.handle_data  s    %%,0JJLDLL)--LL++M2>LL/66tzz|D&&+5

+DDLL( 'r   )r   r   r   r+   r   r   r   r7   r8   s   @r   SimpleResultParserr     s    *-*Er   r   )html.parserr   )r,   r   r   s      r   r   z'WebSearchTool._create_duckduckgo_parser~  s    *'	E '	ER "##r   c                 h   dd l mc m} dd l}|j	                  d|dd      }|j                          |j                  |j                        }|j                  d      }|d | j                   D cg c]5  }|j                  d      |j                  d      |j                  d	      d
7 }}|S c c}w )Nr   zhttps://www.bing.com/searchrss)r   formatr   z.//itemrZ   r   r   )rZ   r   r   )xml.etree.ElementTreeetreeElementTreer   r   r   
fromstringrb   findallrK   findtext)	r,   rI   ETr   r   rootitemsitemrf   s	            r   r   zWebSearchTool.search_bing  s    **<<)%0   
 	!!#}}X]]+Y' 0 0 01
 	 w/f-#}}];
 
 
s   1:B/)rr   r   )r   r   r   r   r   r   r   ru   r   r+   r6   r&   r   r   r   r   r   r7   r8   s   @r   r   r   S  s    D aK9WXYFKC c 
+S +S +CC CD C
T 
c 

s t ,$\  r   r   c                   d     e Zd ZdZdZddddiZdZddef fdZd	e	d
ede	fdZ
de	de	fdZ xZS )VisitWebpageToolvisit_webpagezjVisits a webpage at the given url and reads its content as a markdown string. Use this to browse webpages.r   r!   z The url of the webpage to visit.r"   max_output_lengthc                 0    t         |           || _        y r?   )r*   r+   r   )r,   r   r/   s     r   r+   zVisitWebpageTool.__init__  s    !2r   content
max_lengthr0   c                 T    t        |      |k  r|S |d |dz   d| dz   || dz  d  z   S )N   z3
..._This content has been truncated to stay below z characters_...
)rc   )r,   r   r   s      r   _truncate_contentz"VisitWebpageTool._truncate_content  sQ    w<:%N%jAo&DZLPabczkQ&()*	
r   c                    	 dd l }dd l}ddlm} ddlm} 	 |j                  |d      }|j                           ||j                        j                         }|j                  dd|      }| j                  || j                        S # t
        $ r}t        d      |d }~ww xY w# |j                  j                  $ r Y y	|$ r}d
t        |       cY d }~S d }~wt         $ r}dt        |       cY d }~S d }~ww xY w)Nr   )markdownify)RequestExceptionz}You must install packages `markdownify` and `requests` to run this tool: for instance run `pip install markdownify requests`.   )timeoutz\n{3,}r`   z?The request timed out. Please try again later or check the URL.zError fetching the webpage: zAn unexpected error occurred: )rer   r   requests.exceptionsr  rT   r   r   rb   r   subr   r   
exceptionsTimeoutr   rd   )	r,   r   r  r   r   r  rV   r   markdown_contents	            r   r6   zVisitWebpageTool.forward  s    		/<
	=||C|4H%%'  +8==9??A  "vvi9IJ))*:D<R<RSS  	 P	" ""** 	UT 	;1#a&:: 	=3CF8<<	=sM   B	 A1B& 		B#BB#&C<C<CC<C<$C71C<7C<)i@  )r   r   r   r   r   r   r   ru   r+   r   r   r6   r7   r8   s   @r   r   r     sg    Dt  	=
F K3# 3
 
# 
# 
=3 =3 =r   r   c            	       h     e Zd ZdZdZdZddddiZdZ	 	 	 	 dded	ed
edef fdZ	dedefdZ
 xZS )WikipediaSearchToola  
    Search Wikipedia and return the summary or full text of the requested article, along with the page URL.

    Attributes:
        user_agent (`str`): Custom user-agent string to identify the project. This is required as per Wikipedia API policies.
            See: https://foundation.wikimedia.org/wiki/Policy:Wikimedia_Foundation_User-Agent_Policy
        language (`str`, default `"en"`): Language in which to retrieve Wikipedia article.
            See: http://meta.wikimedia.org/wiki/List_of_Wikipedias
        content_type (`Literal["summary", "text"]`, default `"text"`): Type of content to fetch. Can be "summary" for a short summary or "text" for the full article.
        extract_format (`Literal["HTML", "WIKI"]`, default `"WIKI"`): Extraction format of the output. Can be `"WIKI"` or `"HTML"`.

    Example:
        ```python
        >>> from smolagents import CodeAgent, InferenceClientModel, WikipediaSearchTool
        >>> agent = CodeAgent(
        >>>     tools=[
        >>>            WikipediaSearchTool(
        >>>                user_agent="MyResearchBot (myemail@example.com)",
        >>>                language="en",
        >>>                content_type="summary",  # or "text"
        >>>                extract_format="WIKI",
        >>>            )
        >>>        ],
        >>>     model=InferenceClientModel(),
        >>> )
        >>> agent.run("Python_(programming_language)")
        ```
    wikipedia_searchzbSearches Wikipedia and returns a summary or full text of the given topic, along with the page URL.rI   r!   z!The topic to search on Wikipedia.r"   
user_agentlanguagecontent_typeextract_formatc                    t         |           	 dd l}|st	        d      || _        || _        || _        |j                  j                  |j                  j                  d}||vrt	        d      ||   | _        |j                  | j
                  | j                  | j                        | _        y # t        $ r}t        d      |d }~ww xY w)Nr   z_You must install `wikipedia-api` to run this tool: for instance run `pip install wikipedia-api`zIUser-agent is required. Provide a meaningful identifier for your project.)WIKIHTMLz8Invalid extract_format. Choose between 'WIKI' or 'HTML'.)r  r  r  )r*   r+   wikipediaapirT   r   r  r  r  ExtractFormatr  r  r  	Wikipediawiki)	r,   r  r  r  r  r  rV   extract_format_mapr/   s	           r   r+   zWikipediaSearchTool.__init__%  s     		
 hii$ ( !..33 ..33

 !33WXX0@ **tObOb + 
	-  	q	s   B5 5	C>C

Cr0   c                 f   	 | j                   j                  |      }|j                         sd| dS |j                  }|j                  }| j
                  dk(  r|j                  }n| j
                  dk(  r|j                  }nyd| d| d| S # t        $ r}d	t        |       cY d }~S d }~ww xY w)
NzNo Wikipedia page found for 'z'. Try a different query.summaryrb   u>   ⚠️ Invalid `content_type`. Use either 'summary' or 'text'.u   ✅ **Wikipedia Page:** z

**Content:** u   

🔗 **Read more:** z"Error fetching Wikipedia summary: )
r  r   existsrZ   fullurlr  r  rb   rd   r   )r,   rI   r   rZ   r   rb   rV   s          r   r6   zWikipediaSearchTool.forwardI  s    	A99>>%(D;;=6ug=VWWJJE,,C  I-||""f,yyW-eW4EdVKcdgchii 	A7Ax@@	As)   0B AB 
B 	B0B+%B0+B0)z Smolagents (myemail@example.com)enrb   r  )r   r   r   rt   r   r   r   r   r   r+   r6   r7   r8   s   @r   r  r    s    : DvK>
F K ="$"
"
 "
 	"

 "
HAS AS Ar   r  c                   N     e Zd ZdZdZdZddddiZdZ fdZd	 Z	d
 Z
d Z xZS )SpeechToTextToolzopenai/whisper-large-v3-turbozTThis is a tool that transcribes an audio into text. It returns the transcribed text.transcriberaudiozBThe audio to transcribe. Can be a local path, an url, or a tensor.r"   r!   c                 N    ddl m}m} || _        || _        t
        |   |       S )Nr   )WhisperForConditionalGenerationWhisperProcessor)transformers.models.whisperr#  r$  pre_processor_classmodel_classr*   __new__)clsr-   r.   r#  r$  r/   s        r   r(  zSpeechToTextTool.__new__l  s$    a"29ws##r   c                 `    ddl m}  ||      j                         }| j                  |d      S )Nr   )
AgentAudiopt)return_tensors)agent_typesr+  to_rawpre_processor)r,   r!  r+  s      r   encodezSpeechToTextTool.encodes  s.    +5!((*!!%!==r   c                 >    | j                   j                  |d         S )Ninput_features)modelgenerate)r,   r   s     r   r6   zSpeechToTextTool.forwardy  s    zz""6*:#;<<r   c                 B    | j                   j                  |d      d   S )NT)skip_special_tokensr   )r0  batch_decode)r,   outputss     r   decodezSpeechToTextTool.decode|  s$    !!..wD.QRSTTr   )r   r   r   default_checkpointr   r   r   r   r(  r1  r6   r:  r7   r8   s   @r   r  r  `  sD    8hKD_
F K$>=Ur   r  )
r   r   r:   rA   r   rG   rx   r   r  r  N)dataclassesr   typingr   local_python_executorr   r   r   toolsr	   r
   r   r   r:   rA   rG   rx   r   r   r   r  r  r   TOOL_MAPPING__all__)
tool_classs   0r   <module>rC     s   " "  
 &   'LD 'LTd D 7.4 7.tTAt TAnZ
t Z
zmD m`7=t 7=t`A$ `AFU| UF 	 OOZs   #B?