+
    wGic!                         ^ RI t ^ RIt^ RIt^ RIt^ RIHtHt ^ RIH	t	 ^ RI
Ht ^ RIHt ^ RIHt ^ RIHtHt ^RIHt ^R	IHtHt R
R/R R llt ! R R]P2                  4      tR# )    N)statusviewsets)actionResponse)AgentConfig)connections)_q_identensure_business_cluster_tables)Call)CallCreateSerializerCallSerializer	timeout_sg      4@c                    V ^8  d   QhR\         R\        R\        R\        \        \        R,          \         3,          /# )   urlpayloadr   returnN)strdictfloattupleint)formats   "<E:\live-kit-agent\livekit_voicebot\backend\apps\calls\api.py__annotate__r      s<      C $ e uSRVY]R]_bMbGc     c          
         \         P                  ! V4      P                  R 4      p\        P                  P                  V VRR/RR7      p \        P                  P                  WBR7      ;_uu_ 4       pVP                  4       p VP                  \         P                  ! VP                  R 4      4      R3uuRRR4       #   \         d5    TP                  RTP                  R RR	7      R
,          3u uuRRR4       # i ; i  + '       g   i     R# ; i  \        P                  P                   ds   p\        TR4      '       d"   TP                  4       P                  R RR	7      M
\        T4      p\!        \#        TRR4      ;'       g    R4      RTR
,          3u Rp?# Rp?i\         d   p^ R\        T4      3u Rp?# Rp?ii ; i)utf-8zcontent-typezapplication/jsonPOST)dataheadersmethod)timeout Nreplaceerrors:Ni  Nreadcodei  )jsondumpsencodeurllibrequestRequesturlopenr)   r   loadsdecode	Exceptionerror	HTTPErrorhasattrr   r   getattr)	r   r   r   r!   reqresprawebodys	   &&$      r   
_post_jsonr>      sr   ::g%%g.D
..
 
 !34	 ! C^^##C#;;t))+CV{{DJJszz'/B$CRG <;  V{{D#**WY**OPT*UUU <;V	 <;; <<!! E=DQ=O=Oqvvxwy9UXYZU[71fc*11c2D$t*DD $As   (D 4D1C7
D 2D4D5
D  DDD	D D G
7AF$F$G
$G
1G
2G?G
G
c                      a  ] tR t^(t o ]P
                  P                  R4      P                  4       t]	t
R tR t]! RR.R7      R 4       tRtV tR	# )
CallViewSetbotc                <    V P                   R 8X  d   \        # \        # )create)r   r   r   )selfs   &r   get_serializer_class CallViewSet.get_serializer_class,   s    ;;("''r   c                   \        VP                  R 7      pVP                  RR7       VP                  pRpRpVP	                  R4      pVP	                  R4      p	VR/9  d   V	e    \        V4      p
\        V	4      p\        V
4       V
 R2p\        R,          P                  4       ;_uu_ 4       pVP                  R	\        V4       R
2V.4       VP                  4       pV'       d7   VP                   Uu. uF  q^ ,          NK  	  pp\        \        VV4      4      pRRR4       V	e/   \         P"                  P%                  V	R7      P'                  4       p\)        VR,          4      P+                  4       pVP	                  R4      ;'       g!    V'       d   VP,                  MR;'       g    RP+                  4       pVP	                  R4      ;'       g!    V'       d   VP.                  MR;'       g    RP+                  4       pV'       d   VP	                  R4      ;'       g%    \)        VP	                  R4      ;'       g    R4      P+                  4       ;'       g    TpVP	                  R4      ;'       g%    \)        VP	                  R4      ;'       g    R4      P+                  4       ;'       g    TpRVRVRV/pV'       Ed   VR/9  Ed   V	Ee   \        V4      VR&   \        V	4      VR&   VP	                  R4      pVe-   \)        V4      P+                  4       R8w  d   \)        V4      VR&   VP	                  R4      pVe;   \)        V4      P+                  4       R8w  d   \)        V4      P+                  4       VR&   VP	                  R4      pVe;   \)        V4      P+                  4       R8w  d   \)        V4      P+                  4       VR&   VP	                  R4      pVe;   \)        V4      P+                  4       R8w  d   \)        V4      P+                  4       VR&   VP	                  R4      pVe;   \)        V4      P+                  4       R8w  d   \)        V4      P+                  4       VR&   VP	                  R4      pVe;   \)        V4      P+                  4       R8w  d   \)        V4      P+                  4       VR&   VP	                  R4      p\1        V\2        \4        34      '       d   VP7                  RRR7      p\1        V\(        4      '       d   VP+                  4       '       d    \8        P:                  ! V4      p\1        V\        4      '       dx   VP	                  R4      ;'       g    VP	                  R4      ;'       g    RpV'       d<   \)        V4      P+                  4       '       d   \)        V4      P+                  4       VR &   V'       Ed   VP<                  '       d   VP<                  VR&   VP>                  '       d   VP>                  VR&   VP@                  '       d   VP@                  VR&   VPB                  '       d   VPB                  VR&   \E        VR!R4      '       d6   VPF                  PH                  '       d   VPF                  PH                  VR &   VPJ                  '       d   VPJ                  VR&   VPL                  '       d   VPL                  VR"&   R0 Fp  pVV9   g   K  \)        VP	                  V4      ;'       g    R4      P+                  4       R8w  g   KE  \)        VP	                  V4      4      P+                  4       VV&   Kr  	  \N        PP                  ! R#R$4      p\S        VV4      w  p p!p"\        V4      p#R"V#9   d   R%V#R"&   \T        P"                  PW                  \T        PX                  PZ                  \T        P\                  P^                  TTTT\)        T!;'       g    / P	                  R&4      ;'       g    R4      \)        T!;'       g    / P	                  R'4      ;'       g    R4      R(V#R)V!R*V /V"R+7
      p$\a        V$4      P                  p%V!V%R,&   V V%R-&   V R19  d   \c        V%\d        Pf                  R.7      # \c        V%\d        Ph                  R.7      # u upi   + '       g   i     EL; i  \         d    Rp ELi ; i  \         d     ELi ; i)2)r!   T)raise_exceptionNbusiness_idbot_idr%   _botsclusterzSELECT * FROM z WHERE bot_id = %s LIMIT 1)id
custnumber	exenumbergid1mcube_exenumber	mcube_gidpromptsystem_promptmessage_outboundfirst_message	llm_modelstt_providertts_providerllm_providervoicer   r&   r'   voice_idvoiceIdtts_voice_idvoice_configHTTP_AUTHORIZATIONMCUBE_OUTBOUND_CALL_URLz-http://127.0.0.1:8002/api/mcube/outbound-callz***redacted***r   mcube_call_sidr/   responsehttp_status)
provider	directionrA   rN   rO   rP   r   provider_call_idmetadata
last_errortelephony_responsetelephony_http_status)r   )Nr%   )rW   rU   rX   rY   rZ   	tts_modelr_   tts_encoding)      )5r   r!   is_validvalidated_datagetr   r   r	   cursorexecuter
   fetchonedescriptionr   zipr4   r   objectsfilterfirstr   striprR   rS   
isinstancebytes	bytearrayr3   r+   r2   rU   rX   rY   rZ   r8   r`   r]   first_message_outboundmcube_http_authorizationosgetenvr>   r   rC   ProviderMCUBE	DirectionOUTBOUNDr   r   r   HTTP_502_BAD_GATEWAYHTTP_201_CREATED)&rD   r/   argskwargsserr!   rA   cluster_bot_rowrI   rJ   bidbpktablecurrowccolsrN   rO   rP   r   rT   msg_outrX   rY   rZ   r[   	voice_rawvobjvidk	mcube_urlre   	resp_jsonerrpayload_for_storagecallouts&   &&*,                                  r   rC   CallViewSet.create1   s^   "5T*!!'+hh}-(#
 j(V-?'+&&k.s3%u +2244KK.%0AA[ \_b^cd,,.C.1oo>o!o>*.s4~*> 5 %%,,,7==?Cl+,224
XXk*XXcs/B/BrXXVX__a	xxGGC3==RGGCNNP+.cc#o6I6IJ[6\6b6b`b2cjjlyypyI88E?QQc/*=*=k*J*P*Pb&QXXZaa^aC *3
 ?{*<AS%(%5GM" #FGH %((2F!c&k&7&7&9R&?+.v;(%))*<=G"s7|'9'9';r'A+.w<+=+=+?('++K8I$Y)=)=)?2)E'*9~';';'=$*..~>L'C,=,C,C,E,K*-l*;*A*A*C'*..~>L'C,=,C,C,E,K*-l*;*A*A*C'*..~>L'C,=,C,C,E,K*-l*;*A*A*C' (++G4I)eY%788%,,WY,G	)S))ioo.?.?::i0D!$--#xx
3PPtxx	7JPPb3s8>>#3#369#hnn6FGN3
 3   +.+<+<(}}}'*}}$*-*:*:'*-*:*:'sND11c6F6F6O6O6O*-*:*:*C*C')))+.+E+E(+++030L0L,-	
A DyS!!2!2399;rA !-335
	
 II79hi	&0G&D#Y #7m#668H 45||""]]((nn--!	R,,X6<<"= )//r!6!67G!H!N!NBO!4j)]\gh # 
 T"''$- !'2#$j(C(C(CDDF$;$;<<o  ?	 544  '"&'p ! si   'A	c 0Ab27b-b2c ,Ac 0c 	
c ;c -b22c	=c c ccc)(c)Frs   )detailmethodsc                    \        R R/4      # )okTr   )rD   r/   s   &&r   healthCallViewSet.health   s    t%%r    N)__name__
__module____qualname____firstlineno__r   ry   select_relatedallquerysetr   serializer_classrE   rC   r   r   __static_attributes____classdictcell__)__classdict__s   @r   r@   r@   (   sQ     ||**51557H%
N=` 55'*& +&r   r@   )r+   r   urllib.requestr.   urllib.errorrest_frameworkr   r   rest_framework.decoratorsr   rest_framework.responser   apps.agents.modelsr   	django.dbr	   apps.cluster.dynamic_tablesr
   r   modelsr   serializersr   r   r>   ModelViewSetr@   r   r   r   <module>r      sI     	   + , , * ! P  =d ,[&('' [&r   