
    ti@                     f   U d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZm	Z	m
Z
mZ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 d dlmZ d dlZd	Z	 d d
lmZ n# e$ r dZd d
lmZ d dlmZ Y nw xY wesd dlmZ d	Z	 d dlmZ n# e$ r d	ZY nw xY w ej         e!          Z"dZ#dhZ$h dZ%ddddddddddddddddZ&ee'e'f         e(d<   d Z)d!Z* G d" d#e          Z+ ed$d%&          Z, G d' d%ee          Z- G d( d)e-          Z. ed*          Z/d+e'd,ee/         d-ee/         fd.Z0d/ee1         d-e'fd0Z2dS )1    N)ABC)TopologicalSorter)OptionalListAnyDictSetIterableUnion)TypeTypeVarcast)EnforceOverrides)override)LiteralF)BaseSettingsT)	validator)is_thin_clienta  [91mYou are using a deprecated configuration of Chroma.

[94mIf you do not have data you wish to migrate, you only need to change how you construct
your Chroma client. Please see the "New Clients" section of https://docs.trychroma.com/deployment/migration.
________________________________________________________________________________________________

If you do have data you wish to migrate, we have a migration tool you can use in order to
migrate your data to the new Chroma architecture.
Please `pip install chroma-migrate` and run `chroma-migrate` to migrate your data and then
change how you construct your Chroma client.

See https://docs.trychroma.com/deployment/migration for more information or join our discord at https://discord.gg/8g5FESbj for help![0mchroma_db_impl>	   duckdb+parquetchromadb.db.duckdb.DuckDBchromadb.api.local.LocalAPI!chromadb.db.clickhouse.Clickhouse#chromadb.db.duckdb.PersistentDuckDBrestlocalduckdb
clickhousechroma_api_implchroma_client_auth_providerchroma_server_authn_providerchroma_server_authz_providerchroma_sysdb_implchroma_consumer_implchroma_producer_implchroma_quota_provider_impl"chroma_rate_limiting_provider_implchroma_segment_manager_implchroma_segment_directory_implchroma_memberlist_provider_implchroma_product_telemetry_impl)zchromadb.api.APIzchromadb.api.ServerAPIz%chromadb.api.async_api.AsyncServerAPIz chromadb.auth.ClientAuthProviderz*chromadb.auth.ServerAuthenticationProviderz)chromadb.auth.ServerAuthorizationProviderzchromadb.db.system.SysDBzchromadb.ingest.Consumerzchromadb.ingest.Producerzchromadb.quota.QuotaProviderz+chromadb.rate_limiting.RateLimitingProviderzchromadb.segment.SegmentManagerz-chromadb.segment.distributed.SegmentDirectoryz/chromadb.segment.distributed.MemberlistProviderz1chromadb.telemetry.product.ProductTelemetryClient_abstract_type_keysdefault_tenantdefault_databasec                      e Zd ZU dZeed<   dZeed<    edddd          ded	ee         fd
            Z	dZ
ee         ed<   dZeed<   dZeed<   dZeed<   dZee         ed<   dZeeeef                  ed<   dZee         ed<   dZee         ed<   dZeeeef                  ed<   dZee         ed<   g Zee         ed<   dZeed<   dZeed<   dZeed<   dZee         ed<   dZeed <   dZee         ed!<   dZ ee         ed"<   dZ!ee         ed#<   d$gd$gd$gd%Z"eeee         f         ed&<   dZ#eed'<   dZ$ee         ed(<   dZ%ee         ed)<   dZ&ee         ed*<   dZ'ee         ed+<   dZ(ee         ed,<   dZ)ee         ed-<   d.Z*eed/<   e*Z+eed0<   dZ,eed1<   dZ-ee         ed2<   d3Z.ee         ed4<   i Z/eeef         ed5<   dZ0ee         ed6<   d7Z1e2d8         ed9<   d:Z3e2d;         ed<<   d=Z4eed><   d?Z5eed@<   dAZ6eedB<   dCZ7dZ8ee         edD<   dEZ9eedF<   dEZ:eedG<   dEZ;eedH<   dIZ<eedJ<   dCZ=dKZ>dZ?ee         edL<   dZ@ee         edM<   dZAee         edN<   dOZBeedP<   dQed	eCfdRZDdQed	eCfdSZE G dT dU          ZFdS )VSettings environmentzchromadb.api.segment.SegmentAPIr   chroma_server_nofileT)prealwaysallow_reusevreturnc                 f    t          |          t          u r|                                dk    rd S |S )Nr1   )typestrstrip)clsr7   s     B/var/www/icac/venv/lib/python3.11/site-packages/chromadb/config.pyempty_str_to_nonezSettings.empty_str_to_noneg   s+    77c>>aggii2oo4    N(   chroma_server_thread_pool_sizedefault	tenant_idtopic_namespacechroma_server_hostchroma_server_headerschroma_server_http_portFchroma_server_ssl_enabledchroma_server_ssl_verify/api/v1chroma_server_api_default_path chroma_server_cors_allow_originsis_persistentz./chromapersist_directoryr   chroma_memory_limit_byteschroma_segment_cache_policyallow_reset"chroma_auth_token_transport_headerr    chroma_client_auth_credentialsGET)rK   z/api/v1/heartbeatz/api/v1/versionchroma_server_auth_ignore_paths;chroma_overwrite_singleton_tenant_database_access_from_authr!   chroma_server_authn_credentials$chroma_server_authn_credentials_filer"   chroma_server_authz_configchroma_server_authz_config_filez*chromadb.telemetry.product.posthog.Posthogr+   chroma_telemetry_implanonymized_telemetrychroma_otel_collection_endpointchromadbchroma_otel_service_namechroma_otel_collection_headerschroma_otel_granularityapply)nonevalidaterc   
migrationsmd5)rg   sha256migrations_hash_algorithmzRchromadb.segment.impl.distributed.segment_directory.RendezvousHashSegmentDirectoryr)   zTchromadb.segment.impl.distributed.segment_directory.CustomResourceMemberlistProviderr*   zquery-service-memberlistworker_memberlist_name	localhostchroma_server_grpc_portz chromadb.db.impl.sqlite.SqliteDBr#   r%   r$   z7chromadb.segment.impl.manager.local.LocalSegmentManagerr(   i  r&   r'   r   z9chromadb.ingest.impl.simple_policy.SimpleAssignmentPolicy(chroma_collection_assignment_policy_implkeyc                 @    | |         }|t          d| d          |S )zYReturn the value of a required config key, or raise an exception if it is not
        setNzMissing required config value '')
ValueErrorselfrn   vals      r>   requirezSettings.require   s1     3i;EsEEEFFF
r@   c                     t          | |          }t          |t                    r|t          v rt	          t
                    |S N)getattr
isinstancer;   _legacy_config_valuesrq   LEGACY_ERRORrr   s      r>   __getitem__zSettings.__getitem__  sA    dC  c3 	+C+@$@$@\***
r@   c                       e Zd ZdZdZdS )Settings.Configz.envzutf-8N)__name__
__module____qualname__env_fileenv_file_encoding r@   r>   Configr~     s        #r@   r   )Gr   r   r   r2   r;   __annotations__r   r   r   r?   r3   intrB   rD   rE   rF   rG   r   rH   rI   boolrJ   r   rL   rM   r   rN   rO   rP   rQ   rR   rS   r    rT   rV   rW   r!   rX   rY   r"   rZ   r[   r+   r\   r]   r^   r`   ra   rb   rf   r   ri   r)   r*   rj   chroma_coordinator_hostrl   r#   r%   r$   r(   chroma_logservice_hostchroma_logservice_portr&   r'   r   rm   r   ru   r|   r   r   r@   r>   r0   r0   ]   s        
 K =OS<<<Y%4$OOO# (3-    PO
 +/(3-...*,"C,,, Is$OS$$$(,,,,6:8DcN3:::-1Xc]11105x~555;?huT3Y'78???4="HSM===24$d3i444  M4's'''%&s&&&15#555K 9=&<<< 26#555 59"HSM888 7#W!7= =#T#tCy.%9    IN?MMM 37 (3-66659#Xc]999:>((3->>> 37 (3-6660444459#Xc]999 *V!3UUU!>3>>>!%$%%%57#Xc]777.8hsm88857"DcN777-1Xc]111 8?J34>>> ;@w7??? *~!3}}} ,B#S  B  B  B"<C<<<)-1Xc]111?s??? B#BBB B#BBB 	B      )"044448<&<<< %)NHSM(((C -c   3 3    s s    $ $ $ $ $ $ $ $ $ $r@   r0   T	Component)boundc                       e Zd ZU ed          ed<   ded<   eed<   ddZdee         defd	Z	ded          fd
Z
ddZddZddZdS )r   _dependenciesSystem_system_runningsystemc                 H    t                      | _        || _        d| _        d S )NF)setr   r   r   )rs   r   s     r>   __init__zComponent.__init__  s      UUr@   r:   r8   c                 n    | j                             |          }| j                            |           |S )zbGet a Component instance of the given type, and register as a dependency of
        that instance.)r   instancer   add)rs   r:   insts      r>   ru   zComponent.require  s5     |$$T**t$$$r@   c                     | j         S )z<Return the full set of components this component depends on.)r   rs   s    r>   dependencieszComponent.dependencies&  s    !!r@   Nc                 b    t                               d| j        j                    d| _        dS )zWIdempotently stop this component's execution and free all associated
        resources.zStopping component FNloggerdebug	__class__r   r   r   s    r>   stopzComponent.stop*  s/     	D4>+BDDEEEr@   c                 b    t                               d| j        j                    d| _        dS )z-Idempotently start this component's executionzStarting component TNr   r   s    r>   startzComponent.start0  s-    D4>+BDDEEEr@   c                 T    t                               d| j        j                    dS )zgReset this component's state to its initial blank state. Only intended to be
        called from tests.zResetting component N)r   r   r   r   r   s    r>   reset_statezComponent.reset_state5  s*     	EDN,CEEFFFFFr@   )r   r   r8   N)r   r   r   r	   r   r   r   r   r   ru   r   r   r   r   r   r@   r>   r   r     s         {####NNN   
DG     "c+. " " " "      
G G G G G Gr@   c                        e Zd ZU eed<   eee         ef         ed<   def fdZdee	         de	fdZ
dee         fdZed fd	            Zed fd
            Zedd            Z xZS )r   settings
_instancesc           	         t           r|d         dvrt          d          t          D ]}||         t          t                    |d         L|d         dk    r@t
                              d           |d         dk    rt
                              d	           |d
         t          j                    dk    rdd l	}|
                    |j                  \  }}|d
         }||k    rt          j        d| d|            n||k    rv	 |                    |j        ||f           t
                              d|            n|# t           $ r-}t
                              d| d| d|            Y d }~nJd }~ww xY w||k     r!t
                              d| d| d           nt
                              d           || _        i | _        t'                                          |            d S )Nr   )zchromadb.api.fastapi.FastAPIz'chromadb.api.async_fastapi.AsyncFastAPIa  Chroma is running in http-only client mode, and can only be run with 'chromadb.api.fastapi.FastAPI' or 'chromadb.api.async_fastapi.AsyncFastAPI' as the chroma_api_impl.             see https://docs.trychroma.com/guides#using-the-python-http-only-client for more information.rQ   LRUzAFailed to set chroma_segment_cache_policy: Only LRU is available.rP   r   zPFailed to set chroma_segment_cache_policy: chroma_memory_limit_bytes is require.r3   WindowszUchroma_server_nofile cannot be set to a value greater than the current hard limit of z. Keeping soft limit at zSet chroma_server_nofile to z&Failed to set chroma_server_nofile to z: z" nofile soft limit will remain at zchroma_server_nofile is set to z., but this is less than current soft limit of z'. chroma_server_nofile will not be set.zWchroma_server_nofile is not supported on Windows. chroma_server_nofile will not be set.)r   RuntimeError_legacy_config_keysrq   r{   r   errorplatformr   resource	getrlimitRLIMIT_NOFILEloggingwarning	setrlimitinfo	Exceptionr   r   superr   )	rs   r   rn   r   	curr_soft	curr_harddesired_softer   s	           r>   r   zSystem.__init__?  s    		)* 3   #k  
 ' 	/ 	/C}( ... ) 23?675@@LLS   3499f  
 *+7  I--'/'9'9(:P'Q'Q$	9'(>?)++O _py  _  _  T]  _  _    "I-- **$2\94M   $Q<$Q$QRRRR$    F\  F  FUV  F  F  {D  F  F       
 "I--NN i,  i  iv  i  i  i   m   !s   :E 
E?#E::E?r:   r8   c                    t          j        |          rat          |          }|t          vrt	          d|           t          |         }| j                            |          }t          ||          }|| j        vr0 ||           }|| j        |<   | j	        r|
                                 | j        |         }t          t          |          S )z|Return an instance of the component type specified. If the system is running,
        the component will be started as well.z"Cannot instantiate abstract type: )inspect
isabstractget_fqnr,   rq   r   ru   	get_classr   r   r   r   r   )rs   r:   type_fqnrn   fqnimplr   s          r>   r   zSystem.instance  s     d## 	(t}}H222 !Ld!L!LMMM%h/C-'',,CS$''Dt&&4::D$(DOD!} 

t$At}}r@   c                     t                      }| j                                        D ]"} |j        |g|                                R   #|                                S )zYReturn the full set of all components and their dependencies in dependency
        order.)r   r   valuesr   r   static_order)rs   sorter	components      r>   
componentszSystem.components  sh     0A/B/B//11 	= 	=IFJy<9#9#9#;#;<<<<<""$$$r@   Nc                     t                                                       |                                 D ]}|                                 d S rw   )r   r   r   rs   r   r   s     r>   r   zSystem.start  sJ    ** 	 	IOO	 	r@   c                     t                                                       t          t          |                                                     D ]}|                                 d S rw   )r   r   reversedlistr   r   s     r>   r   zSystem.stop  sZ    !$t'8'8"9"9:: 	 	INN	 	r@   c                     | j         j        st          d          t          t	          |                                                     D ]}|                                 dS )zOReset the state of this system and all constituents in reverse dependency orderzResetting is not allowed by this configuration (to enable it, set `allow_reset` to `True` in your Settings() or include `ALLOW_RESET=TRUE` in your environment variables)N)r   rR   rq   r   r   r   r   )rs   r   s     r>   r   zSystem.reset_state  ss     }( 	 |   "$t'8'8"9"9:: 	$ 	$I!!####	$ 	$r@   r   )r   r   r   r0   r   r   r   r   r   r   r   r
   r   r   r   r   r   __classcell__)r   s   @r>   r   r   ;  s'        T)_i/0000? ? ? ? ? ? ?BT!W     *%HY/ % % % %      X
      X
 $ $ $ X$ $ $ $ $r@   r   Cr   r:   r8   c                     |                      dd          \  }}t          j        |          }t          ||          }t	          t
          t                   |          S )zIGiven a fully qualifed class name, import the module and return the class.   )rsplit	importlibimport_modulerx   r   r   r   )r   r:   module_name
class_namemoduler=   s         r>   r   r     sM    !jja00K$[11F
&*
%
%CQr@   r=   c                 $    | j          d| j         S )z.Given a class, return its fully qualified namer   )r   r   )r=   s    r>   r   r     s    n--s|---r@   )3r   r   r   abcr   graphlibr   typingr   r   r   r   r	   r
   r   r   r   r   	overridesr   r   typing_extensionsr   r   in_pydantic_v2pydanticr   ImportErrorpydantic.v1r   r   chromadb.is_thin_client	getLoggerr   r   r{   r   rz   r,   r;   r   DEFAULT_TENANTDEFAULT_DATABASEr0   r   r   r   r   r   objectr   r   r@   r>   <module>r      sh                & & & & & & B B B B B B B B B B B B B B B B B B & & & & & & & & & & & & & & & &       % % % % % %  &%%%%%%% & & &N((((((%%%%%%%%&
  #"""""" 6666666   NNN 
	8	$	$P  
 
 
 ( */->(E2P1O 3 6 6$@3W'D5T7X9X%' ' T#s(^   * "% r$ r$ r$ r$ r$| r$ r$ r$j GC{####G #G #G #G #G% #G #G #GLw$ w$ w$ w$ w$Y w$ w$ w$t GCLL3 d1g $q'    .f .# . . . . . .s$   A A,+A,:B B
B