Ë
    uPêj1\  ã            .       ó  — d Z ddlZddlZddlmZmZmZ ddlmZ ddl	m
Z
mZ ddlZddlZddlmZmZ ddlmZ ddlmZmZ dd	lmZ dd
lmZmZmZmZmZmZm Z  ddl!m"Z" ddl#m$Z$ e$	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d)de%dz  de%dz  dedz  de&e    dz  de%dz  de'e%e
f   dz  de(dz  de(dz  de(dz  dedz  de&e%   dz  de'e%e
f   dz  de%dz  de%dz  de'e%e
f   dz  de'e%e
f   dz  de)ejT                  z  dz  de%dz  deee   z  f&d „«       Z+e$	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d)de%dz  de%dz  dedz  de&e    dz  de%dz  de'e%e
f   dz  de(dz  de(dz  de(dz  dedz  de&e%   dz  de'e%e
f   dz  de%dz  de%dz  de'e%e
f   dz  de'e%e
f   dz  de)ejT                  z  dz  de%dz  deee   z  ee
e
eee   z  f   z  f&d!„«       Z,e$	 	 	 d*d"e%de'e%e
f   dz  de)ejT                  z  dz  de%dz  def
d#„«       Z-e$	 	 	 d*d"e%de'e%e
f   dz  de)ejT                  z  dz  de%dz  deee
e
ef   z  f
d$„«       Z.e$	 	 	 d*d"e%de'e%e
f   dz  de)ejT                  z  dz  de%dz  def
d%„«       Z/e$	 	 	 d*d"e%de'e%e
f   dz  de)ejT                  z  dz  de%dz  deee
e
ef   z  f
d&„«       Z0e$	 	 	 d*d"e%de'e%e
f   dz  de)ejT                  z  dz  de%dz  def
d'„«       Z1e$	 	 	 d*d"e%de'e%e
f   dz  de)ejT                  z  dz  de%dz  deee
e
ef   z  f
d(„«       Z2y)+aÈ  
LiteLLM Interactions API - Main Module

Per OpenAPI spec (https://ai.google.dev/static/api/interactions.openapi.json):
- Create interaction: POST /{api_version}/interactions
- Get interaction: GET /{api_version}/interactions/{interaction_id}
- Delete interaction: DELETE /{api_version}/interactions/{interaction_id}

Usage:
    import litellm

    # Create an interaction with a model
    response = litellm.interactions.create(
        model="gemini-2.5-flash",
        input="Hello, how are you?"
    )

    # Create an interaction with an agent
    response = litellm.interactions.create(
        agent="deep-research-pro-preview-12-2025",
        input="Research the current state of cancer research"
    )

    # Async version
    response = await litellm.interactions.acreate(...)

    # Get an interaction
    response = litellm.interactions.get(interaction_id="...")

    # Delete an interaction
    result = litellm.interactions.delete(interaction_id="...")
é    N)ÚAsyncIteratorÚ	CoroutineÚIterator)Úpartial)ÚAnyÚFinal)Ú2maybe_schedule_background_interaction_cost_pollingÚ1maybe_settle_background_interaction_before_delete)Úinteractions_http_handler)ÚInteractionsAPIRequestUtilsÚ$get_provider_interactions_api_config)ÚLogging)ÚCancelInteractionResultÚDeleteInteractionResultÚInteractionEnvironmentÚInteractionInputÚInteractionsAPIResponseÚ InteractionsAPIStreamingResponseÚInteractionTool)ÚGenericLiteLLMParams)ÚclientÚmodelÚagentÚinputÚtoolsÚsystem_instructionÚgeneration_configÚstreamÚstoreÚ
backgroundÚenvironmentÚresponse_modalitiesÚresponse_formatÚresponse_mime_typeÚprevious_interaction_idÚextra_headersÚ
extra_bodyÚtimeoutÚcustom_llm_providerÚreturnc              ‹   ó’  K  — t        «       }	 t        j                  «       }d|d<   |€/| r-t        j                  | |j                  dd«      ¬«      \  }}}}n|€d}t        t        fi d| “d|“d	|“d
|“d|“d|“d|“d|“d|“d|	“d|
“d|“d|“d|“d|“d|“d|“d|“|¤Ž}t        j                  «       }t        |j                  |«      }|j                  d|«      ƒ d{  –—† }t        j                  |«      r|ƒ d{  –—† }n|}t        |||¬«       |S 7 Œ67 Œ# t        $ r}t        j                  | ||||¬«      ‚d}~ww xY w­w)uš  
    Async: Create a new interaction using Google's Interactions API.

    Per OpenAPI spec, provide either `model` or `agent`.

    Args:
        model: The model to use (e.g., "gemini-2.5-flash")
        agent: The agent to use (e.g., "deep-research-pro-preview-12-2025")
        input: The input content (string, content object, or list)
        tools: Tools available for the model
        system_instruction: System instruction for the interaction
        generation_config: Generation configuration
        stream: Whether to stream the response
        store: Whether to store the response for later retrieval
        background: Whether to run in background
        environment: Agent execution environment â€” ``"remote"``, an existing env id
            string, or a config object such as
            ``{"type": "remote", "sources": [...]}`` /
            ``{"type": "remote", "network": {...}}``
        response_modalities: Requested response modalities (TEXT, IMAGE, AUDIO)
        response_format: JSON schema for response format
        response_mime_type: MIME type of the response
        previous_interaction_id: ID of previous interaction for continuation
        extra_headers: Additional headers
        extra_body: Additional body parameters
        timeout: Request timeout
        custom_llm_provider: Override the LLM provider

    Returns:
        InteractionsAPIResponse or async iterator for streaming
    TÚacreate_interactionNÚapi_base)r   r-   Úgeminir   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   )ÚresponseÚcreate_kwargsr)   ©r   r)   Úoriginal_exceptionÚcompletion_kwargsÚextra_kwargs)ÚlocalsÚasyncioÚget_event_loopÚlitellmÚget_llm_providerÚgetr   ÚcreateÚcontextvarsÚcopy_contextÚrunÚrun_in_executorÚiscoroutiner	   Ú	ExceptionÚexception_type)r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   ÚkwargsÚ
local_varsÚloopÚ_ÚfuncÚctxÚfunc_with_contextÚinit_responser/   Úes                               ú^/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/litellm/interactions/main.pyÚacreaterM   F   sÙ  è ø€ ôD ›€Jð7
Ü×,Ñ,Ó.ˆØ(,ˆÐ$Ñ%àÐ&©5Ü+2×+CÑ+CÈ%ÐZ`×ZdÑZdÐeoÐquÓZvÔ+wÑ(ˆAÐ" A¡qØ Ð(Ø"*ÐäÜò
áð
ñ ð
ñ ð	
ñ
 ð
ñ  2ð
ñ 0ð
ñ ð
ñ ð
ñ "ð
ñ $ð
ñ !4ð
ñ ,ð
ñ  2ð
ñ %<ð
ñ  (ð!
ñ" "ð#
ñ$ ð%
ñ& !4Øñ)
ˆô. !×-Ñ-Ó/ˆÜ#*¨3¯7©7°DÓ#9ÐØ%)×%9Ñ%9¸$Ð@QÓ%R×Rˆä×Ñ˜}Ô-Ø*×*‰Hà$ˆHä:ØØ Ø 3õ	
ð ˆð  Søð +ùô ò 
Ü×$Ñ$ØØ 3Ø Ø(Øô
ð 	
ûð
üsM   ‚EŽCD Ã!DÃ"D Ä DÄD ÄEÄD ÄD Ä	EÄ%D?Ä?EÅEc                 óâ  — t        «       }	 |j                  d«      }|j                  dd«      }|j                  dd«      du }t        di |¤Ž}|r| |k(  rd} |r	| s|xs d}n;| r3t	        j
                  | ||j                  |j                  ¬«      \  } }}}n|xs d}t        || ¬	«      }|j                  |«       t        j                  |«      }|d
k(  s|€*ddlm}  |«       } |j                  d| xs d|||||dœ|¤ŽS |j                  || t!        |«      d|i|¬«       t#        j$                  | ||||||||||||¬«      }|S # t&        $ r}t	        j(                  | ||||¬«      ‚d}~ww xY w)u“  
    Sync: Create a new interaction using Google's Interactions API.

    Per OpenAPI spec, provide either `model` or `agent`.

    Args:
        model: The model to use (e.g., "gemini-2.5-flash")
        agent: The agent to use (e.g., "deep-research-pro-preview-12-2025")
        input: The input content (string, content object, or list)
        tools: Tools available for the model
        system_instruction: System instruction for the interaction
        generation_config: Generation configuration
        stream: Whether to stream the response
        store: Whether to store the response for later retrieval
        background: Whether to run in background
        environment: Agent execution environment â€” ``"remote"``, an existing env id
            string, or a config object such as
            ``{"type": "remote", "sources": [...]}`` /
            ``{"type": "remote", "network": {...}}``
        response_modalities: Requested response modalities (TEXT, IMAGE, AUDIO)
        response_format: JSON schema for response format
        response_mime_type: MIME type of the response
        previous_interaction_id: ID of previous interaction for continuation
        extra_headers: Additional headers
        extra_body: Additional body parameters
        timeout: Request timeout
        custom_llm_provider: Override the LLM provider

    Returns:
        InteractionsAPIResponse or iterator for streaming
    Úlitellm_logging_objÚlitellm_call_idNr,   FTr.   )r   r)   r-   Úapi_key)Úproviderr   Úlitellm_responsesr   )Ú#LiteLLMResponsesInteractionsHandlerÚ )r   r   Úoptional_paramsr)   Ú	_is_asyncr   ©rC   r   rV   Úlitellm_paramsr)   )r   r   r   Úinteractions_api_configrV   r)   rY   Úlogging_objr&   r'   r(   rW   r   r1   © )r5   r:   Úpopr   r8   r9   r-   rQ   r   Úupdater   Ú.get_requested_interactions_api_optional_paramsÚ=litellm.interactions.litellm_responses_transformation.handlerrT   Úinteractions_api_handlerÚupdate_from_kwargsÚdictr   Úcreate_interactionrA   rB   )r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   rC   rD   rO   rP   rW   rY   rF   rZ   rV   rT   Úhandlerr/   rK   s                                  rL   r;   r;   Ã   så  € ôL ›€JðT
Ø8>¿
¹
ÐCXÓ8YÐØ-3¯Z©ZÐ8IÈ4Ó-PˆØ!Ÿ:™:Ð&;¸UÓCÀtÐKˆ	ä 4Ñ >°vÑ >ˆñ
 �U˜e’^ØˆEÙ™Ø"5Ò"A¸ÑÙÜ/6×/GÑ/GØØ$7Ø'×0Ñ0Ø&×.Ñ.ô	0Ñ,ˆEÐ&¨©1ð #6Ò"A¸Ðä)MØ(Øô*
Ðð 	×Ñ˜&Ô!Ü!<×!kÑ!kÐlvÓ!wˆð Ð"5Ò5Ð9PÐ9Xõñ AÓBˆGØ3�7×3Ñ3ð Ø’k˜rØØ /Ø$7Ø#Øñð ñð ð 	×.Ñ.ØØÜ  Ó1Ø-¨Ð?Ø 3ð 	/ô 	
ô 4×FÑFØØØØ$;Ø+Ø 3Ø)Ø+Ø'Ø!ØØØô
ˆð  ˆøÜò 
Ü×$Ñ$ØØ 3Ø Ø(Øô
ð 	
ûð
ús   ŒC4E ÄAE Å	E.ÅE)Å)E.Úinteraction_idc              ‹   ó¼  K  — t        «       }	 t        j                  «       }d|d<   t        t        f| |||xs ddœ|¤Ž}t        j                  «       }t        |j                  |«      }	|j                  d|	«      ƒ d{  –—† }
t        j                  |
«      r|
ƒ d{  –—† }|S |
}|S 7 Œ)7 Œ# t        $ r#}t        j                  d|xs d|||¬«      ‚d}~ww xY w­w)z$Async: Get an interaction by its ID.TÚaget_interactionr.   ©rf   r&   r(   r)   Nr1   )r5   r6   r7   r   r:   r<   r=   r>   r?   r@   rA   r8   rB   ©rf   r&   r(   r)   rC   rD   rE   rG   rH   rI   rJ   r/   rK   s                rL   Úagetrk   g  sþ   è ø€ ô ›€Jð
Ü×,Ñ,Ó.ˆØ%)ˆÐ!Ñ"äÜð
à)Ø'ØØ 3Ò ?°xñ
ð ñ
ˆô !×-Ñ-Ó/ˆÜ#*¨3¯7©7°DÓ#9ÐØ%)×%9Ñ%9¸$Ð@QÓ%R×Rˆä×Ñ˜}Ô-Ø*×*ˆHð ˆð %ˆHàˆð  Søð +ùô
 ò 
Ü×$Ñ$ØØ 3Ò ?°xØ Ø(Øô
ð 	
ûð
üóY   ‚CŽA1B- Á?B)Â B- ÂB+ÂB- Â$CÂ%B- Â(CÂ)B- Â+B- Â-	CÂ6CÃCÃCc           
      ó¤  — t        «       }|xs d}	 |j                  d«      }|j                  dd«      }|j                  dd«      du }t        di |¤Ž}	t	        |¬«      }
|
€t        d	|› �«      ‚|j                  |dd
| id|i|¬«       t        j                  | |
||	||||¬«      S # t        $ r}t        j                  d||||¬«      ‚d}~ww xY w)z#Sync: Get an interaction by its ID.r.   rO   rP   Nrh   FT©rR   ú$Interactions API not supported for: rf   rX   ©rf   rZ   r)   rY   r[   r&   r(   rW   r1   r\   )r5   r:   r]   r   r   Ú
ValueErrorrb   r   Úget_interactionrA   r8   rB   ©rf   r&   r(   r)   rC   rD   rO   rP   rW   rY   rZ   rK   s               rL   r:   r:   ’  s  € ô ›€JØ-Ò9°Ðð'
Ø8>¿
¹
ÐCXÓ8YÐØ-3¯Z©ZÐ8IÈ4Ó-PˆØ!Ÿ:™:Ð&8¸%Ó@ÀDÐHˆ	ä 4Ñ >°vÑ >ˆä)MØ(ô*
Ðð #Ð*ÜÐCÐDWÐCXÐYÓZÐZà×.Ñ.ØØØ-¨~Ð>Ø-¨Ð?Ø 3ð 	/ô 	
ô )×8Ñ8Ø)Ø$;Ø 3Ø)Ø+Ø'ØØô	
ð 		
øô ò 
Ü×$Ñ$ØØ 3Ø Ø(Øô
ð 	
ûð
úó   ’BB' Â'	CÂ0C
Ã
Cc              ‹   óè  K  — t        «       }	 t        j                  «       }d|d<   t        | ¬«      ƒ d{  –—†  t	        t
        f| |||xs ddœ|¤Ž}t        j                  «       }t	        |j                  |«      }	|j                  d|	«      ƒ d{  –—† }
t        j                  |
«      r|
ƒ d{  –—† }|S |
}|S 7 Œ†7 Œ+7 Œ# t        $ r#}t        j                  d|xs d|||¬«      ‚d}~ww xY w­w)z'Async: Delete an interaction by its ID.TÚadelete_interaction)rf   Nr.   ri   r1   )r5   r6   r7   r
   r   Údeleter<   r=   r>   r?   r@   rA   r8   rB   rj   s                rL   Úadeleterx   Í  s  è ø€ ô ›€Jð 
Ü×,Ñ,Ó.ˆØ(,ˆÐ$Ñ%ä?È~Ô^×^Ð^äÜð
à)Ø'ØØ 3Ò ?°xñ
ð ñ
ˆô !×-Ñ-Ó/ˆÜ#*¨3¯7©7°DÓ#9ÐØ%)×%9Ñ%9¸$Ð@QÓ%R×Rˆä×Ñ˜}Ô-Ø*×*ˆHð ˆð %ˆHàˆð) 	_øð  Søð +ùô
 ò 
Ü×$Ñ$ØØ 3Ò ?°xØ Ø(Øô
ð 	
ûð
üsi   ‚C2Ž(C ¶B=·AC ÂB?ÂC Â2CÂ3C Â8C2Â9C Â<C2Â=C Â?C ÃC Ã	C/ÃC*Ã*C/Ã/C2c           
      ó¤  — t        «       }|xs d}	 |j                  d«      }|j                  dd«      }|j                  dd«      du }t        di |¤Ž}	t	        |¬«      }
|
€t        d	|› �«      ‚|j                  |dd
| id|i|¬«       t        j                  | |
||	||||¬«      S # t        $ r}t        j                  d||||¬«      ‚d}~ww xY w)z&Sync: Delete an interaction by its ID.r.   rO   rP   Nrv   FTrn   ro   rf   rX   rp   r1   r\   )r5   r:   r]   r   r   rq   rb   r   Údelete_interactionrA   r8   rB   rs   s               rL   rw   rw   ú  ó  € ô ›€JØ-Ò9°Ðð'
Ø8>¿
¹
ÐCXÓ8YÐØ-3¯Z©ZÐ8IÈ4Ó-PˆØ!Ÿ:™:Ð&;¸UÓCÀtÐKˆ	ä 4Ñ >°vÑ >ˆä)MØ(ô*
Ðð #Ð*ÜÐCÐDWÐCXÐYÓZÐZà×.Ñ.ØØØ-¨~Ð>Ø-¨Ð?Ø 3ð 	/ô 	
ô )×;Ñ;Ø)Ø$;Ø 3Ø)Ø+Ø'ØØô	
ð 		
øô ò 
Ü×$Ñ$ØØ 3Ø Ø(Øô
ð 	
ûð
úrt   c              ‹   ó¼  K  — t        «       }	 t        j                  «       }d|d<   t        t        f| |||xs ddœ|¤Ž}t        j                  «       }t        |j                  |«      }	|j                  d|	«      ƒ d{  –—† }
t        j                  |
«      r|
ƒ d{  –—† }|S |
}|S 7 Œ)7 Œ# t        $ r#}t        j                  d|xs d|||¬«      ‚d}~ww xY w­w)z'Async: Cancel an interaction by its ID.TÚacancel_interactionr.   ri   Nr1   )r5   r6   r7   r   Úcancelr<   r=   r>   r?   r@   rA   r8   rB   rj   s                rL   Úacancelr   5  sþ   è ø€ ô ›€Jð
Ü×,Ñ,Ó.ˆØ(,ˆÐ$Ñ%äÜð
à)Ø'ØØ 3Ò ?°xñ
ð ñ
ˆô !×-Ñ-Ó/ˆÜ#*¨3¯7©7°DÓ#9ÐØ%)×%9Ñ%9¸$Ð@QÓ%R×Rˆä×Ñ˜}Ô-Ø*×*ˆHð ˆð %ˆHàˆð  Søð +ùô
 ò 
Ü×$Ñ$ØØ 3Ò ?°xØ Ø(Øô
ð 	
ûð
ürl   c           
      ó¤  — t        «       }|xs d}	 |j                  d«      }|j                  dd«      }|j                  dd«      du }t        di |¤Ž}	t	        |¬«      }
|
€t        d	|› �«      ‚|j                  |dd
| id|i|¬«       t        j                  | |
||	||||¬«      S # t        $ r}t        j                  d||||¬«      ‚d}~ww xY w)z&Sync: Cancel an interaction by its ID.r.   rO   rP   Nr}   FTrn   ro   rf   rX   rp   r1   r\   )r5   r:   r]   r   r   rq   rb   r   Úcancel_interactionrA   r8   rB   rs   s               rL   r~   r~   `  r{   rt   )NNNNNNNNNNNNNNNNNN)NNN)3Ú__doc__r6   r<   Úcollections.abcr   r   r   Ú	functoolsr   Útypingr   r   Úhttpxr8   Ú,litellm.interactions.background_cost_pollingr	   r
   Ú!litellm.interactions.http_handlerr   Úlitellm.interactions.utilsr   r   Ú*litellm.litellm_core_utils.litellm_loggingr   ÚLiteLLMLoggingObjÚlitellm.types.interactionsr   r   r   r   r   r   r   Úlitellm.types.routerr   Úlitellm.utilsr   ÚstrÚlistrc   ÚboolÚfloatÚTimeoutrM   r;   rk   r:   rx   rw   r   r~   r\   ó    rL   ú<module>r•      s•  ðñóB Û ß >Ñ >Ý ß ã ã ÷õ H÷õ T÷÷ ñ õ 6Ý  ð ð Øà%)à*.à%)à/3ààà"à15à,0Ø-1Ø%)à*.à+/Ø(,Ø,0à&*ñ?y
à�‰:ðy
ð �‰:ðy
ð
 ˜dÑ"ðy
ð �Ñ  4Ñ'ðy
ð ˜d™
ðy
ð ˜C ˜H‘~¨Ñ,ðy
ð �4‰Kðy
ð �$‰;ðy
ð" �t‘ð#y
ð& (¨$Ñ.ð'y
ð* ˜c™ TÑ)ð+y
ð, ˜#˜s˜(‘^ dÑ*ð-y
ð. ˜d™
ð/y
ð2 ! 4™Zð3y
ð6 ˜˜S˜‘> DÑ(ð7y
ð8 �S˜#�X‘ Ñ%ð9y
ð: �U—]‘]Ñ" TÑ)ð;y
ð> ˜t™ð?y
ðB ˜}Ð-MÑNÑNòCy
ó ðy
ðx ð Øà%)à*.à%)à/3ààà"à15à,0Ø-1Ø%)à*.à+/Ø(,Ø,0à&*ñ?[
à�‰:ð[
ð �‰:ð[
ð
 ˜dÑ"ð[
ð �Ñ  4Ñ'ð[
ð ˜d™
ð[
ð ˜C ˜H‘~¨Ñ,ð[
ð �4‰Kð[
ð �$‰;ð[
ð" �t‘ð#[
ð& (¨$Ñ.ð'[
ð* ˜c™ TÑ)ð+[
ð, ˜#˜s˜(‘^ dÑ*ð-[
ð. ˜d™
ð/[
ð2 ! 4™Zð3[
ð6 ˜˜S˜‘> DÑ(ð7[
ð8 �S˜#�X‘ Ñ%ð9[
ð: �U—]‘]Ñ" TÑ)ð;[
ð> ˜t™ð?[
ðD ØÐ/Ñ0ñ1à��SÐ1°MÐBbÑ4cÑcÐcÑdñeòE[
ó ð[
ðF ð ,0Ø,0Ø&*ñ	'
Øð'
à˜˜S˜‘> DÑ(ð'
ð �U—]‘]Ñ" TÑ)ð'
ð ˜t™ð	'
ð ò'
ó ð'
ðT ð ,0Ø,0Ø&*ñ	2
Øð2
à˜˜S˜‘> DÑ(ð2
ð �U—]‘]Ñ" TÑ)ð2
ð ˜t™ð	2
ð ˜y¨¨cÐ3JÐ)JÑKÑKò2
ó ð2
ðt ð ,0Ø,0Ø&*ñ	)
Øð)
à˜˜S˜‘> DÑ(ð)
ð �U—]‘]Ñ" TÑ)ð)
ð ˜t™ð	)
ð ò)
ó ð)
ðX ð ,0Ø,0Ø&*ñ	2
Øð2
à˜˜S˜‘> DÑ(ð2
ð �U—]‘]Ñ" TÑ)ð2
ð ˜t™ð	2
ð ˜y¨¨cÐ3JÐ)JÑKÑKò2
ó ð2
ðt ð ,0Ø,0Ø&*ñ	'
Øð'
à˜˜S˜‘> DÑ(ð'
ð �U—]‘]Ñ" TÑ)ð'
ð ˜t™ð	'
ð ò'
ó ð'
ðT ð ,0Ø,0Ø&*ñ	2
Øð2
à˜˜S˜‘> DÑ(ð2
ð �U—]‘]Ñ" TÑ)ð2
ð ˜t™ð	2
ð ˜y¨¨cÐ3JÐ)JÑKÑKò2
ó ñ2
r”   