h%4SSKJrJr SSKJr SSKJrJr SSKrSSK J r SSK r SSK Jr SSKrSSKJr \"5 SSKrSSKrSSKrSSKrSSKJr SS KJr \"\R6"S 5S S S 9r\"\R6"S5S9rS\S\4SjrS\S\S\4SjrS\S\4Sjr S\S\4Sjr!S\S\4Sjr"S\#S\#S\#4Sjr$S\%\&\#-S\#4Sjr'S \S\&4S!jr(S"\S\4S#jr)S$\S\4S%jr*S&\S\ RV4S'jr,S(\%\&\#-S)\S\#4S*jr-S\S+\S\4S,jr.g)-)DuckDuckGoSearchToolGoogleSearchTool)YouTubeTranscriptApi)Supadata SupadataErrorN)fetch_wikipedia_tables)Any) load_dotenv) OpenRouter) ChatMessageOPENROUTER_API_KEYzgoogle/gemini-2.5-flash-previewgffffff?)api_keymodel temperatureSUPADATA_API_KEY)rtextreturnc v[USSS25 USSS2$![an[SU35eSnAff=f)z Returns the reversed version of the text. If you receive some unknown text, that can't be recognized and analyzed, then you need to use this tool to make it clear. Args: text: text to be reversed Return: The reversed text. NzCan't reverse text: )print Exception ValueError)rkwargses R/Users/halyna/Desktop/courses/HuggingFaceAgents/Final_Assignment_Template/tools.py reverse_textrsH5 d4R4jDbDz 5/s3445s 838 event_nameyearc [R"USU35nURnURn[R "U5nSUSU3nU$![ an[U5nSnAN$SnAff=f)a Fetches data about historical event that occured in certain year. Some examples of events: Olympics games, Footbal games, NBA etc. Args: event_name: String name of the event year: String year of the event Return: String with data about the event z in N Content: Tables: ) wikipediapageurlcontentpd read_htmlrr)rrrresultr$r%tablesrs rfetch_historical_event_datar*.sw^^zl$tf5 6F **CnnG-c" F8 4F M -',-sA A4 A//A4itemc l[R[SUS3S9/S9nURR$)z Classifies items to fruits and vegitables Args: item: Item to classify Returns: Text with explanation whether it is a fruit or vegetable. z+Classify whether it is fruit or vegetable: z9. Return only `fruit` or `vegetable` without explanations)r%)messages)llmchatr messager%)r+rresponses rclassify_fruit_vegitabler2HsLxx EdVLEF  H    # ##queryc L[SS9RU5n[U5 U$)a$ Returns web search results for the provided query. Don't use it for Wikipedia queries. For Wikipedia queries use wikipedia_search tool. Important, query is human-language string input, not the URL or key. Args: query: query to search in WEB Return: String with web search results. serpapi)provider)rforwardr)r4rr(s r web_searchr9\s%y 1 9 9% @F &M Mr3c [R"U5nURnURn[R "U5nSUSU3nU$! [ U5nN=f)z Returns wikipedia search results for the provided query. Args: query: query to search in WIKIPEDIA Return: Wikipedia search results. r r!)r"r#r$r%r&r'r)r4rr(r$r%r)s rwikipedia_searchr;nsa^^E "F **CnnG-c" F8 4F M -',s A Aabc X-$)zh Multiply two numbers. Args: a: First number b: Second number Return: The product of the two numbers. )r<r=rs rmultiplyr@s  5Lr3valuesc [U5$)zr Computes sum of provided values Args: values: list of integer or float values Return: Sum of the values sum)rArs r compute_sumrEs v;r3iterablec [U5$)zf Return the length of an iterable. Args: iterable: Any iterable Return: The length of the iterable. )len)rFrs rlengthrIs x=r3 file_pathc[RRU5(d[SU35e[RR [RR U55n[RR U5nURSS5n[RR5n[RRSU5 [R"5n[R"5n[RRX05nUb UR c[#SU35e[RR%U5nU[R&U'[(R*"U5 [(R,"U5 UR R/U5 [1US5n U R35n 0UR4En SU S '[7X5 SSS5 SSS5 SSS5 [9US 5(a=UR:U[lU[R&;a[R&U $$UR=5R?5n [AS U 35 U U[lU[R&;a[R&U $$!,(df  N=f!,(df  N=f!,(df  N=f![Ba=n UR=5nU(a [EU 5"[GU 5S U35SeeSn A ff=f!U[lU[R&;a[R&U ff=f) a Executes a Python file and returns its result. This function takes a path to a Python file, executes it by importing it as a module, and returns the result. The file should contain a function call that produces the result to be returned. This version also executes code under the 'if __name__ == "__main__":' block. Args: file_path (str): Path to the Python file to execute. Returns: Any: The result of executing the Python file. If the file sets a variable named 'result', that value will be returned. Raises: FileNotFoundError: If the specified file does not exist. ImportError: If there was an error importing the Python file. Example: >>> # If example.py contains: result = 2 + 3 >>> execute_python_file('example.py') 5 zFile not found: z.pyrNz Could not load module spec from r__main____name__r(zRESULT PYTHON: z Program output: )$ospathisfileFileNotFoundErrordirnameabspathbasenamereplacesyscopyinsertioStringIO importlibutilspec_from_file_locationloader ImportErrormodule_from_specmodules contextlibredirect_stdoutredirect_stderr exec_moduleopenread__dict__exechasattrr(getvaluestriprrtypestr)rJfile_dir file_name module_nameoriginal_sys_pathstdout_capturestderr_capturespecmodulef file_content namespaceoutputr error_outputs rexecute_python_filer~s4 77>>) $ $"29+ >??wwrwwy9:H  +I##E2.K HHOOAx [[]N[[]N()~~55kM <4;;. @ LM M006#) K  ' ' 79S9S :  KK # #F +i% vvx /v/ (2 *%\- &: 7 68 $ $==% #++ % K( &$,,.446F OF8, -% #++ % K( &/&%: : 7 7* %..0 q'SVH$6|nEFD P  % #++ % K( &ss BK4K#%(K /K<KK# $K4"-K4 K K K K## K1-K44 L;>8L66L;;L>>3M1video_idc V[RRUSS9nUR$)z Returns transcript of YouTube video. Args: video_id: ID of youtube video (Pass in the video ID, NOT the video URL. For a video with the URL https://www.youtube.com/watch?v=12345 the ID is 12345.) Return: Transcript of YouTube video. en)rlang)supadatayoutube transcriptr%)rrrs rtrascript_youtubers+!!,,hT,JJ   r3rQc .[R"U5$)zN Reads xlsx file Args: path: path to xlsx file Return: Pandas dataframe )r& read_excel)rQrs rrrs == r3pandas_column_values column_namec [U5$)z Computes sum on pandas dataframe column Args: pandas_column_values: List with float or integer pandas values column_name: Name of the column Return: Sum of the column rC)rrrs rpandas_column_sumrs # $$r3answerc SUSUS3$)z Prepare the final answer for the user. It should be always used as a last step. Args: query: The initial query of the user answer: The answer to format and return to the user Return: The final answer. z User query: z Final answer from agent: a. Adapt final answer to user request. Final answer should be a number or as few words as possible or a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string. There might be requested exact number, then you need to compress the output so that it was only number without any comments or explanations (float or integer). And on the other hand, the question might request some exact string value. Don't explain it, just return this value (For example, insted of `In response to the question, desired person is X` return only `X`) Again, you don't need to modify or solve answer, you just need to format it properly. r?)r4rrs r final_answerr/s%$X& r3)/ smolagentsrryoutube_transcript_apirrrrr"wikipedia_tables_parserrpandasr&typingr rPdotenvr importlib.utilr]rXr[rdllama_index.llms.openrouterr llama_index.core.typesr getenvr.rprr*r2r9r;floatr@listintrErIr~r DataFramerrrr?r3rrs=7,:   2. II* + + BII&89 :5s55$Cs4$3$S$(c$Cc0  % e  S5[)   S s S)3S)3S)l  #  S r||  %sU{+ %:= %  % Ssr3