Ë
    µŒj¼  ã                   óÌ   — d dl Z d dlmZmZmZmZmZmZmZ d dl	Z	d dl
mZ d dlmZ d dlmZ d dlmZ dZdZd	ed
ededeeef   fd„Zd	ed
ededeeddf   fd„Z G d„ de«      Zy)é    N)ÚAnyÚDictÚ	GeneratorÚIteratorÚListÚLiteralÚOptional)ÚCallbackManagerForLLMRun)ÚLLM)ÚGenerationChunk)ÚFieldzhttps://chat-api.you.com/smartz!https://chat-api.you.com/researchÚbase_urlÚapi_keyÚkwargsÚreturnc                 óz   — d|i}t        j                  | ||¬«      }|j                  «        |j                  «       S )zŠ
    NOTE: This function can be replaced by a OpenAPI-generated Python SDK in the future,
    for better input/output typing support.
    ú	x-api-key)ÚheadersÚjson)ÚrequestsÚpostÚraise_for_statusr   )r   r   r   r   Úresponses        úf/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langchain_community/llms/you.pyÚ_requestr      s8   € ð
 ˜GÐ$€GÜ�}‰}˜X¨w¸VÔD€HØ×ÑÔØ�=‰=‹?Ðó    c              +   óò  K  — d|i}t        di |¤ddi¤Ž}t        j                  | |d|¬«      }|j                  «        d„ |D «       }	 dd l}|j                  |«      }|j                  «       D ]m  }	|	j                  dv rŒ|	j                  d	k(  r|	j                  –— Œ0|	j                  d
k(  rt        d|	j                  › �«      ‚t        d|	j                  › �«      ‚ y # t        $ r t        d«      ‚w xY w­w)Nr   ÚstreamT)r   r   r   c              3   ó    K  — | ]  }|–— Œ y ­w)N© )Ú.0Ú
bytestrings     r   Ú	<genexpr>z"_request_stream.<locals>.<genexpr>"   s   è ø€ Ð:± :”J±ùs   ‚r   zPCould not import `sseclient`. Please install it with `pip install sseclient-py`.)Úsearch_resultsÚdoneÚtokenÚerrorzError in response: zUnknown event type r    )Údictr   r   r   Ú	sseclientÚ	SSEClientÚImportErrorÚeventsÚeventÚdataÚ
ValueErrorÚNotImplementedError)
r   r   r   r   Úparamsr   Úevent_sourcer)   Úclientr-   s
             r   Ú_request_streamr4      sý   è ø€ ð ˜GÐ$€GÜÑ(�FÑ( 4Ò(€FÜ�}‰}˜X¨w¸tÈ&ÔQ€HØ×ÑÔñ ;±Ó:€Lð

Ûà×$Ñ$ \Ó2ˆð —‘–ˆØ�;‰;Ð4Ñ4ØØ�[‰[˜GÒ#Ø—*‘*ÓØ�[‰[˜GÒ#ÜÐ2°5·:±:°,Ð?Ó@Ð@ä%Ð(;¸E¿K¹K¸=Ð&IÓJÐJñ !øô ò 
ÜðEó
ð 	
ð
üs   ‚AC7Á	C ÁBC7ÃC4Ã4C7c                   ó
  — e Zd ZU dZ edd¬«      Zed   ed<    edd¬«      Ze	e
   ed	<   	 	 dd
e
de	ee
      de	e   dede
f
d„Z	 	 dd
e
de	ee
      de	e   dedee   f
d„Zede
fd„«       Zede
fd„«       Zede
fd„«       Zy)ÚYoua‰  Wrapper around You.com's conversational Smart and Research APIs.

    Each API endpoint is designed to generate conversational
    responses to a variety of query types, including inline citations
    and web results when relevant.

    Smart Endpoint:
    - Quick, reliable answers for a variety of questions
    - Cites the entire web page URL

    Research Endpoint:
    - In-depth answers with extensive citations for a variety of questions
    - Cites the specific web page snippet relevant to the claim

    To connect to the You.com api requires an API key which
    you can get at https://api.you.com.

    For more information, check out the documentations at
    https://documentation.you.com/api-reference/.

    Args:
        endpoint: You.com conversational endpoints. Choose from "smart" or "research"
        ydc_api_key: You.com API key, if `YDC_API_KEY` is not set in the environment
    ÚsmartzCYou.com conversational endpoints. Choose from "smart" or "research")Údescription)r7   ÚresearchÚendpointNz>You.com API key, if `YDC_API_KEY` is not set in the envriomentÚydc_api_keyÚpromptÚstopÚrun_managerr   r   c                 ór   — |rt        d«      ‚d|i}t        | j                  fd| j                  i|¤Ž}|d   S )Nú5Stop words are not implemented for You.com endpoints.Úqueryr   Úanswer)r0   r   Ú_request_endpointÚ_api_key)Úselfr<   r=   r>   r   r1   r   s          r   Ú_callz	You._call`   sL   € ñ Ü%ØGóð ð ˜6Ð"ˆÜ˜D×2Ñ2ÑT¸D¿M¹MÐTÈVÑTˆØ˜Ñ!Ð!r   c              +   ó˜   K  — |rt        d«      ‚d|i}t        | j                  fd| j                  i|¤ŽD ]  }t	        |¬«      –— Œ y ­w)Nr@   rA   r   )Útext)r0   r4   rC   rD   r   )rE   r<   r=   r>   r   r1   r&   s          r   Ú_streamzYou._streamo   s`   è ø€ ñ Ü%ØGóð ð ˜6Ð"ˆÜ$Ø×"Ñ"ñ
Ø,0¯M©Mð
Ø=Cô
ˆEô " uÔ-Ó-ñ
ùs   ‚AA
c                 ó8   — | j                   dk(  rt        S t        S )Nr7   )r:   ÚSMART_ENDPOINTÚRESEARCH_ENDPOINT©rE   s    r   rC   zYou._request_endpoint€   s   € à�=‰=˜GÒ#Ü!Ð!Ü Ð r   c                 óD   — | j                   xs t        j                  d   S )NÚYDC_API_KEY)r;   ÚosÚenvironrM   s    r   rD   zYou._api_key†   s   € à×ÑÒ<¤2§:¡:¨mÑ#<Ð<r   c                  ó   — y)Nzyou.comr    rM   s    r   Ú	_llm_typezYou._llm_typeŠ   s   € àr   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r:   r   Ú__annotations__r;   r	   Ústrr   r
   r   rF   r   r   rI   ÚpropertyrC   rD   rS   r    r   r   r6   r6   ;   s1  … ññ2 .3ØàQô.€HˆgÐ)Ñ*ó ñ "'ØØTô"€K�˜#‘ó ð %)Ø:>ñ	"àð"ð �t˜C‘yÑ!ð"ð Ð6Ñ7ð	"ð
 ð"ð 
ó"ð$ %)Ø:>ñ	.àð.ð �t˜C‘yÑ!ð.ð Ð6Ñ7ð	.ð
 ð.ð 
�/Ñ	"ó.ð" ð! 3ò !ó ð!ð
 ð=˜#ò =ó ð=ð ð˜3ò ó ñr   r6   )rP   Útypingr   r   r   r   r   r   r	   r   Ú langchain_core.callbacks.managerr
   Ú#langchain_core.language_models.llmsr   Úlangchain_core.outputsr   Úpydanticr   rK   rL   rY   r   r4   r6   r    r   r   Ú<module>r`      s˜   ðÛ 	ß J× JÑ Jã Ý EÝ 3Ý 2Ý à1€Ø7Ð ð�sð  Sð °Cð ¸DÀÀcÀ¹Nó ðKØðKØðKØ+.ðKàˆs�D˜$ˆÑóKôDQˆ#õ Qr   