
    ei9                        d dl mZmZmZ d dlZd dlmZ d dlmZ	 d dl
mZ d dlmZ d dlZd dlmZmZmZ d dlmZ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!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9 d dl:m;Z; d dl<m=Z=m>Z>m?Z?m@Z@ d dlAmBZB d dlCZCg dZDd dlEmFZF  ej                  eH      ZI e       aJdZKdeLfdZM eM       ZNdZO	 d dlPmQZQ eQZOeOswd dlSZSeSj                  dk  rdeNrZd dlUZUd dlVZV eUj                  eVj                  ddddg        eYd       eVj                  j                  d      eVj                  d<   n e\d      d:dZ]defdZ^deefdee   d e_d!e_defd"Z`d#deefd$ee_eBf   dee   d e_d!e_def
d%Zaddeefd$ee_   dee   d e_d!e_def
d&Zbd'd(dddeefd)e_d*ecd+eLd,eee_e_f      dee   d e_d!e_defd-Zdd'd(dddeefd)e_d*ecd+eLd,eee_e_f      dee   d e_d!e_defd.Ze	 	 	 	 d;d/d0d1d2d ee_   d!ee_   d3ee_   dee   d4e_d5ecd6eLdefd7Zft        eefded e_d!e_defd8Z e       fdedefd9Zy# eR$ r dZOY pw xY w)<    )DictOptionalUnionN)Client)AdminClient)AsyncClient)TokenTransportHeader)DEFAULT_DATABASEDEFAULT_TENANTSettings)AdminAPIAsyncClientAPI	ClientAPI)
Collection)CmekCollectionMetadataUpdateMetadata	DocumentsEmbeddingFunction
EmbeddingsURIURIsIDsIncludeMetadata	Metadatas	ReadLevelWhereQueryResult	GetResultWhereDocumentUpdateCollectionMetadataSparseVectorSparseVectorsSparseEmbeddingFunctionSchemaVectorIndexConfigHnswIndexConfigSpannIndexConfigFtsIndexConfigSparseVectorIndexConfigStringInvertedIndexConfigIntInvertedIndexConfigFloatInvertedIndexConfigBoolInvertedIndexConfig)Search)KeyKKnnRrf)Path)%r   r   r   r   r   r!   r   r   r   r   r   r   r   r   r   r"   r   r    r	   r0   r1   r2   r3   r4   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   )CloudClientArgz1.4.1returnc                  ,    	 dd l } y# t        $ r Y yw xY w)Nr   TF)google.colabImportError)googles    [/home/obispo/Crisostomo_bridge/mision_env/lib/python3.12/site-packages/chromadb/__init__.pyis_in_colabr=   s   s     s    	F)is_thin_client)   #   r   z-mpipinstallzpysqlite3-binary	pysqlite3sqlite3z[91mYour system has an unsupported version of sqlite3. Chroma                     requires sqlite3 >= 3.35.0.[0m
[94mPlease visit                     https://docs.trychroma.com/troubleshooting#sqlite to learn how                     to upgrade.[0mc                  B    t        j                  j                  di | ay)zGOverride Chroma's default settings, environment variables or .env filesN )chromadbconfigr   
__settings)kwargss    r<   	configurerK      s     ))3F3J    c                      t         S )N)rI   rF   rL   r<   get_settingsrN      s    rL   settingstenantdatabasec                 p    | 
t               } d| _        t        |      }t        |      }t        | ||      S )aA  
    Creates an in-memory instance of Chroma. This is useful for testing and
    development, but not recommended for production use.

    Args:
        tenant: The tenant to use for this client. Defaults to the default tenant.
        database: The database to use for this client. Defaults to the default database.
    FrO   rP   rQ   )r   is_persistentstrClientCreatorrS   s      r<   EphemeralClientrW      s<     :"H [F8}H(6HMMrL   z./chromapathc                     |
t               }t        |       |_        d|_        t        |      }t        |      }t	        |||      S )a  
    Creates a persistent instance of Chroma that saves to disk. This is useful for
    testing and development, but not recommended for production use.

    Args:
        path: The directory to save Chroma's data to. Defaults to "./chroma".
        tenant: The tenant to use for this client. Defaults to the default tenant.
        database: The database to use for this client. Defaults to the default database.
    TrP   rQ   rO   )r   rU   persist_directoryrT   rV   rX   rO   rP   rQ   s       r<   PersistentClientr]      sH     :!$TH!H [F8}HHMMrL   c                     |
t               }d|_        | du|_        | xs d|_        t	        |      }t	        |      }t        |||      S )a  
    Creates an ephemeral or persistance instance of Chroma that saves to disk.
    This is useful for testing and development, but not recommended for production use.

    Args:
        path: An optional directory to save Chroma's data to. The client is ephemeral if a None value is provided. Defaults to None.
        tenant: The tenant to use for this client. Defaults to the default tenant.
        database: The database to use for this client. Defaults to the default database.
    Nz!chromadb.api.rust.RustBindingsAPI rZ   )r   chroma_api_implrT   r[   rU   rV   r\   s       r<   
RustClientra      sU     :BH!-H!%H [F8}HHMMrL   	localhosti@  hostportsslheadersc                    |
t               }t        |       } t        |      }t        |      }t        |      }t        |      }d|_        |j
                  r+|j
                  | k7  rt        d|j
                   d|  d      | |_        |j                  r+|j                  |k7  rt        d|j                   d| d      ||_        ||_        ||_	        t        |||      S )a  
    Creates a client that connects to a remote Chroma server. This supports
    many clients connecting to the same server, and is the recommended way to
    use Chroma in production.

    Args:
        host: The hostname of the Chroma server. Defaults to "localhost".
        port: The port of the Chroma server. Defaults to 8000.
        ssl: Whether to use SSL to connect to the Chroma server. Defaults to False.
        headers: A dictionary of headers to send to the Chroma server. Defaults to {}.
        settings: A dictionary of settings to communicate with the chroma server.
        tenant: The tenant to use for this client. Defaults to the default tenant.
        database: The database to use for this client. Defaults to the default database.
    chromadb.api.fastapi.FastAPI(Chroma server host provided in settings[3] is different to the one provided in HttpClient: []-Chroma server http port provided in settings[rZ   )r   rU   intboolr`   chroma_server_host
ValueErrorchroma_server_http_portchroma_server_ssl_enabledchroma_server_headersrV   rc   rd   re   rf   rO   rP   rQ   s          r<   
HttpClientru      s"   0 : t9Dt9D
s)C[F8}H=H""x'B'Bd'J6x7R7R6S  TG  HL  GM  MN  O
 	
 #'H''H,L,LPT,T;H<\<\;]  ^Q  RV  QW  WX  Y
 	
 (,H$),H&%,H"HMMrL   c                   K   |
t               }t        |       } t        |      }t        |      }t        |      }t        |      }d|_        |j
                  r+|j
                  | k7  rt        d|j
                   d|  d      | |_        |j                  r+|j                  |k7  rt        d|j                   d| d      ||_        ||_        ||_	        t        j                  |||       d{   S 7 w)a  
    Creates an async client that connects to a remote Chroma server. This supports
    many clients connecting to the same server, and is the recommended way to
    use Chroma in production.

    Args:
        host: The hostname of the Chroma server. Defaults to "localhost".
        port: The port of the Chroma server. Defaults to 8000.
        ssl: Whether to use SSL to connect to the Chroma server. Defaults to False.
        headers: A dictionary of headers to send to the Chroma server. Defaults to {}.
        settings: A dictionary of settings to communicate with the chroma server.
        tenant: The tenant to use for this client. Defaults to the default tenant.
        database: The database to use for this client. Defaults to the default database.
    Nz'chromadb.api.async_fastapi.AsyncFastAPIri   rj   rk   rl   rZ   )r   rU   rm   rn   r`   ro   rp   rq   rr   rs   AsyncClientCreatorcreatert   s          r<   AsyncHttpClientry   +  s;    0 : t9Dt9D
s)C[F8}HHH""x'B'Bd'J6x7R7R6S  TG  HL  GM  MN  O
 	
 #'H''H,L,LPT,T;H<\<\;]  ^Q  RV  QW  WX  Y
 	
 (,H$),H&%,H"#**8   s   C0C92C73C9zapi.trychroma.comi  T)
cloud_host
cloud_port
enable_sslapi_keyrz   r{   r|   c                   t        dd|      g}t        |D cg c]  }|j                   c}      sC|D ]>  }|j                  xs) t        j                  j                  |j                        |_        @ |D cg c]  }|j                  | }	}|	r_t        ddj                  |	D cg c]  }|j                   c}       ddj                  |	D cg c]  }|j                   c}             |
t               }| xs t        j                  j                  d      } | t        |       } |xs t        j                  j                  d      }|t        |      }t        |      }t        |      }t        |      }t        |      }d	|_        ||_        ||_        ||_        d
|_        ||_        t(        j*                  |_        d|_        t1        | ||      S c c}w c c}w c c}w c c}w )aK  
    Creates a client to connect to a tenant and database on Chroma cloud.

    Args:
        tenant: The tenant to use for this client. Optional. If not provided, it will be inferred from the API key if the key is scoped to a single tenant. If provided, it will be validated against the API key's scope.
        database: The database to use for this client. Optional. If not provided, it will be inferred from the API key if the key is scoped to a single database. If provided, it will be validated against the API key's scope.
        api_key: The api key to use for this client.
    r}   CHROMA_API_KEY)nameenv_varvaluezMissing required arguments: z, z8. Please provide them or set the environment variables: CHROMA_TENANTCHROMA_DATABASErh   z1chromadb.auth.token_authn.TokenAuthClientProviderTrZ   )r6   allr   osenvirongetr   rp   joinr   r   rU   rm   rn   r`   ro   rq   rr   chroma_client_auth_providerchroma_client_auth_credentialsr	   X_CHROMA_TOKEN"chroma_auth_token_transport_header;chroma_overwrite_singleton_tenant_database_access_from_authrV   )
rP   rQ   r}   rO   rz   r{   r|   required_argsargmissing_argss
             r<   CloudClientr   `  s   ( 	I/?wOM
 ]3c		34  	AC		@RZZ^^CKK%@CI	A $1FCCII4ECFLF*499,5W3chh5W+X*Y ZEEIYYgsOt`cPSP[P[OtEuDvx
 	

 : 6rzz~~o6FV<2::>>*;<Hx='lGZJZJj!J=H",H'1H$)3H& 	< ( /6H+2F2U2UH/KOHHHMMM 4 G 6XOts   G:G$G$)G)G.c                 J    t        |      }t        |      }t        |||       S )z
    Return a running chroma.API instance

    tenant: The tenant to use for this client. Defaults to the default tenant.
    database: The database to use for this client. Defaults to the default database.
    rZ   )rU   rV   rS   s      r<   r   r     s%     [F8}HHMMrL   c                     t        |       S )zU

    Creates an admin client that can be used to create tenants and databases.

    rO   )AdminClientCreatorr   s    r<   r   r     s     x00rL   )r7   N)NNNN)gtypingr   r   r   loggingchromadb.api.clientr   rV   r   r   chromadb.api.async_clientr   rw   chromadb.auth.token_authnr	   chromadb.configrG   r
   r   r   chromadb.apir   r   r   chromadb.api.models.Collectionr   chromadb.api.typesr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   "chromadb.execution.expression.planr0   &chromadb.execution.expression.operatorr1   r2   r3   r4   pathlibr5   r   __all__chromadb.typesr6   	getLogger__name__loggerrI   __version__rn   r=   IN_COLAB	is_clientchromadb.is_thin_clientr>   r:   rD   sqlite_version_info
subprocesssys
check_call
executable
__import__modulespopRuntimeErrorrK   rN   rU   rW   r]   ra   rm   ru   ry   r   rF   rL   r<   <module>r      s)   ( (  7 H :  F F < < 5                 F 6   	)V *			8	$Z
T  =	6I ""Z/!J!!ui9KL {#%([[__[%ACKK	"( 4h 
 $( $Nx NN N 	N2 (#' $	N
T	
Nx N N 	N
 N8 #' $	N
3-Nx N N 	N
 N< (,#' $0N
0N
0N 
0N d38n%	0N
 x 0N 0N 0N 0Nh (,#' $2
2
2 
2 d38n%	2
 x 2 2 2 2l !"!#'	>N *>NSM>Nsm>N c]>N x 	>N >N >N >N >ND $ $NNN N 	N& &.Z 1( 1H 1c	  Is   I II