
    Pis                     N    d e de fdZedk    rddlZ ej        e           dS dS )url_or_space_idsource_directoryc                 r  	
 dd l ddlm} ddlm} ddlm} ddlmm		  |          
 |d          } ||           r| 
                    d          nd ||           j         d	|                                d
t          dt          f	
fd            }|                    d           d S )N    )is_http_url_like)
space_info)FastMCP)abspathis_in_or_equalz
upload-mcp/zhttps://z	.hf.spacefilereturnc                 N    |           } |          st          d|  d           t          |d          5 }                    	 dd|i          }ddd           n# 1 swxY w Y   |                                 |                                d         }	 d	| S )
a  Generate a Gradio File Input for a local file by uploading it to a Gradio app and returning the URL.
        Arguments:
            file: A complete, absolute path to a local file to upload.
        Returns:
            Gradio File Input - A URL to the uploaded file.
        zFile z is not in rbz/gradio_api/uploadfiles)r   Nr   z/gradio_api/file=)
ValueErroropenpostraise_for_statusjson)
r   target_pathfresponseresultr	   httpxr
   source_pathurls
        r/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/gradio/cli/commands/upload_mcp.pyupload_file_to_gradioz#main.<locals>.upload_file_to_gradio   s    gdmm~k;77 	ECTCCkCCDDD+t$$ 	RzzS"<"<"<WaLzQQH	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R!!####00000s   A''A+.A+stdio)	transport)r   gradio_client.utilsr   huggingface_hubr   mcp.server.fastmcpr   gradio.utilsr	   r
   rstrip	subdomaintoolstrrun)r   r   r   r   r   mcpr   r	   r   r
   r   r   s          @@@@@r   mainr+      s1   LLL444444************44444444'*++K
',

C(( J$$S))IO44>IIIXXZZ1C 1C 1 1 1 1 1 1 1 1 1 Z1& GGgG    __main__r   N)r(   r+   __name__typerr)    r,   r   <module>r1      sY   %# % % % % %P zLLLEIdOOOOO r,   