o
    h<                     @  s  d dl mZ d dlmZ d dlmZmZ er>ddlmZ ddl	m
Z
mZ ddlmZmZmZ ddlmZ dd	lmZmZmZ dd
lmZ eG dd dZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZ G dd deZ!dS )    )annotations)	dataclass)TYPE_CHECKINGAny   )Agent)InputGuardrailResultOutputGuardrailResult)ModelResponseRunItemTResponseInputItem)RunContextWrapper)ToolGuardrailFunctionOutputToolInputGuardrailToolOutputGuardrailpretty_print_run_error_detailsc                   @  sT   e Zd ZU dZded< ded< ded< ded	< d
ed< ded< ded< dddZdS )RunErrorDetailsz:Data collected from an agent run when an exception occurs.zstr | list[TResponseInputItem]inputzlist[RunItem]	new_itemszlist[ModelResponse]raw_responsesz
Agent[Any]
last_agentzRunContextWrapper[Any]context_wrapperzlist[InputGuardrailResult]input_guardrail_resultszlist[OutputGuardrailResult]output_guardrail_resultsreturnstrc                 C  s   t | S Nr   )self r   R/var/www/html/openai_agents/venv/lib/python3.10/site-packages/agents/exceptions.py__str__    s   zRunErrorDetails.__str__N)r   r   )__name__
__module____qualname____doc____annotations__r!   r   r   r   r    r      s   
 r   c                      s,   e Zd ZU dZded< d
 fdd	Z  ZS )AgentsExceptionz0Base class for all exceptions in the Agents SDK.zRunErrorDetails | Nonerun_dataargsobjectr   Nonec                   s   t  j|  d | _d S r   )super__init__r(   )r   r)   	__class__r   r    r-   )   s   
zAgentsException.__init__)r)   r*   r   r+   r"   r#   r$   r%   r&   r-   __classcell__r   r   r.   r    r'   $      
 r'   c                      ,   e Zd ZU dZded< d fddZ  ZS )MaxTurnsExceededz>Exception raised when the maximum number of turns is exceeded.r   messagec                      || _ t | d S r   r5   r,   r-   r   r5   r.   r   r    r-   3      zMaxTurnsExceeded.__init__r5   r   r0   r   r   r.   r    r4   .   r2   r4   c                      r3   )ModelBehaviorErrorzException raised when the model does something unexpected, e.g. calling a tool that doesn't
    exist, or providing malformed JSON.
    r   r5   c                   r6   r   r7   r8   r.   r   r    r-   ?   r9   zModelBehaviorError.__init__r:   r0   r   r   r.   r    r;   8   s   
 r;   c                      r3   )	UserErrorz<Exception raised when the user makes an error using the SDK.r   r5   c                   r6   r   r7   r8   r.   r   r    r-   I   r9   zUserError.__init__r:   r0   r   r   r.   r    r<   D   r2   r<   c                      .   e Zd ZU dZded< 	 d fddZ  ZS )InputGuardrailTripwireTriggered8Exception raised when a guardrail tripwire is triggered.r   guardrail_resultc                   $   || _ t d|jjj d d S Nz
Guardrail  triggered tripwirer@   r,   r-   	guardrailr/   r"   r   r@   r.   r   r    r-   T      z(InputGuardrailTripwireTriggered.__init__)r@   r   r0   r   r   r.   r    r>   N   
   
 r>   c                      r=   ) OutputGuardrailTripwireTriggeredr?   r	   r@   c                   rA   rB   rD   rF   r.   r   r    r-   a   rG   z)OutputGuardrailTripwireTriggered.__init__)r@   r	   r0   r   r   r.   r    rI   [   rH   rI   c                      8   e Zd ZU dZded< 	 ded< 	 d fddZ  ZS )	#ToolInputGuardrailTripwireTriggeredzCException raised when a tool input guardrail tripwire is triggered.ToolInputGuardrail[Any]rE   r   outputc                   (   || _ || _t d|jj d d S )NzTool input guardrail rC   rE   rM   r,   r-   r/   r"   r   rE   rM   r.   r   r    r-   q      z,ToolInputGuardrailTripwireTriggered.__init__)rE   rL   rM   r   r0   r   r   r.   r    rK   h      
 rK   c                      rJ   )	$ToolOutputGuardrailTripwireTriggeredzDException raised when a tool output guardrail tripwire is triggered.ToolOutputGuardrail[Any]rE   r   rM   c                   rN   )NzTool output guardrail rC   rO   rP   r.   r   r    r-      rQ   z-ToolOutputGuardrailTripwireTriggered.__init__)rE   rT   rM   r   r0   r   r   r.   r    rS   w   rR   rS   N)"
__future__r   dataclassesr   typingr   r   agentr   rE   r   r	   itemsr
   r   r   run_contextr   tool_guardrailsr   r   r   util._pretty_printr   r   	Exceptionr'   r4   r;   r<   r>   rI   rK   rS   r   r   r   r    <module>   s(    


