
    gPi                    Z   U d dl mZ d dlZd dlZd dlZd dlmZmZmZmZ d dl	m
Z d dlmZmZmZmZmZ ddlmZ dd	lmZ dd
lmZ d)dZd)dZd)dZd)dZd)dZd)dZd)dZej        fZ de!d<   ej"        dk    rg e ej        R Z d*dZ# ed          d+d            Z$d,d"Z%dd#d-d(Z&dS ).    )annotationsN)AnyTypeVarIterablecast)abc)TypeIsRequired	Annotatedget_args
get_origin   )	lru_cache   )InheritsGeneric)is_uniontyptypereturnboolc                2    t          |           t          k    S N)r   r   r   s    i/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/openai/_utils/_typing.pyis_annotated_typer      s    c??i''    c                6    t          |           p| t          k    S r   )r   listr   s    r   is_list_typer      s    sOO"st++r   c                    t          |           p| }|t          j        k    p|t          j        k    p|t          j        k    S r   )r   typing_extensionsSequencetyping_c_abcr   origins     r   is_sequence_typer'      s<    __#F&//i6V_3LiPVZ`ZiPiir   c                Z    t          |           p| }|t          k    p|t          j        k    S )z)If the given type is `typing.Iterable[T]`)r   r   r$   r%   s     r   is_iterable_typer)   "   s)    __#FX:6?!::r   c                :    t          t          |                     S r   )	_is_unionr   r   s    r   is_union_typer,   (   s    Z__%%%r   c                2    t          |           t          k    S r   )r   r
   r   s    r   is_required_typer.   ,   s    c??h&&r   c                2    t          |           t          k    S r   )r   r   r   s    r   
is_typevarr0   0   s     99r   z1tuple[type[typing_extensions.TypeAliasType], ...]_TYPE_ALIAS_TYPES)      tpr   'TypeIs[typing_extensions.TypeAliasType]c               ,    t          | t                    S )zReturn whether the provided argument is an instance of `TypeAliasType`.

    ```python
    type Int = int
    is_type_alias_type(Int)
    # > True
    Str = TypeAliasType("Str", str)
    is_type_alias_type(Str)
    # > True
    ```
    )
isinstancer1   )r4   s    r   is_type_alias_typer8   ;   s     b+,,,r   i  )maxsizec                    t          |           st          |           r5t          t          t          t          |           d                             S | S )Nr   )r.   r   strip_annotated_typer   r   r   r   s    r   r;   r;   K   sL     B 1# 6 6 B#Dx}}Q/?$@$@AAAJr   indexintc                    t          |           }	 t          t          ||                   S # t          $ r}t	          d|  d| d          |d }~ww xY w)NzExpected type z" to have a type argument at index z but it did not)r   r   r   
IndexErrorRuntimeError)r   r<   argserrs       r   extract_type_argrC   S   sp    C==DtD$u+&&& t t tiCiiSXiiijjpssts   , 
AAA)failure_messagegeneric_basestuple[type, ...]rD   
str | Nonec                  t          t          t          |           p|           }||v rt          | |          S t	          |t
                    rbd}|j        D ]}|j        |v r|} n|t          d| d| d          t          ||          }t          |          rt          | |          S |S t          |pd| d|            )a  Given a type like `Foo[T]`, returns the generic type variable `T`.

    This also handles the case where a concrete subclass is given, e.g.
    ```py
    class MyResponse(Foo[bytes]):
        ...

    extract_type_var(MyResponse, bases=(Foo,), index=0) -> bytes
    ```

    And where a generic subclass is given:
    ```py
    _T = TypeVar('_T')
    class MyResponse(Foo[_T]):
        ...

    extract_type_var(MyResponse[bytes], bases=(Foo,), index=0) -> bytes
    ```
    NzFCould not find the generic base class;
This should never happen;
Does z inherit from one of z ?z/Could not resolve inner type variable at index z for )
r   objectr   rC   r7   r   __orig_bases__
__origin__r@   r0   )r   rE   r<   rD   clstarget_base_classbase	extracteds           r   extract_type_var_from_baserP   [   s&   4 vz#-#
.
.C
mU+++ #'' (,& 	 	D-//$(! 0 $DD D2?D D D   %%6>>	i   		0 $C///
m*m\a*m*mhk*m*m
n
nnr   )r   r   r   r   )r4   r   r   r5   )r   r   r   r   )r   r   r<   r=   r   r   )
r   r   rE   rF   r<   r=   rD   rG   r   r   )'
__future__r   sysr#   r!   r   r   r   r   collectionsr   r$   r	   r
   r   r   r   _utilsr   _typesr   _compatr   r+   r   r   r'   r)   r,   r.   r0   TypeAliasTyper1   __annotations__version_infor8   r;   rC   rP    r   r   <module>r[      sT   " " " " " " " 



      / / / / / / / / / / / / % % % % % %                    $ $ $ $ $ $ * * * * * *( ( ( (, , , ,j j j j
; ; ; ;& & & &' ' ' '        IZHgGi  i i i iwB+BV-ABB- - - -  4   t t t t #'Ao Ao Ao Ao Ao Ao Ao Aor   