Ë
    tPêj=  ã                   óJ   — d Z ddlmZmZ ddlmZ dededededeeef   f
d	„Z	y
)a  
Utility module for handling OpenAPI schema generation compatibility with FastAPI 0.120+.

FastAPI 0.120+ has stricter schema generation that fails on certain types like openai.Timeout.
This module provides a compatibility layer to handle these cases gracefully.
é    )ÚAnyÚFinal)Úverbose_proxy_loggerÚtitleÚversionÚdescriptionÚroutesÚreturnc                 ó  ‡— 	 ddl m} ddlmŠ |j                  }ˆfd„}t        |d|«       	  | ||||¬«      }t        |d|«       |S # t        |d|«       w xY w# t        t        f$ r }	t        j                  d|	«       	  | ||||¬«      cY d}	~	S # t        $ rg}
t        |
«      j                  }|d	k(  sd	t        t        |
«      «      v r1t        j                  d
|
«       d|||xs ddœi di idœcY d}
~
cY d}	~	S ‚ d}
~
ww xY wd}	~	ww xY w)aî  
    Generate OpenAPI schema with compatibility handling for FastAPI 0.120+.

    This function patches Pydantic's schema generation to handle non-serializable types
    like openai.Timeout that cause PydanticSchemaGenerationError in FastAPI 0.120+.

    Args:
        get_openapi_func: The FastAPI get_openapi function
        title: API title
        version: API version
        description: API description
        routes: List of routes

    Returns:
        OpenAPI schema dictionary
    r   )ÚGenerateSchema)Úcore_schemac                 ó  •— t        |«      }t        |dd«      }|dk(  rd|v s t        |d«      r$|j                  dk(  r|dk(  r‰j	                  «       S 	 ‰j                  «       S # t        $ r ‰j	                  «       cY S w xY w)z?Patch to handle openai.Timeout and other non-serializable typesÚ
__module__Ú ÚopenaiÚTimeoutÚ__name__)ÚstrÚgetattrÚhasattrr   Ú
str_schemaÚ
any_schemaÚ	Exception)ÚselfÚobjÚobj_strÚ
obj_moduler   s       €úu/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/litellm/proxy/common_utils/openapi_schema_compat.pyÚpatched_unknown_type_schemazCget_openapi_schema_with_compat.<locals>.patched_unknown_type_schema-   s‹   ø€ ô ! ›XˆGÜ '¨¨\¸2Ó >ˆJà˜hÒ&¨9¸Ñ+?Ü˜˜ZÔ(¨S¯\©\¸YÒ-FÈ:ÐYaÒKað #×-Ñ-Ó/Ð/ð0Ø"×-Ñ-Ó/Ð/øÜò 0à"×-Ñ-Ó/Ò/ð0ús   ÁA$ Á$B Á?B Ú_unknown_type_schema)r   r   r   r	   zICould not patch Pydantic schema generation: %s. Trying normal generation.NÚPydanticSchemaGenerationErrorz:PydanticSchemaGenerationError during schema generation: %sz3.0.0r   )r   r   r   Úschemas)ÚopenapiÚinfoÚpathsÚ
components)Ú#pydantic._internal._generate_schemar   Úpydantic_corer   r    ÚsetattrÚImportErrorÚAttributeErrorr   Údebugr   Útyper   r   Úwarning)Úget_openapi_funcr   r   r   r	   r   Úoriginal_unknown_type_schemar   Úopenapi_schemaÚeÚpydantic_errorÚerror_type_namer   s               @r   Úget_openapi_schema_with_compatr5      sP  ø€ ð2LÝFÝ-ð /=×.QÑ.QÐ$ô	0ô* 	�Ð 6Ð8SÔTð		ZÙ$4ØØØ'Øô	%ˆNô �NÐ$:Ð<XÔYàÐøô �NÐ$:Ð<XÕYûô œÐ(ò !ä×"Ñ"Ð#nÐpqÔrð	Ù#ØØØ'Øô	õ øô ò 	ô &*¨.Ó%9×%BÑ%BˆOØÐ"AÒAÐEdÔhkÜ�^Ó$óiñ Fô %×,Ñ,ØPÐR`ôð  'à!&Ø#*Ø'2Ò'8°bñð
  Ø#,¨b /ñ	÷ 	ò 	ð ûð/	þð!úsj   ƒ*A ®A	 ºA Á	AÁA ÁD
Á*DÂBÂD
Â	DÂAC=Ã1DÃ2DÃ6D
Ã<C=Ã=DÄDÄD
N)
Ú__doc__Útypingr   r   Úlitellm._loggingr   r   ÚlistÚdictr5   © ó    r   ú<module>r=      sU   ðñ÷ å 1ðeàðeð ðeð ð	eð
 ðeð 
ˆ#ˆsˆ(�^ôer<   