
    ;3h                         d dl Z d dlZd dlmZ d dlmZ d dlZdZdede	fdZ
ded	ed
eddfdZdedee   fdZdeeeef      dededeeeeef      deeeef      f
dZd ZdedefdZy)    N)Callable)UnionzQwen/Qwen2.5-Coder-32B-Instructsreturnc                 :    	 t        |        y# t        $ r Y yw xY w)NTF)float
ValueError)r   s    S/var/www/html/audio-gradio/venv/lib/python3.12/site-packages/gradio/sketch/utils.py	is_numberr      s#    a s    	objkeyvaluec                    |dk(  r| j                  |d        y |j                         dv r|j                         dk(  | |<   y t        |      rt        |      | |<   y |j	                  d      r|j                  d      s"|j	                  d      r|j                  d      r	|dd | |<   y |j	                  d      r|j                  d	      s"|j	                  d
      r*|j                  d      rt        j                  |      | |<   y || |<   y )N )truefalser   '"   []{})poplowerr   r   
startswithendswithastliteral_eval)r   r   r   s      r
   	set_kwargr!      s    {T	+	+;;=F*C	5	<C


3
ENN3$7%.."52;C


3
ENN3$7%.."5##E*CC    fn_nameinputsc                 2    d|  ddj                  |       dS )Nzdef (z, z):)join)r#   r$   s     r
   
get_headerr(   &   s!    '!DIIf-.b11r"   historyhf_tokenoutput_typesc           
   #   *  K   dt        ||D cg c]  }|d   	 c}       d}t        |      dkD  rbt        |      dk(  r)|d|d   d    dt        |d   d   |d   d          dz  }n+|d	z  }|D ]!  }|d
|d    dt        |d   |d          dz  }# t        |      dkD  rbt        |      dk(  r |dt        |d   d   |d   d          dz  }n4|dz  }t        |      D ]!  \  }}|d| dt        |d   |d          dz  }# |d| d   d    dz  }|dz  }|dz  }|| d   d   gg| dd  z   }	g }
|	D ]0  \  }}|
j	                  d|d       ||
j	                  d|d       2 t        j                  |      }d}|j                  |
dt              D ]u  }||j                  d   j                  j                  xs dz  }d|v rA|j                  d      t        d      z   }|j                  d|      }|dk7  r||| n||d   r| w y c c}w w)Nz5Create a python function with the following header:
`r   z`
r   zThe value of 'z' is passed as:    z.
z"The inputs are passed as follows:
z- 'z'The function should return a value as: z<The function should return a tuple of the following values:
z- index z should be: z0The function should perform the following task: 
a  Return only the python code of the function in your response. Do not wrap the code in backticks or include any description before the response. Return ONLY the function code. Start your response with the header provided. Include any imports inside the function.
a  If using an LLM would help with the task, use the huggingface_hub library. For example:
```python
import huggingface_hub
client = huggingface_hub.InferenceClient()

# For OpenAI style chat API
response = client.chat_completion([{"role": "user", "content": "What is 12*2320?"}], stream=False)
output = response.choices[0].message.content  # a string

# For text completion
output = client.text_generation("What is 12*2320?")  # a string

# For image generation
response = client.text_to_image("A picture of a cat")  # a PIL image
```
If an LLM is not helpful for the task, there is no need to use huggingface_hub. Avoid using other 3rd party libraries (other than numpy, pandas, pydub, pillow if useful) unless necessary.
user)rolecontent	assistant)tokenr   T)streammodelz
```python
z
```r   )r(   lenget_value_description	enumerateappendhuggingface_hubInferenceClientchat_completion
code_modelchoicesdeltar1   indexfind)r)   r*   r#   r$   r+   ifull_promptr@   oprompt_historychat_historyuser_msgbot_msgclientr1   r3   startends                     r
   airL   *   s    WV,qt,-.c5K
6{Qv;!~fQil^;KLabhijbklmbnpvwxpyz{p|L}K~  B  E  EK@@K f3qtf,<=RSTUVSWYZ[\Y]=^<__beef
<1|!FG\]ijk]lmn]oq}~  rA  BC  rD  HE  GF  FI  L  LKOK &l3 hq8E7,?TUVWXUY[\]^[_?`>aadggh<WQZ]O2PK   ]  ]K  K$ #GAJqM23gabkANL+ K'VAB IJK
 ,,8<FG''T'T 5==#))117R7G#MM-03}3EEE,,w.C(+r	'%$wuvFMc -s   HHD4HCHc                      | dddi|}t        |dd       }||S t        | j                        }|j                  d      }d|v r|j	                  d       d|v r|j	                  d       dj                  |      S )NrenderF_value_description | Noner    )getattrextract_value_type_hint__init__splitremover'   )component_classconfig	componentvalue_descriptionvalue_type_hint	all_hintss         r
   r7   r7   m   s    7u77I	+?F$  -o.F.FGO%%e,I Y$::i  r"   funcc                    t        j                  |       }d|j                  v r|j                  d   }|j                  t         j                  j
                  urt        |j                  d      rH|j                  j                  t        u r,dj                  d |j                  j                  D              S t        |j                  d      r|j                  j                  S t        |j                        j                  dd      S y)	Nr   
__origin__rP   c              3   4   K   | ]  }|j                     y w)N)__name__).0args     r
   	<genexpr>z*extract_value_type_hint.<locals>.<genexpr>   s     !T3#,,!Ts   rb   ztyping.r   Any)inspect	signature
parameters
annotation	Parameteremptyhasattrr`   r   r'   __args__rb   strreplace)r^   sigparams      r
   rT   rT   |   s    


D
!C#.. w'7#4#4#:#::((,7$$//58zz!T%:J:J:S:S!TTT)):6''0005++,44YCCr"   )r   rg   collections.abcr   typingr   r:   r=   ro   boolr   dictr!   listr(   tupletyperL   r7   rT   rR   r"   r
   <module>rz      s    
  $  .
  4 c # $ &2 2T#Y 2@%S/"@@ @ sD$'(	@
 uT4Z()@F!( s r"   