
    j                        d dl mZmZmZmZmZmZmZ erd dlm	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 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y+),    )SetListTYPE_CHECKINGDictAnyOptionalSequence)schemasc                       e Zd Zy)OpikExceptionN__name__
__module____qualname__     h/Users/manta/Documents/Projects/TheRoad-I1/backend/.venv/lib/python3.12/site-packages/opik/exceptions.pyr   r          r   r   c                       e Zd Zy)(DatasetItemUpdateOperationRequiresItemIdNr   r   r   r   r   r      r   r   r   c                       e Zd Zy)ContextExtractorNotSetNr   r   r   r   r   r      r   r   r   c                       e Zd Zy)ConfigurationErrorNr   r   r   r   r   r      r   r   r   c                   X     e Zd Z	 ddedee   dee   deee      f fdZdefdZ xZS )	ScoreMethodMissingArguments
score_namemissing_required_argumentsavailable_keysunused_mapping_argumentsc                 x    || _         || _        || _        || _        t        |   | j                                y N)r   r   r   r    super__init___get_error_message)selfr   r   r   r    	__class__s        r   r$   z$ScoreMethodMissingArguments.__init__   s:     %*D',(@%0023r   returnc                     d| j                    d| j                   d| j                   d}| j                  r|d| j                   z  }|S )NzThe scoring method z is missing arguments: aS  . These keys were not present in either the dataset item or the dictionary returned by the evaluation task. You can either update the dataset or evaluation task to return this key or use the `scoring_key_mapping` to map existing items to the expected arguments. The available keys found in the dataset item and evaluation task output are: . z; Some keys in `scoring_key_mapping` didn't match anything: )r   r   r   r    r&   messages     r   r%   z.ScoreMethodMissingArguments._get_error_message%   sk    !$//!22I$JiJiIj k\ ]a\o\o[pprt 	 ((TUYUrUrTsttGr   r"   )	r   r   r   strr	   r   r$   r%   __classcell__r'   s   @r   r   r      sQ     =A44 %-SM4 !	4
 #+8C="94	C 	r   r   c                       e Zd ZdZy)MetricComputationErrorz2Exception raised when a metric cannot be computed.Nr   r   r   __doc__r   r   r   r1   r1   1   s    <r   r1   c                       e Zd ZdZy)EvaluationErrorz*Exception raised when an evaluation fails.Nr2   r   r   r   r5   r5   7   s    4r   r5   c                       e Zd ZdZy)JSONParsingErrorzFException raised when we fail to parse an LLM response to a dictionaryNr2   r   r   r   r7   r7   =   s    Pr   r7   c                   4    e Zd Zdee   dee   fdZdefdZy)*PromptPlaceholdersDontMatchFormatArgumentsprompt_placeholdersformat_argumentsc                 L    || _         || _        |j                  |      | _        y r"   )r:   r;   symmetric_difference)r&   r:   r;   s      r   r$   z3PromptPlaceholdersDontMatchFormatArguments.__init__D   s(    #6  0$7$L$L%
!r   r(   c                     dt        | j                         dt        | j                         dt        | j                         dS )NziThe `prompt.format(**kwargs)` arguments must exactly match the prompt placeholders. Prompt placeholders: z. Format arguments: z. Difference: r*   )listr:   r;   r=   r&   s    r   __str__z2PromptPlaceholdersDontMatchFormatArguments.__str__K   sQ    $$()A)A$B#C D!!%d&;&;!< = > 9 9:;2?	
r   N)r   r   r   r   r-   r$   rA   r   r   r   r9   r9   C   s)    
CH 
C 

 
r   r9   c                   0    e Zd ZdZdededefdZdefdZy)	PromptTemplateStructureMismatchzyException raised when attempting to create a prompt version with a different template structure than the existing prompt.prompt_nameexisting_structureattempted_structurec                 .    || _         || _        || _        y r"   rD   rE   rF   )r&   rD   rE   rF   s       r   r$   z(PromptTemplateStructureMismatch.__init__W   s     '"4#6 r   r(   c                 V    d| j                    d| j                   d| j                   dS )NzPrompt with name 'z$' already exists and has immutable 'z' template structure, not 'z'. rH   r@   s    r   rA   z'PromptTemplateStructureMismatch.__str__^   s=     !1!1 2 3''((CDD\D\C]]`b	
r   Nr   r   r   r3   r-   r$   rA   r   r   r   rC   rC   T   s1     D77477NQ7
 
r   rC   c                       e Zd Zy)ExperimentNotFoundNr   r   r   r   rL   rL   e   r   r   rL   c                       e Zd Zy)DatasetNotFoundNr   r   r   r   rN   rN   i   r   r   rN   c                       e Zd ZdZy)DatasetVersionNotFoundz5Exception raised when a dataset version is not found.Nr2   r   r   r   rP   rP   m   s    ?r   rP   c                   H     e Zd ZdZdeded   ded   f fdZdefdZ xZS )	GuardrailValidationFailedz3Exception raised when a guardrail validation fails.r,   validation_resultszschemas.ValidationResultfailed_validationsc                 N    || _         || _        || _        t        |   |       y r"   )r,   rS   rT   r#   r$   )r&   r,   rS   rT   r'   s       r   r$   z"GuardrailValidationFailed.__init__v   s)     "4"4!r   r(   c                 :    | j                    d| j                   dS )Nz. Failed validations: 
)r,   rT   r@   s    r   rA   z!GuardrailValidationFailed.__str__   s!    ,,5d6M6M5NbQQr   )	r   r   r   r3   r-   r   r$   rA   r.   r/   s   @r   rR   rR   s   sA    =	"	" !!;<	" !!;<		"R Rr   rR   c                   6    e Zd ZdZdeeef   defdZdefdZ	y)OpikCloudRequestsRateLimitedz=Exception raised when the Opik Cloud limits the request rate.headersretry_afterc                      || _         || _        y r"   rZ   r[   )r&   rZ   r[   s      r   r$   z%OpikCloudRequestsRateLimited.__init__   s    &r   r(   c                 <    d| j                    d| j                   dS )Nz)Requests rate limited. Response headers: z, retry after: z secondsr]   r@   s    r   rA   z$OpikCloudRequestsRateLimited.__str__   s$    :4<<.X\XhXhWiiqrrr   N)
r   r   r   r3   r   r-   r   floatr$   rA   r   r   r   rY   rY      s.    G'S#X 'U 's sr   rY   c                   >    e Zd ZdZdedee   fdZdefdZdefdZy)	ValidationErrorz)Exception raised when a validation fails.prefixfailure_reasonsc                      || _         || _        y r"   _prefix_failure_reasons)r&   rb   rc   s      r   r$   zValidationError.__init__   s     /r   r(   c                 :    d| j                    d| j                   S )NzValidation failed in z(): re   r@   s    r   rA   zValidationError.__str__   s     &t||nD9N9N8OPPr   c                 <    d| j                    d| j                   dS )NzValidationError(prefix=z, failure_reasons=)re   r@   s    r   __repr__zValidationError.__repr__   s$    (6HI^I^H__`aar   N)	r   r   r   r3   r-   r   r$   rA   rk   r   r   r   ra   ra      s8    30s 0T#Y 0Q Qb# br   ra   c                   ,    e Zd ZdZdeddfdZdefdZy)BaseLLMErrorz0Base class for all LLM errors during evaluation.r,   r(   Nc                     || _         y r"   r,   r+   s     r   r$   zBaseLLMError.__init__   s	    r   c                      d| j                    S )NzLLM infrastructure error: ro   r@   s    r   rA   zBaseLLMError.__str__   s    +DLL>::r   rJ   r   r   r   rm   rm      s$    :  ; ;r   rm   c                       e Zd ZdZy)SearchTimeoutErrorz)Exception raised when a search times out.Nr2   r   r   r   rr   rr      s    3r   rr   c                       e Zd ZdZy)AgentConfigNotFoundz^Exception raised when no agent config blueprint is found for the requested env/version/latest.Nr2   r   r   r   rt   rt      s    hr   rt   c                   0    e Zd ZdZdededdfdZdefdZy)LLMJudgeParseErrorzRaised when LLMJudge output fails validation.

    Carries the partial ``ScoreResult`` list so callers can inspect what was
    parsed before the error was raised.
    resultsr,   r(   Nc                      || _         || _        y r"   )rw   r,   )r&   rw   r,   s      r   r$   zLLMJudgeParseError.__init__   s    r   c                     | j                   S r"   ro   r@   s    r   rA   zLLMJudgeParseError.__str__   s    ||r   )r   r   r   r3   r?   r-   r$   rA   r   r   r   rv   rv      s-     s t  r   rv   N)typingr   r   r   r   r   r   r	   opik.guardrailsr
   	Exceptionr   r   r   r   r   r1   r5   r7   r9   rC   rL   rN   rP   rR   rY   ra   rm   rr   rt   rv   r   r   r   <module>r}      s
   J J J'	I 		} 		] 		 	- 4	] 		m 		} 	
 
"
m 
"	 		m 		] 	R R$s= sbm b;= ;	 		- 	 r   