
    uga                     d    d dl mZmZ d dlZd dlmZ d dlmZmZ d dl	m
Z
 d dlmZ  G d d      Zy)	    )ClassVarDictN)	ServerAPI)SettingsSystem)ProductTelemetryClient)ClientStartEventc                       e Zd ZU i Zeeeef      ed<   eed<    e	       fde	ddfdZ
edede	defd       Zede	defd	       Zed
edefd       Zed
edd fd       Zedd       Zedefd       ZddZy)SharedSystemClient_identifier_to_system_identifiersettingsreturnNc                 x    t         j                  |      | _        t         j                  | j                  |       y N)r   _get_identifier_from_settingsr   _create_system_if_not_exists)selfr   s     V/var/www/openai/venv/lib/python3.12/site-packages/chromadb/api/shared_system_client.py__init__zSharedSystemClient.__init__   s-     .KKHU778H8H(S    
identifierc                 @   || j                   vrUt        |      }|| j                   |<   |j                  t               |j                  t               |j                          n-| j                   |   }|j                  |k7  rt        d| d      | j                   |   S )Nz)An instance of Chroma already exists for z with different settings)r   r   instancer   r   startr   
ValueError)clsr   r   
new_systemprevious_systems        r   r   z/SharedSystemClient._create_system_if_not_exists   s     S666)J4>C%%j1 67	*!77
CO ''83 ?
|Kcd  ((44r   c                     d}| j                   }|t        d      |dk(  r| j                  r| j                  }|S d}|S |dv rt	        t        j                               }|S t        d|       )N z1Chroma API implementation must be set in settingszchromadb.api.segment.SegmentAPI	ephemeral)zchromadb.api.fastapi.FastAPIz'chromadb.api.async_fastapi.AsyncFastAPIz&Unsupported Chroma API implementation )chroma_api_implr   is_persistentpersist_directorystruuiduuid4)r   r   api_impls      r   r   z0SharedSystemClient._get_identifier_from_settings,   s    
++PQQ::%%%77
       
 

 TZZ\*J  EhZPQQr   systemc                 j    t         j                  | j                        }| t         j                  |<   |S r   )r   r   r   r   )r*   r   s     r   _populate_data_from_systemz-SharedSystemClient._populate_data_from_systemE   s-    'EEfooV
?E00<r   c                 T    t         j                  |        | |j                        }|S )zRCreate a client from an existing system. This is useful for testing and debugging.)r   r,   r   )r   r*   r   s      r   from_systemzSharedSystemClient.from_systemK   s%     	55f=v'r   c                      i t         _        y r   )r   r    r   r   clear_system_cachez%SharedSystemClient.clear_system_cacheS   s    350r   c                 <    t         j                  | j                     S r   )r   r   r   )r   s    r   _systemzSharedSystemClient._systemW   s    !778H8HIIr   c                 t    | j                   j                  t              }|j                  t	                      y r   )r3   r   r   capturer	   )r   telemetry_clients     r   _submit_client_start_eventz-SharedSystemClient._submit_client_start_event[   s*    <<001GH  !1!34r   )r   N)__name__
__module____qualname__r   r   r   r&   r   __annotations__r   r   classmethodr   staticmethodr   r,   r.   r1   propertyr3   r7   r0   r   r   r   r   
   s   9;8Df$56; &ZTT 
T 55(05	5 5,  S  0 6 c  
  ,@   6 6 J J J5r   r   )typingr   r   r'   chromadb.apir   chromadb.configr   r   chromadb.telemetry.productr   !chromadb.telemetry.product.eventsr	   r   r0   r   r   <module>rD      s#    !  " , = >S5 S5r   