
     `i                    z    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dS )    )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hostnameschemadict[str, Any]returnc                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)r   s    s/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/anthropic/lib/_parse/_transform.pyget_transformed_stringr%   #   s4     zz&X%%(&*@*@!xM    json_schema)type[pydantic.BaseModel] | dict[str, Any]c                   t          j        |           r.t          | t          j                  r|                                 } i }i | } |                     dd          }|||d<   |S |                     dd          }|3i }||d<   |                                D ]\  }}t          |          ||<   |                     dd          }|                     dd          }|                     dd          }	|                     dd          }
t          |          rd |D             |d<   nTt          |	          rd	 |	D             |d<   n5t          |
          rd
 |
D             |d<   n|t          d          ||d<   |                     dd          }|||d<   |                     dd          }|||d<   |dk    rnd |                     di                                           D             |d<   |                     dd           d|d<   |                     dd          }|||d<   n|dk    r/|                     dd          }|r|t          v r||d<   n|r|| d<   n|dk    r\|                     dd          }|t          |          |d<   |                     dd          }||dk    s|dk    r||d<   n2||| d<   n*|dk    s|dk    s|dk    s|dk    s|nt          |           | rY|                    d          }||dz   nd d!z   d"                    d# |                                 D                       z   d$z   |d<   |S )%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allOfc                H    g | ]}t          t          d |                     S r   transform_schemar   .0variants     r$   
<listcomp>z$transform_schema.<locals>.<listcomp>f   -    !j!j!jX_"248H'3R3R"S"S!j!j!jr&   c                H    g | ]}t          t          d |                     S r.   r/   r1   s     r$   r4   z$transform_schema.<locals>.<listcomp>h   r5   r&   c                H    g | ]}t          t          d |                     S r.   r/   r1   s     r$   r4   z$transform_schema.<locals>.<listcomp>j   r5   r&   z>Schema must have a 'type', 'anyOf', 'oneOf', or 'allOf' field.descriptiontitler   c                4    i | ]\  }}|t          |          S  )r0   )r2   keyprop_schemas      r$   
<dictcomp>z$transform_schema.<locals>.<dictcomp>z   s4     '
 '
 '
3C3C!+..'
 '
 '
r&   
propertiesadditionalPropertiesFrequiredr   r!   r   itemsminItemsr      r   r   r   r   z

 {z, c              3  *   K   | ]\  }}| d | V  dS )z: Nr;   )r2   r<   values      r$   	<genexpr>z#transform_schema.<locals>.<genexpr>   s4      PPjc53))%))PPPPPPr&   })inspectisclass
issubclasspydantic	BaseModelmodel_json_schemapoprB   r0   r
   
ValueErrorSupportedStringFormatsr   r#   join)r'   strict_schemarefdefsstrict_defsnamer   type_any_ofone_ofall_ofr8   r9   rA   r!   rB   	min_itemss                    r$   r0   r0   6   s   . {## 6
;@R(S(S 6!3355$&M![/K
//&$
'
'C
 #f??7D))D&(!,g JJLL 	9 	9LD& 0 8 8K&1oofd&C&CE__Wd++F__Wd++F__Wd++Fv 
&!j!jci!j!j!jg	 &!j!jci!j!j!jg	 &!j!jci!j!j!jg=]^^^ %f//-66K'2m$OOGT**E!&g'
 '
GRWcegGhGhGnGnGpGp'
 '
 '
l# 	.55505,-??:t44(0M*%	(		400 	+f 666&,M(## 	+$*K!	'		..%5e%<%<M'"OOJ55	 Y!^^yA~~(1M*%%"&/K
#	)		u	11Uh5F5F%SY//]b]jU  
#''66%0%<[6!!"iiPPK<M<M<O<OPPPPPQ  	m$ r&   )r   r   r   r   )r'   r(   r   r   )
__future__r   rK   typingr   r   r   r   typing_extensionsr   rN   _utilsr
   SupportedTypesrS   r%   r0   r;   r&   r$   <module>rd      s    " " " " " "  / / / / / / / / / / / / * * * * * *             &q q q q q qr&   