o
    i                     @   s   U d dl Z d dlmZmZ d dlmZ d dlZd dlmZ d dl	m
Z
mZ d dlmZmZ d dlmZ d dlmZ d d	lmZ g d
Zeee eee
ef geeB eeeB  B f Zeed< ee ee B Zeed< dee defddZdS )    N)	AwaitableCallable)	TypeAlias)CreateMessageResult)ClientSessionSamplingFnT)LifespanContextTRequestContext)CreateMessageRequestParams)SamplingMessage)ServerSamplingHandler)SamplingHandlerr   SamplingParamsClientSamplingHandlerr   sampling_handlerreturnc                    s.   dt ttf dtdttjjB f fdd}|S )Ncontextparamsr   c              
      s   z& |j || }t|r|I d H }t|tr%tddtjjd|dd}|W S  t	yE } ztjj
tjjt|dW  Y d }~S d }~ww )N	assistantzfastmcp-clienttext)typer   )rolemodelcontent)codemessage)messagesinspectisawaitable
isinstancestrr   mcptypesTextContent	Exception	ErrorDataINTERNAL_ERROR)r   r   resulter    ]/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/fastmcp/client/sampling.py_sampling_handler"   s&   


z3create_sampling_callback.<locals>._sampling_handler)r	   r   r   r   r   r!   r"   r%   )r   r,   r*   r)   r+   create_sampling_callback   s   

r-   )r   collections.abcr   r   typingr   	mcp.typesr!   r   mcp.client.sessionr   r   mcp.shared.contextr   r	   r
   r   r   fastmcp.server.sampling.handlerr   __all__listr    r   __annotations__r   r-   r*   r*   r*   r+   <module>   s4   
 


