
    i              	          d dl mZmZmZ ddlmZmZ ddlmZm	Z	 ddl
mZ ddlZ G d d	e      Z G d
 de      Z G d de      ZddddddddddgdddiddidddddddddgdddZej#                         Zd ed!   d   d"<   d ed"<    ed# e	de e       d$%      &      Z G d' d(ej(                        Zed)k(  r ej.                          yy)*   )pydantic_model_from_json#response_format_from_pydantic_modelrec_strict_json_schema    )	BaseModelValidationError   )ResponseFormat
JSONSchema)UnsetNc                   "    e Zd ZU eed<   eed<   y)StudentnameageN)__name__
__module____qualname__str__annotations__int     ^/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/mistralai/extra/tests/test_utils.pyr   r      s    
I	Hr   r   c                   "    e Zd ZU eed<   eed<   y)ExplanationexplanationoutputN)r   r   r   r   r   r   r   r   r   r      s    Kr   r   c                   (    e Zd ZU ee   ed<   eed<   y)MathDemonstrationstepsfinal_answerN)r   r   r   listr   r   r   r   r   r   r   r      s    r   r   string)titletypeOutputr   r   r   r   object)
propertiesrequiredr$   r%   z$refz#/$defs/ExplanationStepsarray)itemsr$   r%   zFinal Answerr    r!   r    r!   )$defsr)   r*   r$   r%   Fr/   additionalPropertiesjson_schemaT)r   schema_definitiondescriptionstrict)r%   r1   c                       e Zd Zd Zd Zd Zy)TestResponseFormatc                 B   ddi}ddd}dddd}ddd	d
ddd
ddd
ddd
ddd
gd}| j                  t        |t              t        dd             | j                  t        |t              t        dd             | j                  t        |t              t        t	        dd	
      t	        dd
      t	        dd
      t	        dd
      t	        dd
      gd             | j                  t              5  t        |t               d d d        y # 1 sw Y   y xY w)Nr   zJean Dupont   )r   r   extra_value)r   r   extra_fieldzx = -4zStart with the given equation.z8x + 7 = -23r'   z6Subtract 7 from both sides to isolate the term with x.z8x = -23 - 7z(Simplify the right side of the equation.z8x = -30z&Divide both sides by 8 to solve for x.zx = -30 / 8z.Simplify the fraction to get the final answer.)r!   r    r.   )assertEqualr   r   r   r   assertRaisesr   )selfmissing_json_datagood_json_dataextra_json_datacomplex_json_datas        r   test_pydantic_model_from_jsonz0TestResponseFormat.test_pydantic_model_from_jsonF   sw   #]3"/;!(
 % $D,
 $\,
 $N(
 $L+
 $T&#
4 	$^W=B/	
 	$_g>B/	
 	$%68IJ$D-  $\-  $N)  $L,  $T'#, &/	
< / 	A$%6@	A 	A 	As   ;DDc                 J    | j                  t        t              t               y )N)r;   r   r   mathdemo_response_format)r=   s    r   (test_response_format_from_pydantic_modelz;TestResponseFormat.test_response_format_from_pydantic_model   s    /0AB$	
r   c                     t         ddiz  }| j                  t        t               t               | j	                  t
              5  t        |       d d d        y # 1 sw Y   y xY w)Nwrong_value   )mathdemo_schemar;   r   mathdemo_strict_schemar<   
ValueError)r=   invalid_schemas     r   test_rec_strict_json_schemaz.TestResponseFormat.test_rec_strict_json_schema   sW    (M1+=="?35K	
 z* 	3">2	3 	3 	3s   AA"N)r   r   r   rB   rE   rM   r   r   r   r6   r6   E   s    IAV
3r   r6   __main__)utils.response_formatr   r   r   pydanticr   r   modelsr
   r   types.basemodelr   unittestr   r   r   rI   copyrJ   rD   TestCaser6   r   mainr   r   r   <module>rW      s7   
 0 0 $ i 
) 
	  	)6I$,h? '1"

 34

 #1(C .) -2 )--/ IN w  ./E F16 - .)	 0G	 Y3** Y3x zHMMO r   