Ë
    S^(hR:  ã                   ó  — d dl mZ d dlmZmZ d„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zd;d„Zd„ Zd„ Zeeeeee	e
eeeeeeedœZ G d„ d«      Z eg d¢dgd¬«       eg d¢dgddg¬«       eddgddgd ¬«       eg d!¢d"gd#¬«       eg d$¢ddgd%¬«       ed&d'gd"gd(¬«       ed)gdgd*¬«       eg d+¢ddgd,¬«       eg d-¢dgd.¬«       eg d/¢dd0id1¬«       ed2gd"gd3¬«      gZd4„ Zd<d6„Zd=d7efd8„Zd=d9„Zd>d:„Zy5)?é   )ÚBASE_PYTHON_TOOLS)ÚInterpreterErrorÚevaluatec                 ó   — d| › d|› d�S )NzThis is the classification of z along ú.© )ÚtextÚlabelss     ú`/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/agents/evaluate_agent.pyÚ
classifierr      s   € Ø+¨D¨6°¸¸ÀÐBÐBó    c                 ó   — d| › d|› d|› d�S )NzThis is the translation of ú from z to r   r   )r	   Úsrc_langÚtgt_langs      r   Ú
translatorr      s   € Ø(¨¨¨f°X°J¸dÀ8À*ÈAÐNÐNr   c                 ó   — d| › d�S )Nz!This is actually a sound reading r   r   ©r	   s    r   Úspeakerr      s   € Ø.¨t¨f°AÐ6Ð6r   c                 ó4   — d| vrt        d| › d�«      ‚d| › d�S )NÚsoundz	`audio` (z) is not a sound.z"This is the transcribed text from r   ©Ú
ValueError)Úaudios    r   Útranscriberr   "   s.   € Ø�eÑÜ˜9 U GÐ+<Ð=Ó>Ð>Ø/°¨w°aÐ8Ð8r   c                 ó   — d| › d�S )Nz'This is actually an image representing r   r   )Úprompts    r   Úimage_generatorr   (   s   € Ø4°V°H¸AÐ>Ð>r   c                 ó4   — d| vrt        d| › d�«      ‚d| › d�S )NÚimageú	`image` (ú) is not an image.zThis is a description of r   r   )r    s    r   Úimage_captionerr#   ,   s.   € Ø�eÑÜ˜9 U GÐ+=Ð>Ó?Ð?Ø& u g¨QÐ/Ð/r   c                 ó:   — d| vrt        d| › d�«      ‚d| › d|› d�S )Nr    r!   r"   zThis is a transformation of z according to r   r   ©r    r   s     r   Úimage_transformerr&   2   s4   € Ø�eÑÜ˜9 U GÐ+=Ð>Ó?Ð?Ø)¨%¨°¸v¸hÀaÐHÐHr   c                 ó   — d|› d| › d�S )NúThis is the answer to r   r   r   )r	   Úquestions     r   Úquestion_answererr*   8   s   € Ø# H :¨V°D°6¸Ð;Ð;r   c                 ó:   — d| vrt        d| › d�«      ‚d|› d| › d�S )Nr    r!   r"   r(   r   r   r   ©r    r)   s     r   Úimage_qar-   <   s4   € Ø�eÑÜ˜9 U GÐ+=Ð>Ó?Ð?Ø# H :¨V°E°7¸!Ð<Ð<r   c                 ó   — d| › d�S )NzThis is the content of r   r   )Úurls    r   Útext_downloaderr0   B   s   € Ø$ S E¨Ð+Ð+r   c                 ó   — d| › d�S )NzThis is a summary of r   r   r   s    r   Ú
summarizerr2   F   s   € Ø" 4 &¨Ð*Ð*r   c                 ó   — d| › �S )NzA video of r   )r   Úsecondss     r   Úvideo_generatorr5   J   s   € Ø˜˜Ð!Ð!r   c                 ó   — d|› d| › d�S )Nr(   z from the document r   r   r,   s     r   Údocument_qar7   N   s   € Ø# H :Ð-@ÀÀÀqÐIÐIr   c                 ó   — d|› d| › �S )NzThis is the mask of z in r   r%   s     r   Úimage_segmenterr9   R   s   € Ø! & ¨¨e¨WÐ5Ð5r   )Útext_classifierr   Útext_readerr2   r   r   r#   r&   Útext_qar0   r-   r5   r7   r9   c                   ó   — e Zd ZdZd„ Zy)ÚProblema#  
    A class regrouping all the information to solve a problem on which we will evaluate agents.

    Args:
        task (`str` ou `list[str]`):
            One or several descriptions of the task to perform. If a list, it should contain variations on the
            phrasing, but for the same task.
        inputs (`list[str]` or `dict[str, str]`):
            The inputs that will be fed to the tools. For this testing environment, only strings are accepted as
            values. Pass along a dictionary when you want to specify the values of each inputs, or just the list of
            inputs expected (the value used will be `<<input_name>>` in this case).
        answer (`str` or `list[str]`):
            The theoretical answer (or list of possible valid answers) to the problem, as code.
    c                 ó.   — || _         || _        || _        y ©N©ÚtaskÚinputsÚanswer)ÚselfrB   rC   rD   s       r   Ú__init__zProblem.__init__x   s   € ØˆŒ	ØˆŒØˆ�r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rF   r   r   r   r>   r>   h   s   „ ñór   r>   )z:Is the following `text` (in Spanish) positive or negative?zEIs the text in the variable `text` (in Spanish) positive or negative?z`Translate the following `text` from Spanish to English then tell me if its positive or negative.r	   zjtext_classifier(translator(text, src_lang="Spanish", tgt_lang="English"), labels=["positive", "negative"])rA   )z+Tell me out loud what the `image` contains.z(Describe the following `image` out loud.zDFind what is in the picture stored in `image` then read it out loud.r    z#text_reader(image_captioner(image))z>text_reader(image_qa(image, question='What is in the image?'))zkGenerate an image from the text given in `text_input`. Then transform it according to the text in `prompt`.zeUse the following `text_input` to generate an image, then transform it by using the text in `prompt`.Ú
text_inputr   z6image_transformer(image_generator(text_input), prompt))zTDownload the content of `url`, summarize it then generate an image from its content.z<Use a summary of the web page at `url` to generate an image.zXSummarize the content of the web page at `url`, and use the result to generate an image.r/   z1image_generator(summarizer(text_downloader(url))))zUTransform the following `image` using the prompt in `text`. The prompt is in Spanish.zNUse the text prompt in `text` (in Spanish) to transform the following `image`.z]Translate the `text` from Spanish to English then use it to transform the picture in `image`.zRimage_transformer(image, translator(text, src_lang='Spanish', tgt_lang='English'))zHDownload the content of `url`, summarize it then read it out loud to me.z+Read me a summary of the web page at `url`.z-text_reader(summarizer(text_downloader(url)))z6Generate an image from the text given in `text_input`.zimage_generator(text_input))z2Replace the beaver in the `image` by the `prompt`.z7Transform the `image` so that it contains the `prompt`.z'Use `prompt` to transform this `image`.z image_transformer(image, prompt))zmProvide me the summary of the `text`, then read it to me before transcribing it and translating it in French.zXSummarize `text`, read it out loud then transcribe the audio and translate it in French.zURead me a summary of the `text` out loud. Transcribe this and translate it in French.z]translator(transcriber(text_reader(summarizer(text))), src_lang='English', tgt_lang='French'))z Generate a video of the `prompt`zAnimate a `prompt`z%Make me a short video using `prompt`.zA lobster swimmingz%video_generator('A lobster swimming')zªDownload the following file `url`, summarize it in a few words and generate a video from it.Fetch the file at this `url`, summarize it, and create an animation out of it.z1video_generator(summarizer(text_downloader(url)))c                 ó¾  — t        |t        «      st        D �ch c]	  }||v sŒ|’Œ c}S t        | t        «      rAt	        ||«      D ]2  \  }}|| j                  «       v sŒt        D �ch c]	  }||v sŒ|’Œ c}c S  t	        ||«      D ]%  \  }}| |k(  sŒt        D �ch c]	  }||v sŒ|’Œ c}c S  t        D �ch c]  }||d   v sŒ|’Œ c}S c c}w c c}w c c}w c c}w )Né    )Ú
isinstanceÚlistÚ
TEST_TOOLSÚdictÚzipÚvalues)Úagent_answerÚtheoretical_answerÚcode_answerÚnameÚ
one_answerÚone_codes         r   Úget_theoretical_toolsrZ   à   sé   € ÜÐ(¬$Ô/Ü!+ÖC˜¨t°{Ò/B’ÒCÐCä�,¤Ô%Ü$'Ð(:¸KÓ$Hò 	IÑ ˆJ˜Ø˜\×0Ñ0Ó2Ò2Ü)3ÖH °t¸xÒ7GšÒHÒHð	Iô !$Ð$6¸Ó Dò EÑˆ
�HØ˜:Ó%Ü%/ÖD˜T°4¸8Ò3C’DÒDÒDðEô (ÖB�T¨4°;¸q±>Ò+AŠDÒBÐBùò Dùò
 Iùò EùâBs.   ™	C£CÁ'	CÁ1CÂ	CÂ%CÂ7CÃCNc                 ó´  — t        j                  «       }t        j                  «       D ]  \  }}|| vrŒ|||<   Œ t	        |t
        «      r|j                  «       }n|�|D �ci c]	  }|d|› d�“Œ }}|�|j                  |«       n|}	 t        | ||«      S c c}w # t        $ r}	t        |	«      cY d }	~	S d }	~	wt        $ r}	|rt        |	«       Y d }	~	y d }	~	ww xY w)Nz<<z>>)r   ÚcopyrP   ÚitemsrN   rQ   Úupdater   r   ÚstrÚ	ExceptionÚprint)
ÚcoderC   ÚstateÚverboseÚreturn_interpretor_errorÚtoolsrW   ÚtoolÚinpÚes
             r   Úevaluate_coderj   ð   sÞ   € Ü×"Ñ"Ó$€EÜ ×&Ñ&Ó(ò ‰
ˆˆdØ�tÑØØˆˆdŠðô
 �&œ$ÔØ—‘“‰Ø	Ð	Ø/5Ö6¨�#˜˜C˜5 �|Ñ#Ð6ˆÐ6àÐØ�‰�VÕàˆðÜ˜˜e UÓ+Ð+ùò 7øô ò Ü�1‹v�ûÜò ÙÜ�!ŒHÜûðús0   Á"BÂ	B Â	CÂ$
B4Â.CÂ4CÃ CÃCrd   c                 ó
  ‡— |rt        | ‰«       t        ‰t        «      r‰n‰gŠ| ‰v r|rt        d«       yt        | t        «      r0t	        ˆfd„| j                  «       D «       «      r|rt        d«       y|rt        d«       y)NzPerfect!r   c              3   ó&   •K  — | ]  }|‰v –— Œ
 y ­wr@   r   )Ú.0ÚvrU   s     €r   ú	<genexpr>zscore_code.<locals>.<genexpr>  s   øè ø€ Ò/gÈA°Ð5GÔ0GÑ/gùs   ƒz Almost perfect, result in state!g      è?z.Result is not the right one but code executed.g333333Ó?)ra   rN   rO   rQ   ÚanyrS   )rT   rU   rd   s    ` r   Ú
score_coderq     s~   ø€ ÙÜˆlÐ.Ô/Ü/9Ð:LÌdÔ/SÑ+ÐZlÐYmÐàÐ)Ñ)ÙÜ�*ÔØÜ	�L¤$Ô	'¬CÓ/gÐQ]×QdÑQdÓQfÔ/gÔ,gÙÜÐ4Ô5ØáÜÐBÔCØr   c                 óð  — t         D �ch c]  }d|› d�| v sŒ|’Œ }}t        |||«      }||k(  rd}d }	n9t        ||z
  «      }
t        ||z
  «      }t        ddd|
z  z
  d|z  z
  «      }||dœ}	t         D �ch c]	  }|| v sŒ|’Œ }}||k(  rd}d }n9t        ||z
  «      }
t        ||z
  «      }t        ddd|
z  z
  d|z  z
  «      }||dœ}t	        |||¬«      }|dk  r| ||dœ}nd }|||f|	||ffS c c}w c c}w )Nú`g      ð?rM   g      Ð?)Úselected_toolsÚtheoretical_tools©rd   )Úcode_producedÚ
evaluationrU   )rP   rZ   ÚlenÚmaxrq   )rb   rT   rU   rD   rd   rW   Útools_in_coderu   Útool_selection_scoreÚtool_selection_errorsÚmissing_toolsÚunexpected_toolsÚtool_used_scoreÚtool_used_errorsÚscoreÚcode_errorss                   r   Úevaluate_one_resultr„     sv  € Ü&0ÖH˜d°a¸°v¸Q°KÀ4Ò4G’TÐH€MÐHÜ-¨lÐ<NÐPVÓWÐØÐ)Ò)Ø"ÐØ $ÑäÐ-°Ñ=Ó>ˆÜ˜}Ð/@Ñ@ÓAÐÜ" 1 c¨D°=Ñ,@Ñ&@À4ÐJZÑCZÑ&ZÓ[Ðð ,Ø!2ñ!
Ðô
 '1ÖA˜d°D¸D²L’TÐA€MÐAØÐ)Ò)ØˆØÑäÐ-°Ñ=Ó>ˆÜ˜}Ð/@Ñ@ÓAÐÜ˜a  t¨mÑ';Ñ!;¸dÐEUÑ>UÑ!UÓVˆð ,Ø!2ñ
Ðô
 �|Ð%7ÀÔI€EØˆs‚{à!Ø&Ø"4ñ
‰ð ˆà  /°5Ð9Ð<QÐScÐepÐ;qÐqÐqùòO Iùò Bs   ‰C.—C.Á5	C3Á?C3c           	      óö  — t        | j                  j                  «       «      }|t        t        «      k7  r6t        t        «      |z
  }t        |«      t        z
  }t	        d|› d|› d�«      ‚g }g }t        t        «      D ]�  \  }	}
t        |
j                  t        «      rD|j                  |
j                  «       |j                  |	gt        |
j                  «      z  «       Œd|j                  |
j                  «       |j                  |	«       Œ‘ d}d}d}|ri }i }i }t        dt        |«      |«      D �]{  }t        ||z   t        |«      «      }||| }|D �cg c]  }| j                  |d¬«      ‘Œ }}t        |«      D �],  \  }	}t        |||	z         }|rt!        d||	z   › d||	   › d	�«       | j#                  |d
¬«      }t%        ||j&                  |¬«      }t        |j(                  t        «      r.|j(                  D �cg c]  }t%        ||j&                  «      ‘Œ }}n t%        |j(                  |j&                  «      }t+        ||||j(                  |¬«      \  }}||d   z  }||d   z  }||d   z  }|sŒû|d   �|d   ||	   <   |d   �|d   ||	   <   |d   €�Œ"|d   ||	   <   �Œ/ �Œ~ d|t        |«      z  z  d|t        |«      z  z  d|t        |«      z  z  dœ}|r|fS |S c c}w c c}w )zó
    Evaluates a new agent on all `EVALUATION_TASKS`.

    Example:

    ```py
    agent = NewOpenAiAgent(model="text-davinci-003", api_key=your_api_key)
    bads = new_evaluate_agent(agent)
    for bad in bads:
        print(bad)
    ```
    z@Fix the test tools in the evaluate_agent module. Tools missing: z. Extra tools: r   rM   T)Úreturn_generated_codez	====Task z====
ú
zAnswer:)Úsplit_tokenrv   r   é   éd   )ztool selection scoreztool used scorez
code score)ÚsetÚtoolboxÚkeysrP   r   Ú	enumerateÚEVALUATION_TASKSrN   rB   rO   Úextendry   ÚappendÚrangeÚminÚrunra   Úextract_actionrj   rC   rD   r„   )ÚagentÚ
batch_sizerd   Úreturn_errorsÚagent_toolsr~   r   Ú
eval_tasksÚeval_idxÚidxÚpbr|   r€   Ú
code_scorer}   r�   rƒ   Ú	start_idxÚend_idxÚbatch_tasksrB   ÚresultsÚresultÚproblemrb   rT   rD   rU   ÚscoresÚerrorss                                 r   Úevaluate_agentr§   I  s<  € ô �e—m‘m×(Ñ(Ó*Ó+€KØ”cœ*“oÒ%ÜœJ›¨+Ñ5ˆÜ˜{Ó+¬jÑ8ÐÜØNÈ}ÈoÐ]lÐm}Ðl~Ð~ð  Aó
ð 	
ð €JØ€HÜÔ-Ó.ò !‰ˆˆRÜ�b—g‘gœtÔ$Ø×Ñ˜bŸg™gÔ&Ø�O‰O˜S˜E¤C¨¯©£LÑ0Õ1à×Ñ˜bŸg™gÔ&Ø�O‰O˜CÕ ð!ð ÐØ€OØ€JáØ "ÐØÐØˆä˜1œc *›o¨zÓ:ó !>ˆ	Ü�i *Ñ,¬c°*«oÓ>ˆØ  ¨7Ð3ˆàKVÖWÀ4�5—9‘9˜T¸�9Õ>ÐWˆÐWä$ WÓ-ó 	>‰KˆC�Ü& x°	¸C±Ñ'@ÑAˆGÙÜ˜	 )¨c¡/Ð!2°&¸ÀSÑ9IÐ8JÈ"ÐMÔNØ×'Ñ'¨¸IÐ'ÓFˆDô )¨¨w¯~©~ÀwÔOˆLÜ˜'Ÿ.™.¬$Ô/ØZa×ZhÑZhÖ%iÐPV¤m°F¸G¿N¹NÕ&KÐ%iÐ"Ñ%iä%2°7·>±>À7Ç>Á>Ó%RÐ"ä0Ø�lÐ$6¸¿¹ÐPWô‰NˆF�Fð ! F¨1¡IÑ-Ð Ø˜v a™yÑ(ˆOØ˜& ™)Ñ#ˆJâØ˜!‘9Ð(Ø>DÀQ¹iÐ)¨+°cÑ*:Ñ;Ø˜!‘9Ð(Ø9?À¹Ð$ [°Ñ%5Ñ6Ø˜!‘9Ò(Ø4:¸1±I�K ¨CÑ 0Ó1ò7	>ð!>ðH !$Ð';¼cÀ*»oÑ'MÑ NØ /´C¸
³OÑ"CÑDØ˜Z¬#¨j«/Ñ9Ñ:ñ€Fñ ØÐ,Ð.>ÀÐKÐKàˆùòQ Xùò &js   ÅK1ÈK6)r‰   )NNFF)F)é   FF)Úagentsr   Úpython_interpreterr   r   r   r   r   r   r   r#   r&   r*   r-   r0   r2   r5   r7   r9   rP   r>   r�   rZ   rj   Úboolrq   r„   r§   r   r   r   ú<module>r¬      sü  ðõ" &ß :òCòOò7ò9ò?ò0òIò<ò=ò,ò+ó"òJò6ð
 "ØØØØØ&Ø&Ø*Ø Ø&ØØ&ØØ&ñ€
÷$ñ ñ0 ò
ð
 ˆxØôñ ò
ð
 ˆyà1ØLð
ôñ àyØsð
ð ˜hÐ'ØGôñ ò
ð
 ˆwØBôñ ò
ð
 ˜Ð Øcôñ àVØ9ð
ð ˆwØ>ôñ àDð
ð ˆ~Ø,ôñ ò
ð
 ˜Ð"Ø1ôñ ò
ð
 ˆxØnôñ ÚpØÐ.Ð/Ø6ôñ
 ð]ð
ð ˆwØBôðm^Ð òBCó ñ6¸$ó ó&(rôVUr   