
    pi                        d dl mZ d dlZd dlmZmZmZmZ d dlm	Z	 d dl
Z
ddlmZ ed   Zh dZ	 	 	 	 dd	Z	 	 	 	 dd
Zy)    )annotationsN)AnyLiteralOptionalcast)assert_never   )is_list)objectarraystringintegernumberbooleannull>
   	date-timeuridateipv4ipv6timeuuidemaildurationhostnamec                @    | j                  d      dk(  r	d| vrd| d<   | S )aU  Transforms a JSON schema of type string to ensure it conforms to the API's expectations.

    Specifically, it ensures that if the schema is of type "string" and does not already
    specify a "format", it sets the format to "text".

    Args:
        schema: The original JSON schema.

    Returns:
        The transformed JSON schema.
    typer   formattext)get)schemas    a/opt/services/ai/voice_agent/venv/lib/python3.12/site-packages/anthropic/lib/_parse/_transform.pyget_transformed_stringr#   #   s+     zz&X%(&*@!xM    c           	        t        j                  |       r*t        | t        j                        r| j                         } i }i | } | j                  dd      }|||d<   |S | j                  dd      }|-i }||d<   |j                         D ]  \  }}t        |      ||<    | j                  dd      }| j                  dd      }| j                  dd      }	| j                  dd      }
t        |      r'|D cg c]  }t        t        d|             c}|d<   nvt        |	      r'|	D cg c]  }t        t        d|             c}|d<   nDt        |
      r'|
D cg c]  }t        t        d|             c}|d<   n|t        d	      ||d<   | j                  d
d      }|||d
<   | j                  dd      }|||d<   |dk(  rq| j                  di       j                         D ci c]  \  }}|t        |       c}}|d<   | j                  dd       d|d<   | j                  dd      }|||d<   n|dk(  r*| j                  dd      }|r|t        v r||d<   n}|r{|| d<   nu|dk(  rN| j                  dd      }|t        |      |d<   | j                  dd      }||dk(  s|dk(  r||d<   n*|(|| d<   n"|dk(  s|dk(  s|dk(  s|dk(  s|nt        |       | rJ|j                  d
      }||dz   nddz   dj                  d  | j                         D              z   d!z   |d
<   |S c c}w c c}w c c}w c c}}w )"a  
    Transforms a JSON schema to ensure it conforms to the API's expectations.

    Args:
        json_schema (Dict[str, Any]): The original JSON schema.

    Returns:
        The transformed JSON schema.

    Examples:
        >>> transform_schema(
        ...     {
        ...         "type": "integer",
        ...         "minimum": 1,
        ...         "maximum": 10,
        ...         "description": "A number",
        ...     }
        ... )
        {'type': 'integer', 'description': 'A number

{minimum: 1, maximum: 10}'}
    z$refNz$defsr   anyOfoneOfallOfdict[str, Any]z>Schema must have a 'type', 'anyOf', 'oneOf', or 'allOf' field.descriptiontitler   
propertiesadditionalPropertiesFrequiredr   r   r   itemsminItemsr      r   r   r   r   z

 {z, c              3  0   K   | ]  \  }}| d |   yw)z: N ).0keyvalues      r"   	<genexpr>z#transform_schema.<locals>.<genexpr>   s     Pjc53%r%)Ps   })inspectisclass
issubclasspydantic	BaseModelmodel_json_schemapopr/   transform_schemar
   r   
ValueErrorSupportedStringFormatsr   r    join)json_schemastrict_schemarefdefsstrict_defsnamer!   type_any_ofone_ofall_ofvariantr*   r+   r7   prop_schemar.   r   r/   	min_itemss                       r"   rB   rB   6   s   . {#
;@R@R(S!335$&M![/K
//&$
'C
 #f??7D)D&(!,g JJL 	9LD& 0 8K	9 '2oofd&CE__Wd+F__Wd+F__Wd+Fvci!jX_"248H'3R"S!jg	ci!jX_"248H'3R"S!jg	ci!jX_"248H'3R"S!jg=]^^ %f//-6K'2m$OOGT*E!&gGRWcegGhGnGnGp'
3C3C!+..'
l# 	.505,-??:t4(0M*%	(	40f 66&,M(#$*K!	'	.%5e%<M'"OOJ5	 Y!^yA~(1M*%"&/K
#	)	u	1Uh5F%SY/]b]jU #''6%0%<[6!"iiPK<M<M<OPPQ  	m$ C "k!j!j '
s   9L,+L1L6,L;)r!   r)   returnr)   )rF   z)type[pydantic.BaseModel] | dict[str, Any]rS   r)   )
__future__r   r;   typingr   r   r   r   typing_extensionsr   r>   _utilsr
   SupportedTypesrD   r#   rB   r5   r$   r"   <module>rY      s^    "  / / *   &q:qqr$   