
    
!i                       % S r SSKJr  SSKrSSKJr  SSKJr  SSK	J
r
  SSK	Jr  SSK	Jr  SS	K	Jr  SS
K	Jr  SSK	Jr  SSKrSSKJr  S\l        \R(                  r\R*                  r\R,                  r\R.                  rSqS\S'   SS jrSS jr " S S\R8                  5      r " S S\5      r\R>                   " S S\R@                  5      5       r \RB                  " 5       RE                  \ 5        g)z,Colab Magics class.

Installs %%llm magics.
    )annotationsN)credentials)client)gspread_client)ipython_env)ipython_env_impl)magics_engine)post_process_utils)sheets_utils)magiczgenai-py-magiczipython_env.IPythonEnv | None_ipython_envc                 F    [         c  [        R                  " 5       q [         $ )z;Lazily constructs and returns a global IPythonEnv instance.)r   r   IPythonEnvImpl     ]/home/james-whalen/.local/lib/python3.13/site-packages/google/generativeai/notebook/magics.py_get_ipython_envr   4   s     '668r   c                >    [         R                  " U [        5       S9  g)zSets up credentials.

This is used for interacting Google APIs, such as Google Sheets.

Args:
  creds: The credentials that will be used (e.g. to read from Google Sheets.)
)credsenvN)r   	authorizer   )r   s    r   r   r   <   s     5.>.@Ar   c                  @    \ rS rSrSr\R                  SS j5       rSrg)AbstractMagicsG   z"Defines interface to Magics class.c                    [        5       e)zPerform various LLM-related operations.

Args:
  cell_line: String to pass to the MagicsEngine.
  cell_body: Contents of the cell body.
)NotImplementedErrorself	cell_line	cell_bodys      r   llmAbstractMagics.llmJ   s     "##r   r   Nr   
str | Noner    r$   )	__name__
__module____qualname____firstlineno____doc__abcabstractmethodr!   __static_attributes__r   r   r   r   r   G   s    ,$ $r   r   c                  (    \ rS rSrSrS rSS jrSrg)
MagicsImplU   zActual class implementing the magics functionality.

We use a separate class to ensure a single, global instance
of the magics class.
c                F    [         R                  " [        5       S9U l        g )N)r   )r	   MagicsEnginer   _engine)r   s    r   __init__MagicsImpl.__init__\   s    $116F6HIr   c                d    U=(       d    SnU=(       d    SnU R                   R                  X5      $ )Perform various LLM-related operations.

Args:
  cell_line: String to pass to the MagicsEngine.
  cell_body: Contents of the cell body.

Returns:
  Results from running MagicsEngine.
 )r2   execute_cellr   s      r   r!   MagicsImpl.llm_   s+     O	O	||((>>r   )r2   Nr#   )r%   r&   r'   r(   r)   r3   r!   r,   r   r   r   r.   r.   U   s    J?r   r.   c                      \ rS rSrSrSr\S	S j5       r\R                  S
S j5       r
\R                  S
S j5       r\R                  S
S j5       rSrg)Magicsn   zpClass to register the magic with Colab.

Objects of this class delegate all calls to a single,
global instance.
Nc                R    U R                   c  [        5       U l         U R                   $ )z.Retrieve global instance of the Magics object.)	_instancer.   )clss    r   get_instanceMagics.get_instancey   s!     == &LCM}}r   c                D    [         R                  5       R                  XS9$ )r6   )r   r    )r;   r@   r!   r   s      r   r!   
Magics.llm   s!     ""$((9(RRr   c                $    U R                  X5      $ Nr!   r   s      r   palmMagics.palm       xx	--r   c                $    U R                  X5      $ rE   rF   r   s      r   geminiMagics.gemini   rI   r   r   )returnr   r#   )r%   r&   r'   r(   r)   r>   classmethodr@   r   line_cell_magicr!   rG   rK   r,   r   r   r   r;   r;   n   sp     I  
S 
S . . . .r   r;   )rM   zipython_env.IPythonEnv)r   zcredentials.CredentialsrM   None)#r)   
__future__r   r*   google.authr   google.generativeair   genaigoogle.generativeai.notebookr   r   r   r	   r
   r   IPythonIPython.corer   
USER_AGENTSheetsInputsSheetsOutputspost_process_add_fnpost_process_replace_fnr   __annotations__r   r   ABCr   r.   magics_classr;   get_ipythonregister_magicsr   r   r   <module>rb      s    # 
 # / 7 4 9 6 ; 5   $ ((** )<< ,DD  /3+ 2B$SWW $? ?2 $.U\\ $. $.N     % %f -r   