
    >'h+\                     x   d dl Z d dlZd dlmZ ddlmZ ddlmZm	Z	 ddl
mZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ 	 d dlZej:                  j=                  d      red dl m!Z  e jD                  e jF                  d      Z$ G d d      Z% G d d      Z&y# e$ r d dlZY =w xY w)    N)JSONDecodeError   )ApiError)AsyncClientWrapperSyncClientWrapper)jsonable_encoder)remove_none_from_dict)UnprocessableEntityError)ChatApp)ChatAppResponse)HttpValidationError)InputMessage)LlmParameters)PresetCompositeRetrievalParamsz1..c                   ,   e Zd ZdefdZddddej                  e   dej                  e   dej                  e	   fdZ
ddddej                  e   dej                  e   d	ed
edededefdZdedefdZddeeeddedej                  e   dej                  e   d	ej                  e   dej                  e   dej                  e   defdZdedej$                  fdZeddedej                  ej                  e      dej$                  fdZy)ChatAppsClientclient_wrapperc                    || _         y N_client_wrapperselfr   s     m/home/kushmeetdev/Regenta/Chatbot/venv/lib/python3.12/site-packages/llama_cloud/resources/chat_apps/client.py__init__zChatAppsClient.__init__    
    -    N
project_idorganization_idr   r    returnc          	         | j                   j                  j                  dt        j                  j                  | j                   j                          dd      t        ||d      | j                   j                         d      }d|j                  cxk  rdk  r<n n9t        j                  t        j                  t           |j                               S |j                  d	k(  r1t!        t        j                  t"        |j                                     	 |j                         }t'        |j                  |
      # t$        $ r" t'        |j                  |j(                  
      w xY w)aC  
        Parameters:
            - project_id: typing.Optional[str].

            - organization_id: typing.Optional[str].
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.chat_apps.get_chat_apps_api_v_1_apps_get()
        GET/api/v1/appsr   <   paramsheaderstimeout   ,    status_codebodyr   httpx_clientrequesturllibparseurljoinget_base_urlr	   get_headersr/   pydanticparse_obj_astypingListr   jsonr
   r   r   r   textr   r   r    	_response_response_jsons        r   get_chat_apps_api_v_1_apps_getz-ChatAppsClient.get_chat_apps_api_v_1_apps_get#   s0     ((55==LL  D$8$8$E$E$G#H!JMZ(
Wf)gh((446 > 
	 )''-#-((_)Ey~~GWXX  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN  	Sy'<'<9>>RR	Ss   E +E,nameretriever_id
llm_configretrieval_configc                   | j                   j                  j                  dt        j                  j                  | j                   j                          dd      t        ||d      t        ||||d      | j                   j                         d      }d|j                  cxk  rd	k  r+n n(t        j                  t        |j                               S |j                  d
k(  r1t        t        j                  t         |j                                     	 |j                         }t%        |j                  |      # t"        $ r" t%        |j                  |j&                        w xY w)a`  
        Create a new chat app.

        Parameters:
            - project_id: typing.Optional[str].

            - organization_id: typing.Optional[str].

            - name: str. Name of the chat app

            - retriever_id: str. ID of the retriever to use for the chat app

            - llm_config: LlmParameters. Configuration for the LLM model to use for the chat app

            - retrieval_config: PresetCompositeRetrievalParams. Configuration for the retrieval model to use for the chat app
        ---
        from llama_cloud import (
            CompositeRetrievalMode,
            LlmParameters,
            PresetCompositeRetrievalParams,
            ReRankConfig,
            ReRankerType,
            SupportedLlmModelNames,
        )
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.chat_apps.create_chat_app_api_v_1_apps_post(
            name="string",
            retriever_id="string",
            llm_config=LlmParameters(
                model_name=SupportedLlmModelNames.GPT_4_O,
            ),
            retrieval_config=PresetCompositeRetrievalParams(
                mode=CompositeRetrievalMode.ROUTING,
                rerank_config=ReRankConfig(
                    type=ReRankerType.SYSTEM_DEFAULT,
                ),
            ),
        )
        POSTr$   r%   r   rC   rD   rE   rF   r&   r(   r=   r)   r*   r+   r,   r-   r.   r   r2   r3   r4   r5   r6   r7   r	   r   r8   r/   r9   r:   r   r=   r
   r   r   r   r>   	r   r   r    rC   rD   rE   rF   r@   rA   s	            r   !create_chat_app_api_v_1_apps_postz0ChatAppsClient.create_chat_app_api_v_1_apps_postD   sC   j ((55==LL  D$8$8$E$E$G#H!JMZ(
Wf)gh! $0",(8	 ((446 > 
	 )''-#-(()..2BCC  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN  	Sy'<'<9>>RR	Ss   D? ?+E*idc                    | j                   j                  j                  dt        j                  j                  | j                   j                          dd|       | j                   j                         d      }d|j                  cxk  rdk  r+n n(t        j                  t        |j                               S |j                  dk(  r1t        t        j                  t        |j                                     	 |j                         }t!        |j                  |	      # t        $ r" t!        |j                  |j"                  	      w xY w)
a#  
        Get a chat app by ID.

        Parameters:
            - id: str.
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.chat_apps.get_chat_app(
            id="string",
        )
        r#   r$   api/v1/apps/r&   r)   r*   r+   r,   r-   r.   r   r2   r3   r4   r5   r6   r7   r8   r/   r9   r:   r   r=   r
   r   r   r   r>   r   rN   r@   rA   s       r   get_chat_appzChatAppsClient.get_chat_app   s"     ((55==LL  D$8$8$E$E$G#H!Jl[]Z^L_`((446	 > 
	 )''-#-(()..2BCC  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN  	Sy'<'<9>>RR	Ss   ?D& &+Er   r    rC   rE   rF   c          	      (   i }|t         ur||d<   |t         ur||d<   |t         ur||d<   | j                  j                  j                  dt        j
                  j                  | j                  j                          dd|       t        ||d      t        |      | j                  j                         d	      }d
|j                  cxk  rdk  r+n n(t        j                  t        |j                               S |j                  dk(  r1t!        t        j                  t"        |j                                     	 |j                         }	t'        |j                  |	      # t$        $ r" t'        |j                  |j(                        w xY w)a  
        Update a chat app.

        Parameters:
            - id: str.

            - project_id: typing.Optional[str].

            - organization_id: typing.Optional[str].

            - name: typing.Optional[str].

            - llm_config: typing.Optional[LlmParameters].

            - retrieval_config: typing.Optional[PresetCompositeRetrievalParams].
        ---
        from llama_cloud import (
            CompositeRetrievalMode,
            LlmParameters,
            PresetCompositeRetrievalParams,
            ReRankConfig,
            ReRankerType,
            SupportedLlmModelNames,
        )
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.chat_apps.update_chat_app(
            id="string",
            llm_config=LlmParameters(
                model_name=SupportedLlmModelNames.GPT_4_O,
            ),
            retrieval_config=PresetCompositeRetrievalParams(
                mode=CompositeRetrievalMode.ROUTING,
                rerank_config=ReRankConfig(
                    type=ReRankerType.SYSTEM_DEFAULT,
                ),
            ),
        )
        rC   rE   rF   PUTr$   rP   r   r&   rJ   r+   r,   r-   r.   OMITr   r2   r3   r4   r5   r6   r7   r	   r   r8   r/   r9   r:   r   r=   r
   r   r   r   r>   
r   rN   r   r    rC   rE   rF   _requestr@   rA   s
             r   update_chat_appzChatAppsClient.update_chat_app   su   h 24t#HVT!%/H\"4'+;H'(((55==LL  D$8$8$E$E$G#H!Jl[]Z^L_`(
Wf)gh!(+((446 > 
	 )''-#-(()..2BCC  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN  	Sy'<'<9>>RR	Ss   ?E& &+Fc                    | j                   j                  j                  dt        j                  j                  | j                   j                          dd|       | j                   j                         d      }d|j                  cxk  rdk  r5n n2t        j                  t        j                  |j                               S |j                  dk(  r1t        t        j                  t        |j                                     	 |j                         }t#        |j                  |	      # t         $ r" t#        |j                  |j$                  	      w xY w)
a  
        Parameters:
            - id: str.
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.chat_apps.delete_chat_app(
            id="string",
        )
        DELETEr$   rP   r&   rQ   r+   r,   r-   r.   r   r2   r3   r4   r5   r6   r7   r8   r/   r9   r:   r;   Anyr=   r
   r   r   r   r>   rS   s       r   delete_chat_appzChatAppsClient.delete_chat_app   s&    ((55==LL  D$8$8$E$E$G#H!Jl[]Z^L_`((446	 > 
	 )''-#-((Y^^5EFF  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN  	Sy'<'<9>>RR	Ss   	D0 0+Emessagesrc   c          	         i }|t         ur||d<   | j                  j                  j                  dt        j
                  j                  | j                  j                          dd| d      t        |      | j                  j                         d      }d|j                  cxk  rd	k  r5n n2t        j                  t        j                  |j                               S |j                  d
k(  r1t!        t        j                  t"        |j                                     	 |j                         }t'        |j                  |      # t$        $ r" t'        |j                  |j(                        w xY w)an  
        Chat with a chat app.

        Parameters:
            - id: str.

            - messages: typing.Optional[typing.List[InputMessage]].
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.chat_apps.chat_with_chat_app(
            id="string",
        )
        rc   rH   r$   rP   /chatr&   r=   r)   r*   r+   r,   r-   r.   rY   r   r2   r3   r4   r5   r6   r7   r   r8   r/   r9   r:   r;   r`   r=   r
   r   r   r   r>   r   rN   rc   r[   r@   rA   s         r   chat_with_chat_appz!ChatAppsClient.chat_with_chat_app  sH   $ 244#+HZ ((55==LL  D$8$8$E$E$G#H!Jl[]Z^^cLde!(+((446 > 
	 )''-#-((Y^^5EFF  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN  	Sy'<'<9>>RR	Ss   #E
 
+E5)__name__
__module____qualname__r   r   r;   Optionalstrr<   r   rB   r   r   r   rM   rT   rY   r\   r`   ra   r   ri    r   r   r   r      s   .*; . 59bfO#__S1OKQ??[^K_O	_	%OH ,004	LO OOC(LO  -	LO
 LO LO "LO 9LO 
LO\Os Ow OH ,004%)59LPKOKO OOC(	KO
  -KO ooc"KO OOM2KO !//*HIKO 
KOZO# O&** O< ei $OS $Ovv{{S_G`7a $Omsmwmw $Or   r   c                   ,   e Zd ZdefdZddddej                  e   dej                  e   dej                  e	   fdZ
ddddej                  e   dej                  e   d	ed
edededefdZdedefdZddeeeddedej                  e   dej                  e   d	ej                  e   dej                  e   dej                  e   defdZdedej$                  fdZeddedej                  ej                  e      dej$                  fdZy)AsyncChatAppsClientr   c                    || _         y r   r   r   s     r   r   zAsyncChatAppsClient.__init__E  r   r   Nr   r   r    r!   c          	        K   | j                   j                  j                  dt        j                  j                  | j                   j                          dd      t        ||d      | j                   j                         d       d{   }d|j                  cxk  rd	k  r<n n9t        j                  t        j                  t           |j                               S |j                  d
k(  r1t!        t        j                  t"        |j                                     	 |j                         }t'        |j                  |      7 # t$        $ r" t'        |j                  |j(                        w xY ww)aS  
        Parameters:
            - project_id: typing.Optional[str].

            - organization_id: typing.Optional[str].
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.chat_apps.get_chat_apps_api_v_1_apps_get()
        r#   r$   r%   r   r&   r'   Nr+   r,   r-   r.   r1   r?   s        r   rB   z2AsyncChatAppsClient.get_chat_apps_api_v_1_apps_getH  s>      ..;;CCLL  D$8$8$E$E$G#H!JMZ(
Wf)gh((446 D 
 
	 )''-#-((_)Ey~~GWXX  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN
  	Sy'<'<9>>RR	Ss+   BE;EBE;$E 4E;+E88E;rC   rD   rE   rF   c                  K   | j                   j                  j                  dt        j                  j                  | j                   j                          dd      t        ||d      t        ||||d      | j                   j                         d       d{   }d	|j                  cxk  rd
k  r+n n(t        j                  t        |j                               S |j                  dk(  r1t        t        j                  t         |j                                     	 |j                         }t%        |j                  |      7 # t"        $ r" t%        |j                  |j&                        w xY ww)ap  
        Create a new chat app.

        Parameters:
            - project_id: typing.Optional[str].

            - organization_id: typing.Optional[str].

            - name: str. Name of the chat app

            - retriever_id: str. ID of the retriever to use for the chat app

            - llm_config: LlmParameters. Configuration for the LLM model to use for the chat app

            - retrieval_config: PresetCompositeRetrievalParams. Configuration for the retrieval model to use for the chat app
        ---
        from llama_cloud import (
            CompositeRetrievalMode,
            LlmParameters,
            PresetCompositeRetrievalParams,
            ReRankConfig,
            ReRankerType,
            SupportedLlmModelNames,
        )
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.chat_apps.create_chat_app_api_v_1_apps_post(
            name="string",
            retriever_id="string",
            llm_config=LlmParameters(
                model_name=SupportedLlmModelNames.GPT_4_O,
            ),
            retrieval_config=PresetCompositeRetrievalParams(
                mode=CompositeRetrievalMode.ROUTING,
                rerank_config=ReRankConfig(
                    type=ReRankerType.SYSTEM_DEFAULT,
                ),
            ),
        )
        rH   r$   r%   r   rI   r&   rJ   Nr+   r,   r-   r.   rK   rL   s	            r   rM   z5AsyncChatAppsClient.create_chat_app_api_v_1_apps_posti  sQ    j ..;;CCLL  D$8$8$E$E$G#H!JMZ(
Wf)gh! $0",(8	 ((446 D 
 
	 )''-#-(()..2BCC  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN/
*  	Sy'<'<9>>RR	Ss+   BE9E	BE9"E 2E9+E66E9rN   c                   K   | j                   j                  j                  dt        j                  j                  | j                   j                          dd|       | j                   j                         d       d{   }d|j                  cxk  rdk  r+n n(t        j                  t        |j                               S |j                  d	k(  r1t        t        j                  t        |j                                     	 |j                         }t!        |j                  |
      7 # t        $ r" t!        |j                  |j"                  
      w xY ww)a3  
        Get a chat app by ID.

        Parameters:
            - id: str.
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.chat_apps.get_chat_app(
            id="string",
        )
        r#   r$   rP   r&   rQ   Nr+   r,   r-   r.   rR   rS   s       r   rT   z AsyncChatAppsClient.get_chat_app  s0      ..;;CCLL  D$8$8$E$E$G#H!Jl[]Z^L_`((446	 D 
 
	 )''-#-(()..2BCC  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN
  	Sy'<'<9>>RR	Ss+   BE D0BE 	D2 E 2+EE rU   c          	      D  K   i }|t         ur||d<   |t         ur||d<   |t         ur||d<   | j                  j                  j                  dt        j
                  j                  | j                  j                          dd|       t        ||d      t        |      | j                  j                         d	       d
{   }d|j                  cxk  rdk  r+n n(t        j                  t        |j                               S |j                  dk(  r1t!        t        j                  t"        |j                                     	 |j                         }	t'        |j                  |	      7 # t$        $ r" t'        |j                  |j(                        w xY ww)a  
        Update a chat app.

        Parameters:
            - id: str.

            - project_id: typing.Optional[str].

            - organization_id: typing.Optional[str].

            - name: typing.Optional[str].

            - llm_config: typing.Optional[LlmParameters].

            - retrieval_config: typing.Optional[PresetCompositeRetrievalParams].
        ---
        from llama_cloud import (
            CompositeRetrievalMode,
            LlmParameters,
            PresetCompositeRetrievalParams,
            ReRankConfig,
            ReRankerType,
            SupportedLlmModelNames,
        )
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.chat_apps.update_chat_app(
            id="string",
            llm_config=LlmParameters(
                model_name=SupportedLlmModelNames.GPT_4_O,
            ),
            retrieval_config=PresetCompositeRetrievalParams(
                mode=CompositeRetrievalMode.ROUTING,
                rerank_config=ReRankConfig(
                    type=ReRankerType.SYSTEM_DEFAULT,
                ),
            ),
        )
        rC   rE   rF   rW   r$   rP   r   r&   rJ   Nr+   r,   r-   r.   rX   rZ   s
             r   r\   z#AsyncChatAppsClient.update_chat_app  s    h 24t#HVT!%/H\"4'+;H'(..;;CCLL  D$8$8$E$E$G#H!Jl[]Z^L_`(
Wf)gh!(+((446 D 
 
	 )''-#-(()..2BCC  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN!
  	Sy'<'<9>>RR	Ss+   CF E0BF 	E2 F 2+FF c                   K   | j                   j                  j                  dt        j                  j                  | j                   j                          dd|       | j                   j                         d       d{   }d|j                  cxk  rdk  r5n n2t        j                  t        j                  |j                               S |j                  d	k(  r1t        t        j                  t        |j                                     	 |j                         }t#        |j                  |
      7 # t         $ r" t#        |j                  |j$                  
      w xY ww)a  
        Parameters:
            - id: str.
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.chat_apps.delete_chat_app(
            id="string",
        )
        r^   r$   rP   r&   rQ   Nr+   r,   r-   r.   r_   rS   s       r   ra   z#AsyncChatAppsClient.delete_chat_app$  s4     ..;;CCLL  D$8$8$E$E$G#H!Jl[]Z^L_`((446	 D 
 
	 )''-#-((Y^^5EFF  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN
  	Sy'<'<9>>RR	Ss+   BE*D:BE*D< #E*<+E''E*rb   rc   c          	        K   i }|t         ur||d<   | j                  j                  j                  dt        j
                  j                  | j                  j                          dd| d      t        |      | j                  j                         d       d{   }d	|j                  cxk  rd
k  r5n n2t        j                  t        j                  |j                               S |j                  dk(  r1t!        t        j                  t"        |j                                     	 |j                         }t'        |j                  |      7 # t$        $ r" t'        |j                  |j(                        w xY ww)a~  
        Chat with a chat app.

        Parameters:
            - id: str.

            - messages: typing.Optional[typing.List[InputMessage]].
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.chat_apps.chat_with_chat_app(
            id="string",
        )
        rc   rH   r$   rP   re   r&   rf   Nr+   r,   r-   r.   rg   rh   s         r   ri   z&AsyncChatAppsClient.chat_with_chat_appB  sV    ( 244#+HZ ..;;CCLL  D$8$8$E$E$G#H!Jl[]Z^^cLde!(+((446 D 
 
	 )''-#-((Y^^5EFF  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN
  	Sy'<'<9>>RR	Ss+   BFEBF-E =F+FF)rj   rk   rl   r   r   r;   rm   rn   r<   r   rB   r   r   r   rM   rT   rY   r\   r`   ra   r   ri   ro   r   r   rq   rq   D  s   .*< . 59bfO#__S1OKQ??[^K_O	_	%OH ,004	LO OOC(LO  -	LO
 LO LO "LO 9LO 
LO\OS OW OH ,004%)59LPKOKO OOC(	KO
  -KO ooc"KO OOM2KO !//*HIKO 
KOZO O

 O> RV&O&O$*OOFKK4M$N&O	&Or   rq   )'r;   urllib.parser4   json.decoderr   core.api_errorr   core.client_wrapperr   r   core.jsonable_encoderr   core.remove_none_from_dictr	   !errors.unprocessable_entity_errorr
   types.chat_appr   types.chat_app_responser   types.http_validation_errorr   types.input_messager   types.llm_parametersr   'types.preset_composite_retrieval_paramsr   r9   __version__
startswithImportErrorpydantic.v1v1castr`   rY   r   rq   ro   r   r   <module>r      s      ( & H 5 ? I % 6 > / 1 U&&t,"
 v{{6::s#bO bOJ	dO dOY	  s   'B- -	B98B9