
    /jm                       S SK Jr  S SKrS SKJrJr  S SKJrJr  S SK	J
r
  S SKrS SKrS SKJr  S SKJr  S SKJrJrJr  S S	KJrJrJrJr  S S
KJr  S SKJr  S SK J!r!J"r"  SSK#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-J.r.J/r/J0r0J1r1  SSKJ2r2  \3" \Rh                  " SS 5      5      r5\S   r6\S   r7\ " S S5      5       r8 " S S\Rr                  5      r9 " S S\5      rg)    )annotationsN)asdict	dataclass)AnyLiteral)urlparse)llm)	LLMStream)ChatContext
ToolChoiceutils)DEFAULT_API_CONNECT_OPTIONS	NOT_GIVENAPIConnectOptions
NotGivenOr)is_given)ReasoningEffort)#ChatCompletionToolChoiceOptionParamcompletion_create_params   )CerebrasChatModels
ChatModelsCometAPIChatModelsDeepSeekChatModelsNebiusChatModelsOctoChatModelsOpenRouterProviderPreferencesOpenRouterWebPluginPerplexityChatModelsSambaNovaChatModelsTelnyxChatModelsTogetherChatModelsXAIChatModels_supports_reasoning_effort)AsyncAzureADTokenProviderLK_OPENAI_DEBUG)lowmediumhigh)	in_memory24hc                      \ rS rSr% S\S'   S\S'   S\S'   S\S'   S\S	'   S\S
'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   Srg )!_LLMOptionsB   str | ChatModelsmodelNotGivenOr[str]usersafety_identifierprompt_cache_keyNotGivenOr[float]temperaturetop_pNotGivenOr[bool]parallel_tool_callsNotGivenOr[ToolChoice]tool_choicestoreNotGivenOr[dict[str, str]]metadataNotGivenOr[int]max_completion_tokensservice_tierNotGivenOr[ReasoningEffort]reasoning_effortNotGivenOr[Verbosity]	verbosity NotGivenOr[PromptCacheRetention]prompt_cache_retentionNotGivenOr[dict[str, Any]]
extra_bodyextra_headersextra_query N)__name__
__module____qualname____firstlineno____annotations____static_attributes__rL       K/app/agent/.venv/lib/python3.13/site-packages/livekit/plugins/openai/llm.pyr-   r-   B   sn    
&&%%""))''((**!!11$$<<**--++rS   r-   c                    ^  \ rS rSrS\\S\\\\\\\\\\S\\\\\\\\\SS.                                                   S?U 4S jjjrS@S jr\SAS j5       r\SAS	 j5       r	\
S
SSSSSSSSS\\\\\\S\\\\S.                                           SBS jj5       r\
SSSS\\\\\\\\S.                         SCS jj5       r\
SSSS\\\S\\\\S.                         SDS jj5       r\
SSSS\\\S\\\\S.                         SES jj5       r\
SSSS\\\S\\\\S.                         SFS jj5       r\
SSSSSSSSS\\\S\\\\SS.                                     SGS jj5       r\
SSSS\\\S\\\\S.                         SHS  jj5       r\
S!SS"S\\\S\\\\S.                         SIS# jj5       r\
S$SS%S\\\S\\\\S.                         SJS& jj5       r\
S'S(S\\S\\\\S).
                     SKS* jj5       r\
S+SS,S\\\S\\\\S.                         SES- jj5       r\
S.SS/S\\\S\\\\S.                         SLS0 jj5       r\
S1SS2S\\\S\\\\S.                         SMS3 jj5       r\
S4SS5S\\\S\\\\S.                         SNS6 jj5       r\
S4SS7S\\\S\\\\S.                         SOS8 jj5       r\
S9SS:.       SPS; jj5       rS\\\\\S<.               SQS= jjrS>rU =r$ )RLLMX   zgpt-4.1NT)r0   api_keybase_urlclientr2   r3   r4   r6   r7   r9   r;   r<   r>   r@   timeoutmax_retriesrA   rC   rE   rG   rI   rJ   rK   _provider_fmt_strict_tool_schemac                 > [         TU ]  5         [        U5      (       d  [        U5      (       a  US;   a  SnOSn[	        S#0 SU_SU_SU_SU
_SU_S	U_S
U_SU_SU_SU_SU_SU_SU	_SU_SU_SU_SU_SU_6U l        [        U5      (       a  U(       d  [        S5      eU=(       d    SU l        UU l        USL U l	        U=(       d    [        R                  " [        U5      (       a  UOS[        U5      (       a  UOS[        U5      (       a  UOS[        R                  " U(       a  UO[        R                  " SSSSS9S[        R                  " SSSS 9S!9S"9U l        g)$z
Create a new instance of OpenAI LLM.

``api_key`` must be set to your OpenAI API key, either using the argument or by setting the
``OPENAI_API_KEY`` environmental variable.
)zgpt-5.1zgpt-5.2zgpt-5.4noneminimalr0   r2   r6   r9   r;   r<   r>   r@   rA   rC   r3   r4   r7   rE   rG   rI   rJ   rK   zYOpenAI API key is required, either as argument or set OPENAI_API_KEY environment variableopenaiNr         .@      @connectreadwritepoolT2   x   )max_connectionsmax_keepalive_connectionskeepalive_expiry)r[   follow_redirectslimits)rX   rY   r\   http_clientrL   )super__init__r   r$   r-   _opts
ValueErrorr]   r^   _owns_clientrb   AsyncClienthttpxTimeoutLimits_client)selfr0   rX   rY   rZ   r2   r3   r4   r6   r7   r9   r;   r<   r>   r@   r[   r\   rA   rC   rE   rG   rI   rJ   rK   r]   r^   	__class__s                             rT   rs   LLM.__init__Y   s   F 	()).H.O.O99#) #,   


 $
 !4	

 $
 
 
 #8
 &
 .
 0
 .
 
  
 $:
  "!
" (#
$ $%

( GW7 
 +6h#6 "dN 
!3!3'00Gd!)(!3!3X'/'<'<!))  ]]4c3O!%||$&.0%(
	"
rS   c                x   #    U R                   (       a#  U R                  R                  5       I S h  vN   g g  N7fN)rv   r{   closer|   s    rT   aclose
LLM.aclose   s,     ,,$$&&& &s   /:8:c                .    U R                   R                  $ r   )rt   r0   r   s    rT   r0   	LLM.model   s    zzrS   c                `    U R                   R                  R                  R                  S5      $ )Nzutf-8)r{   	_base_urlnetlocdecoder   s    rT   providerLLM.provider   s#    ||%%,,33G<<rS   zgpt-4o)r0   azure_endpointazure_deploymentapi_versionrX   azure_ad_tokenazure_ad_token_providerorganizationprojectrY   r2   r3   r4   r6   r9   r;   r[   rC   r7   rE   r@   c                    [         R                  " SUUUUUUUUU	U(       a  UO[        R                  " SSSSS9S9n[	        U UU
UUUUUUUUUS9nSUl        U$ )ay  
This automatically infers the following arguments from their corresponding environment variables if they are not provided:
- `api_key` from `AZURE_OPENAI_API_KEY`
- `organization` from `OPENAI_ORG_ID`
- `project` from `OPENAI_PROJECT_ID`
- `azure_ad_token` from `AZURE_OPENAI_AD_TOKEN`
- `api_version` from `OPENAI_API_VERSION`
- `azure_endpoint` from `AZURE_OPENAI_ENDPOINT`
r   rc   rd   re   )r\   r   r   r   rX   r   r   r   r   rY   r[   )r0   rZ   r2   r6   r9   r;   rC   r3   r4   r7   rE   r@   T)rb   AsyncAzureOpenAIrx   ry   rV   rv   )r0   r   r   r   rX   r   r   r   r   rY   r2   r3   r4   r6   r9   r;   r[   rC   r7   rE   r@   azure_clientr	   s                          rT   
with_azureLLM.with_azure   s    F ..)-#)$;% t#SsK
  # 3#-/-"7
  
rS   zllama-4-scout-17b-16e-instructzhttps://api.cerebras.ai/v1r0   rX   rY   rZ   r2   r6   r9   r;   rC   r3   r4   r7   c                    U=(       d    [         R                  R                  S5      nUc  [        S5      e[	        U UUUUUUUUU	U
USS9$ )z
Create a new instance of Cerebras LLM.

``api_key`` must be set to your Cerebras API key, either using the argument or by setting
the ``CEREBRAS_API_KEY`` environment variable.
CEREBRAS_API_KEYz]Cerebras API key is required, either as argument or set CEREBRAS_API_KEY environment variableFr0   rX   rY   rZ   r2   r6   r9   r;   rC   r3   r4   r7   r^   osenvirongetru   rV   r   s               rT   with_cerebrasLLM.with_cerebras  sg    . ?RZZ^^,>??o  # 3#-/- %
 	
rS   zDeepSeek-R1-0528zhttps://api.sambanova.ai/v1autoc                    U=(       d    [         R                  R                  S5      nUc  [        S5      e[	        U UUUUUUUUU	U
USS9$ )z
Create a new instance of SambaNova LLM (OpenAI-compatible).

``api_key`` must be set to your SambaNova API key, either using the argument or by setting
the ``SAMBANOVA_API_KEY`` environment variable.
SAMBANOVA_API_KEYz_SambaNova API key is required, either as argument or set SAMBANOVA_API_KEY environment variableFr   r   r   s               rT   with_sambanovaLLM.with_sambanova/  sg    . @RZZ^^,?@?q  # 3#-/- %
 	
rS   z1accounts/fireworks/models/llama-v3p3-70b-instructz%https://api.fireworks.ai/inference/v1c                    U=(       d    [         R                  R                  S5      nUc  [        S5      e[	        U UUUUUUUUU	U
US9$ )z
Create a new instance of Fireworks LLM.

``api_key`` must be set to your Fireworks API key, either using the argument or by setting
the ``FIREWORKS_API_KEY`` environmental variable.
FIREWORKS_API_KEYzaFireworks API key is required, either as argument or set FIREWORKS_API_KEY environmental variabler   r   r   s               rT   with_fireworksLLM.with_fireworks\  sd    . @RZZ^^,?@?s  # 3#-/-
 	
rS   zgrok-3-fastzhttps://api.x.ai/v1c                    U=(       d    [         R                  R                  S5      nUc  [        S5      e[	        U UUUUUUUUU	U
US9$ )z
Create a new instance of XAI LLM.

``api_key`` must be set to your XAI API key, either using the argument or by setting
the ``XAI_API_KEY`` environmental variable.
XAI_API_KEYzUXAI API key is required, either as argument or set XAI_API_KEY environmental variabler   r   r   s               rT   	with_x_aiLLM.with_x_ai  sc    , :RZZ^^M:?g  # 3#-/-
 	
rS   zhttps://openrouter.ai/api/v1)r0   rX   rY   rZ   site_urlapp_namefallback_modelsr   pluginsr2   r6   r9   r;   rC   r3   r4   r7   r[   c                   U=(       d    [         R                  R                  S5      nUc  [        S5      e0 nU(       a  UUS'   U(       a  UUS'   0 nU(       a  UUS'   U(       a  U /UQUS'   U(       aM  U VVVs/ s H8  n[	        U5      R                  5        VVs0 s H  u  nnUc  M  UU_M     snnPM:     snnnUS'   [        U UUUU	U
UUUUUUUUUS9$ s  snnf s  snnnf )	z
Create a new instance of OpenRouter LLM.

``api_key`` must be set to your OpenRouter API key, either using the argument or by setting
the ``OPENROUTER_API_KEY`` environment variable.
OPENROUTER_API_KEYzaOpenRouter API key is required, either as argument or set OPENROUTER_API_KEY environment variablezHTTP-RefererzX-Titler   modelsr   )r0   rX   rZ   rY   r2   r6   r9   r;   rC   r3   r4   r7   rI   rJ   r[   )r   r   r   ru   r   itemsrV   )r0   rX   rY   rZ   r   r   r   r   r   r2   r6   r9   r;   rC   r3   r4   r7   r[   default_headersor_bodypkvs                          rT   with_openrouterLLM.with_openrouter  s   : ARZZ^^,@A?s 
 +-.6ON+)1OI& #%"*GJ!& 9 9GHOV"OV!&)//"3E"3$!QqA"3Ew"GI # 3#-/-)
 	
 F"s   ;"C
C+C2CCzdeepseek-chatzhttps://api.deepseek.com/v1c                    U=(       d    [         R                  R                  S5      nUc  [        S5      e[	        U UUUUUUUUU	U
US9$ )z
Create a new instance of DeepSeek LLM.

``api_key`` must be set to your DeepSeek API key, either using the argument or by setting
the ``DEEPSEEK_API_KEY`` environmental variable.
DEEPSEEK_API_KEYz_DeepSeek API key is required, either as argument or set DEEPSEEK_API_KEY environmental variabler   r   r   s               rT   with_deepseekLLM.with_deepseek  sd    . ?RZZ^^,>??q  # 3#-/-
 	
rS   zgpt-5-chat-latestzhttps://api.cometapi.com/v1/c                    U=(       d    [         R                  R                  S5      nUc  [        S5      e[	        U UUUUUUUUU	U
US9$ )a
  
Create a new instance of CometAPI LLM.

``api_key`` must be set to your CometAPI API key, either using the argument or by setting
the ``COMETAPI_API_KEY`` environmental variable.

CometAPI provides access to 500+ AI models from multiple providers including OpenAI,
Anthropic, Google, xAI, DeepSeek, and Qwen through a unified API.

Get your API key at: https://api.cometapi.com/console/token
Learn more: https://www.cometapi.com/?utm_source=livekit&utm_campaign=integration&utm_medium=integration&utm_content=integration
COMETAPI_API_KEYz_CometAPI API key is required, either as argument or set COMETAPI_API_KEY environmental variabler   r   r   s               rT   with_cometapiLLM.with_cometapi(  sd    : ?RZZ^^,>??q  # 3#-/-
 	
rS   zllama-2-13b-chatzhttps://text.octoai.run/v1c                    U=(       d    [         R                  R                  S5      nUc  [        S5      e[	        U UUUUUUUUU	U
US9$ )z
Create a new instance of OctoAI LLM.

``api_key`` must be set to your OctoAI API key, either using the argument or by setting
the ``OCTOAI_TOKEN`` environmental variable.
OCTOAI_TOKENzYOctoAI API key is required, either as argument or set OCTOAI_TOKEN environmental variabler   r   r   s               rT   	with_octoLLM.with_octoZ  sc    . ;RZZ^^N;?k  # 3#-/-
 	
rS   zllama3.1zhttp://localhost:11434/v1
r0   rY   rZ   r6   r9   r;   rC   r3   r4   r7   c        
        (    [        U SUUUUUUUUU	S9$ )z&
Create a new instance of Ollama LLM.
ollama)r0   rX   rY   rZ   r6   r9   r;   rC   r3   r4   r7   )rV   r   s
             rT   with_ollamaLLM.with_ollama  s2    $ # 3#-/-
 	
rS   zgpt-oss-120bz0https://oai.endpoints.kepler.ai.cloud.ovh.net/v1c                    U=(       d    [         R                  R                  S5      nUc  [        S5      e[	        U UUUUUUUUU	U
US9$ )z
Create a new instance of OVHcloud AI Endpoints LLM.

``api_key`` must be set to your OVHcloud AI Endpoints API key, either using the argument or by setting
the ``OVHCLOUD_API_KEY`` environmental variable.
OVHCLOUD_API_KEYzlOVHcloud AI Endpoints API key is required, either as argument or set OVHCLOUD_API_KEY environmental variabler   r   r   s               rT   with_ovhcloudLLM.with_ovhcloud  sd    . ?RZZ^^,>??~  # 3#-/-
 	
rS   zllama-3.1-sonar-small-128k-chatzhttps://api.perplexity.aic                    U=(       d    [         R                  R                  S5      nUc  [        S5      e[	        U UUUUUUUUU	U
US9$ )z
Create a new instance of PerplexityAI LLM.

``api_key`` must be set to your TogetherAI API key, either using the argument or by setting
the ``PERPLEXITY_API_KEY`` environmental variable.
PERPLEXITY_API_KEYzfPerplexity AI API key is required, either as argument or set PERPLEXITY_API_KEY environmental variabler   r   r   s               rT   with_perplexityLLM.with_perplexity  sd    . ARZZ^^,@A?x  # 3#-/-
 	
rS   z+meta-llama/Meta-Llama-3.1-8B-Instruct-Turbozhttps://api.together.xyz/v1c                    U=(       d    [         R                  R                  S5      nUc  [        S5      e[	        U UUUUUUUUU	U
US9$ )z
Create a new instance of TogetherAI LLM.

``api_key`` must be set to your TogetherAI API key, either using the argument or by setting
the ``TOGETHER_API_KEY`` environmental variable.
TOGETHER_API_KEYzbTogether AI API key is required, either as argument or set TOGETHER_API_KEY environmental variabler   r   r   s               rT   with_togetherLLM.with_together  sd    . ?RZZ^^,>??t  # 3#-/-
 	
rS   z&meta-llama/Meta-Llama-3.1-70B-Instructzhttps://api.telnyx.com/v2/aic                    U=(       d    [         R                  R                  S5      nUc  [        S5      e[	        U UUUUUUUUU	U
US9$ )z
Create a new instance of Telnyx LLM.

``api_key`` must be set to your Telnyx API key, either using the argument or by setting
the ``TELNYX_API_KEY`` environmental variable.
TELNYX_API_KEYz^Telnyx AI API key is required, either as argument or set TELNYX_API_KEY environmental variabler   r   r   s               rT   with_telnyxLLM.with_telnyx*  sd    . =RZZ^^,<=?p  # 3#-/-
 	
rS   z!https://api.studio.nebius.com/v1/c                    U=(       d    [         R                  R                  S5      nUc  [        S5      e[	        U UUUUUUUUU	U
US9$ )z
Create a new instance of Nebius LLM.

``api_key`` must be set to your Nebius API key, either using the argument or by setting
the ``NEBIUS_API_KEY`` environmental variable.
NEBIUS_API_KEYz[Nebius API key is required, either as argument or set NEBIUS_API_KEY environmental variabler   r   r   s               rT   with_nebiusLLM.with_nebiusV  sd    . =RZZ^^,<=?m  # 3#-/-
 	
rS   z)https://api.letta.com/v1/chat/completions)rY   rX   c                V   [        U5      nUR                  S;  a  [        SUR                   S35      eUR                  (       d  [        SU S35      eU=(       d    [        R
                  R                  S5      nUc  [        S5      e[        U UUS[        [        [        [        S	9$ )
a6  
Create a new Letta-backed LLM instance connected to the specified Letta agent.

Args:
    agent_id (str): The Letta agent ID (must be prefixed with 'agent-').
    base_url (str): The URL of the Letta server (e.g., http://localhost:8283/v1/chat/completions for local or https://api.letta.com/v1/chat/completions for cloud).
    api_key (str | None, optional): Optional API key for authentication, required if
                                    the Letta server enforces auth.

Returns:
    LLM: A configured LLM instance for interacting with the given Letta agent.
>   httphttpszInvalid URL scheme: 'z'. Must be 'http' or 'https'.zURL 'z4' is missing a network location (e.g., domain name).LETTA_API_KEYNzYLetta API key is required, either as argument or set LETTA_API_KEY environmental variable)r0   rX   rY   rZ   r2   r6   r9   r;   )	r   schemeru   r   r   r   r   rV   r   )agent_idrY   rX   parseds       rT   
with_lettaLLM.with_letta  s    ( (#== 114V]]OC`abb}}uXJ.bcdd<RZZ^^O<?k  ! )!	
 		
rS   )toolsconn_optionsr9   r;   response_formatextra_kwargsc               ,	   0 n[        U5      (       a  UR                  U5        [        U R                  R                  5      (       a  U R                  R                  US'   [        U R                  R                  5      (       a  U R                  R                  US'   [        U R                  R
                  5      (       a  U R                  R
                  US'   [        U R                  R                  5      (       a  U R                  R                  US'   [        U R                  R                  5      (       a  U R                  R                  US'   [        U R                  R                  5      (       a  U R                  R                  US'   [        U R                  R                  5      (       a  U R                  R                  US'   [        U R                  R                  5      (       a  U R                  R                  US'   [        U R                  R                  5      (       a  U R                  R                  US	'   [        U R                  R                  5      (       a  U R                  R                  US
'   [        U R                  R                  5      (       a  U R                  R                  US'   [        U R                  R                  5      (       a  U R                  R                  US'   [        U R                  R                  5      (       a  U R                  R                  US'   [        U R                  R                   5      (       a  U R                  R                   US'   [        U5      (       a  UOU R                  R"                  n[        U5      (       a  XHS'   [        U5      (       a  UOU R                  R$                  n[        U5      (       a3  ['        U[(        5      (       a  SSUS   S   0S.n	XS'   OUS;   a  Un	XS'   [        U5      (       a  [*        R,                  " U5      US'   [/        U U R                  R0                  U R2                  U R4                  U R6                  UU=(       d    / UUS9	$ )NrI   rJ   rK   r>   r2   r@   r6   rA   rC   r3   r4   r7   rE   rG   r9   functionname)typer   r;   )r   requiredr`   r   r0   provider_fmtstrict_tool_schemarZ   chat_ctxr   r   r   )r   updatert   rI   rJ   rK   r>   r2   r@   r6   rA   rC   r3   r4   r7   rE   rG   r9   r;   
isinstancedict	llm_utilsto_openai_response_formatr
   r0   r]   r^   r{   )
r|   r   r   r   r9   r;   r   r   extraoai_tool_choices
             rT   chatLLM.chat  sl    L!!LL&DJJ))**"&**"7"7E,DJJ,,--%)ZZ%=%=E/"DJJ**++#'::#9#9E- DJJ''(( $

 3 3E*DJJOO$$ JJOOE&MDJJ4455-1ZZ-M-ME)*DJJ**++#'::#9#9E- DJJ++,,$(JJ$;$;E.!DJJ//00(,

(C(CE$%DJJ0011)-)E)EE%&DJJ//00(,

(C(CE$%DJJ$$%%!ZZ--E'NDJJ(())!%!5!5E+DJJ5566.2jj.O.OE*+ $,,?#@#@djjFdFd 	 '((+>'(%-k%:%:k

@V@VK  +t,,&!'Z)@)H I# (7m$ <<"-'6m$O$$'0'J'J?'[E#$**""++#77<<+2%

 
	
rS   )r{   rt   rv   r]   r^   )4r0   r/   rX   r1   rY   r1   rZ   openai.AsyncClient | Noner2   r1   r3   r1   r4   r1   r6   r5   r7   r5   r9   r8   r;   r:   r<   r8   r>   r=   r@   r?   r[   httpx.Timeout | Noner\   r?   rA   r1   rC   rB   rE   rD   rG   rF   rI   rH   rJ   r=   rK   r=   r]   r1   r^   boolreturnNone)r  r  )r  str),r0   r/   r   
str | Noner   r	  r   r	  rX   r	  r   r	  r   z AsyncAzureADTokenProvider | Noner   r	  r   r	  rY   r	  r2   r1   r3   r1   r4   r1   r6   r5   r9   r8   r;   r:   r[   r  rC   rB   r7   r5   rE   rD   r@   r?   r  rV   )r0   zstr | CerebrasChatModelsrX   r	  rY   r  rZ   r  r2   r1   r6   r5   r9   r8   r;   r:   rC   rB   r3   r1   r4   r1   r7   r5   r  rV   )r0   zstr | SambaNovaChatModelsrX   r	  rY   r  rZ   r  r2   r1   r6   r5   r9   r8   r;   r   rC   rB   r3   r1   r4   r1   r7   r5   r  rV   )r0   r  rX   r	  rY   r  rZ   r  r2   r1   r6   r5   r9   r8   r;   r   rC   rB   r3   r1   r4   r1   r7   r5   r  rV   )r0   zstr | XAIChatModelsrX   r	  rY   r  rZ   r  r2   r1   r6   r5   r9   r8   r;   r   rC   rB   r3   r1   r4   r1   r7   r5   r  rV   )&r0   r  rX   r	  rY   r  rZ   r  r   r	  r   r	  r   zlist[str] | Noner   z$OpenRouterProviderPreferences | Noner   z list[OpenRouterWebPlugin] | Noner2   r1   r6   r5   r9   r8   r;   r   rC   rB   r3   r1   r4   r1   r7   r5   r[   r  r  rV   )r0   zstr | DeepSeekChatModelsrX   r	  rY   r  rZ   r  r2   r1   r6   r5   r9   r8   r;   r   rC   rB   r3   r1   r4   r1   r7   r5   r  rV   )r0   zstr | CometAPIChatModelsrX   r	  rY   r  rZ   r  r2   r1   r6   r5   r9   r8   r;   r   rC   rB   r3   r1   r4   r1   r7   r5   r  rV   )r0   zstr | OctoChatModelsrX   r	  rY   r  rZ   r  r2   r1   r6   r5   r9   r8   r;   r   rC   rB   r3   r1   r4   r1   r7   r5   r  rV   )r0   r  rY   r  rZ   r  r6   r5   r9   r8   r;   r   rC   rB   r3   r1   r4   r1   r7   r5   r  rV   )r0   zstr | PerplexityChatModelsrX   r	  rY   r  rZ   r  r2   r1   r6   r5   r9   r8   r;   r   rC   rB   r3   r1   r4   r1   r7   r5   r  rV   )r0   zstr | TogetherChatModelsrX   r	  rY   r  rZ   r  r2   r1   r6   r5   r9   r8   r;   r   rC   rB   r3   r1   r4   r1   r7   r5   r  rV   )r0   zstr | TelnyxChatModelsrX   r	  rY   r  rZ   r  r2   r1   r6   r5   r9   r8   r;   r   rC   rB   r3   r1   r4   r1   r7   r5   r  rV   )r0   zstr | NebiusChatModelsrX   r	  rY   r  rZ   r  r2   r1   r6   r5   r9   r8   r;   r   rC   rB   r3   r1   r4   r1   r7   r5   r  rV   )r   r  rY   r  rX   r	  r  rV   )r   r   r   zlist[llm.Tool] | Noner   r   r9   r8   r;   r:   r   zUNotGivenOr[completion_create_params.ResponseFormat | type[llm_utils.ResponseFormatT]]r   rH   r  r
   )rM   rN   rO   rP   r   rs   r   propertyr0   r   staticmethodr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  rR   __classcell__r}   s   @rT   rV   rV   X   s8    #,#,$-,0 )-6,5)2#,09.7"+/81:(,'0(18A+4CL1:4=2;)2$(7W
  W
 !	W

 "W
 *W
 W
 +W
 *W
 'W
 !W
 .W
 ,W
  W
 -W
   /!W
" &#W
$ %%W
& &'W
( 6)W
* )+W
, !A-W
. //W
0 21W
2 03W
4 '5W
6 "7W
8 
9W
 W
r'     = =  #+%)'+"&"%)DH#'"# )-6,5)209.7(,8A#,+41:-AA #A %	A
  A A #A "BA !A A A A +A *A 'A  .!A" ,#A$ &%A& 6'A( !)A* )+A,  /-A. 
/A AF  +K"4,0 ))209.78A-6,5#,*
'*
 *
 	*

 **
 *
 '*
 .*
 ,*
 6*
 +*
 **
 !*
 
*
 *
X  ,>"5,0 ))209"(8A-6,5#,*
(*
 *
 	*

 **
 *
 '*
 .*
  *
 6*
 +*
 **
 !*
 
*
 *
X  I"?,0 ))209"(8A-6,5#,)
)
 )
 	)

 *)
 )
 ')
 .)
  )
 6)
 +)
 *)
 !)
 
)
 )
V  &3"-,0 ))209"(8A-6,5#,)
")
 )
 	)

 *)
 )
 ')
 .)
  )
 6)
 +)
 *)
 !)
 
)
 )
V  "6,0##,09=48 ))209"(8A-6,5#,(,'E
E
 E
 	E

 *E
 E
 E
 *E
 7E
 2E
 E
 'E
 .E
  E
 6E
  +!E
" *#E
$ !%E
& &'E
( 
)E
 E
N  +:"5,0 ))209"(8A-6,5#,)
')
 )
 	)

 *)
 )
 ')
 .)
  )
 6)
 +)
 *)
 !)
 
)
 )
V  +>"6,0 ))209"(8A-6,5#,/
'/
 /
 	/

 */
 /
 '/
 ./
  /
 6/
 +/
 */
 !/
 
/
 /
b  '9"4,0 ))209"(8A-6,5#,)
#)
 )
 	)

 *)
 )
 ')
 .)
  )
 6)
 +)
 *)
 !)
 
)
 )
V   3,0)209"(8A-6,5#,

 
 *	

 '
 .
  
 6
 +
 *
 !
 

 
>  $"J,0 ))209"(8A-6,5#,)
)
 )
 	)

 *)
 )
 ')
 .)
  )
 6)
 +)
 *)
 !)
 
)
 )
V  -N"3,0 ))209"(8A-6,5#,)
))
 )
 	)

 *)
 )
 ')
 .)
  )
 6)
 +)
 *)
 !)
 
)
 )
V  +X"5,0 ))209"(8A-6,5#,)
')
 )
 	)

 *)
 )
 ')
 .)
  )
 6)
 +)
 *)
 !)
 
)
 )
V  )Q"6,0 ))209"(8A-6,5#,)
%)
 )
 	)

 *)
 )
 ')
 .)
  )
 6)
 +)
 *)
 !)
 
)
 )
V  )Q";,0 ))209"(8A-6,5#,)
%)
 )
 	)

 *)
 )
 ')
 .)
  )
 6)
 +)
 *)
 !)
 
)
 )
V  D"	(
(
 (
 	(

 
(
 (
\ (,*E09.7 3<[
 [
 %	[

 ([
 .[
 ,[

[
 1[
 
[
 [
rS   rV   c                  T   ^  \ rS rSr                    SU 4S jjrSrU =r$ )r
   i  c               0   > [         T
U ]  UUUUUUUUU	S9	  g )Nr   )rr   rs   )r|   r	   r0   r   r   rZ   r   r   r   r   r}   s             rT   rs   LLMStream.__init__  s2     	%1%% 	 
	
rS   rL   )r	   rV   r0   r/   r   r  r   r  rZ   zopenai.AsyncClientr   zllm.ChatContextr   zlist[llm.Tool]r   r   r   zdict[str, Any]r  r  )rM   rN   rO   rP   rs   rR   r  r  s   @rT   r
   r
     so    

  	

 
 !
 #
 "
 
 (
 %
 

 
rS   r
   ):
__future__r   r   dataclassesr   r   typingr   r   urllib.parser   rx   rb   livekit.agentsr	   livekit.agents.inference.llmr
   
_LLMStreamlivekit.agents.llmr   r   r   r   livekit.agents.typesr   r   r   r   livekit.agents.utilsr   openai.typesr   openai.types.chatr   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   intgetenvlk_oai_debug	VerbosityPromptCacheRetentionr-   rV   rL   rS   rT   <module>r"     s    # 	 )  !    @ 
  * ( [     -299.23+,	12  , , ,*p
#'' p
f

 
rS   