
    ugJD                        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 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 esd dlmZ d
Z 	 d dl!m Z   ejD                  e#      Z$dZ%dhZ&h dZ'i ddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1Z(ee)e)f   e*d2<   d3Z+d4Z, G d5 d6e)e      Z- G d7 d8e      Z. ed9d:;      Z/ G d< d:ee      Z0 G d= d>e0      Z1 ed?      Z2d@e)dAee2   dBee2   fdCZ3dDee4   dBe)fdEZ5y# e$ r dZd dlmZ d dlmZ Y w xY w# e$ r d
Z Y w xY w)F    N)ABC)Enum)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/MMeYNTmh3x 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
clickhousezchromadb.api.APIchroma_api_implzchromadb.api.ServerAPIz%chromadb.api.async_api.AsyncServerAPIz chromadb.auth.ClientAuthProviderchroma_client_auth_providerz*chromadb.auth.ServerAuthenticationProviderchroma_server_authn_providerz)chromadb.auth.ServerAuthorizationProviderchroma_server_authz_providerzchromadb.db.system.SysDBchroma_sysdb_implz-chromadb.execution.executor.abstract.Executorchroma_executor_implzchromadb.ingest.Consumerchroma_consumer_implzchromadb.ingest.Producerchroma_producer_implzchromadb.quota.QuotaEnforcerchroma_quota_enforcer_implz%chromadb.rate_limit.RateLimitEnforcerchroma_rate_limit_enforcer_implz*chromadb.rate_limit.AsyncRateLimitEnforcer%chroma_async_rate_limit_enforcer_implzchromadb.segment.SegmentManagerchroma_segment_manager_implz-chromadb.segment.distributed.SegmentDirectorychroma_segment_directory_implz/chromadb.segment.distributed.MemberlistProviderchroma_memberlist_provider_implz1chromadb.telemetry.product.ProductTelemetryClientchroma_product_telemetry_impl_abstract_type_keysdefault_tenantdefault_databasec                       e Zd ZdZdZy)
APIVersionz/api/v1z/api/v2N)__name__
__module____qualname__V1V2     D/var/www/openai/venv/lib/python3.12/site-packages/chromadb/config.pyr3   r3   `   s    	B	Br:   r3   c                   <   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<   ej0                  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"<   ej0                   d#gej0                   d$d#gej0                   d%d#gejH                   d#gejH                   d$d#gejH                   d%d#gi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Z0ee   ed2<   d3Z1ee   ed4<   i Z2eeef   ed5<   dZ3ee   ed6<   d7Z4e5d8   ed9<   d:Z6e5d;   ed<<   d=Z7eed><   d?Z8eed@<   dAZ9eedB<   dCZ:dZ;ee   edD<   dEZ<eedF<   dEZ=eedG<   dEZ>eedH<   dIZ?eedJ<   dKZ@eedL<   dCZAdMZBdZCee   edN<   dZDee   edO<   dPZEeedQ<   dRZFeedS<   dTZGeedU<   dVZHeedW<   dVZIeedX<   dYZJeedZ<   dZKee   ed[<   d\ZLeed]<   d^ed	eMfd_ZNd^ed	eMfd`ZO G da db      ZPy)cSettings environmentzchromadb.api.segment.SegmentAPIr    chroma_server_nofileT)prealwaysallow_reusevreturnc                 P    t        |      t        u r|j                         dk(  ry |S )Nr>   )typestrstrip)clsrD   s     r;   empty_str_to_nonezSettings.empty_str_to_noneo   s!    7c>aggi2or:   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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GETz
/heartbeatz/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validaterm   
migrationsmd5)rq   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+   z/chromadb.execution.executor.local.LocalExecutorr%   i  chroma_quota_provider_impl"chroma_rate_limiting_provider_implz8chromadb.quota.simple_quota_enforcer.SimpleQuotaEnforcerr(   z=chromadb.rate_limit.simple_rate_limit.SimpleRateLimitEnforcerr)   zBchromadb.rate_limit.simple_rate_limit.SimpleAsyncRateLimitEnforcerr*      )chroma_logservice_request_timeout_seconds$chroma_sysdb_request_timeout_seconds<   $chroma_query_request_timeout_secondsr   z9chromadb.ingest.impl.simple_policy.SimpleAssignmentPolicy(chroma_collection_assignment_policy_implkeyc                 2    | |   }|t        d| d      |S )zYReturn the value of a required config key, or raise an exception if it is not
        setzMissing required config value '')
ValueErrorselfr   vals      r;   requirezSettings.require  s,     3i;>se1EFF
r:   c                 l    t        | |      }t        |t              r|t        v rt	        t
              |S N)getattr
isinstancerH   _legacy_config_valuesr   LEGACY_ERRORr   s      r;   __getitem__zSettings.__getitem__%  s0    dC c3C+@$@\**
r:   c                       e Zd ZdZdZy)Settings.Configz.envzutf-8N)r4   r5   r6   env_fileenv_file_encodingr9   r:   r;   Configr   ,  s    #r:   r   )Qr4   r5   r6   r?   rH   __annotations__r    r   r   rK   r@   intrM   rO   rP   rQ   rR   r	   rS   rT   boolrU   r   r3   r8   rV   rW   r   rX   rY   rZ   r[   r\   r]   r!   r^   r7   r`   ra   r"   rb   rc   r#   rd   re   r.   rf   rg   rh   rj   rk   rl   rp   r   rs   r,   r-   rt   chroma_coordinator_hostrv   r$   r'   r&   r+   r%   chroma_logservice_hostchroma_logservice_portrw   rx   r(   r)   r*   rz   r{   r}   r   r~   r   r   r   r   r9   r:   r;   r=   r=   e   s4   
 K =OS<%4$O# (3-  P
 +/(3-.*,"C, Is$OS$(,,6:8DcN3:-1Xc]105x~5;?huT3Y'78?;E=="HZ$8H24$d3i4  M4's'%&s&15#5K 9=&< 26#5 59"HSM8 ==/UG==/$ug==/"UG==/UG==/$ug==/"UG=#T#tCy.%9  IN?M 37 (3-659#Xc]9:>((3-> 37 (3-604459#Xc]9 *V!3U!>3>!%$%57#Xc]7.8hsm857"DcN7-1Xc]1 8?J34> ;@w7? *~!3} ,B#S  B"<C<)-1Xc]1?s? B#B B#B 	B    !R#Q("0448<&< 	C  
 	H $S 
 	M *3  67-s601(#102(#2 %)NHSM(C -c 3 3 s s $ $r:   r=   T	Component)boundc                   z    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y
)r   _dependenciesSystem_system_runningc                 >    t               | _        || _        d| _        y )NF)setr   r   r   )r   systems     r;   __init__zComponent.__init__9  s     Ur:   rG   rE   c                 r    | j                   j                  |      }| j                  j                  |       |S )zbGet a Component instance of the given type, and register as a dependency of
        that instance.)r   instancer   add)r   rG   insts      r;   r   zComponent.require>  s1     ||$$T*t$r:   c                     | j                   S )z<Return the full set of components this component depends on.)r   r   s    r;   dependencieszComponent.dependenciesE  s    !!!r:   Nc                 j    t         j                  d| j                  j                          d| _        y)zWIdempotently stop this component's execution and free all associated
        resources.zStopping component FNloggerdebug	__class__r4   r   r   s    r;   stopzComponent.stopI  s*     	*4>>+B+B*CDEr:   c                 j    t         j                  d| j                  j                          d| _        y)z-Idempotently start this component's executionzStarting component TNr   r   s    r;   startzComponent.startO  s(    *4>>+B+B*CDEr:   c                 \    t         j                  d| j                  j                          y)zgReset this component's state to its initial blank state. Only intended to be
        called from tests.zResetting component N)r   r   r   r4   r   s    r;   reset_statezComponent.reset_stateT  s#     	+DNN,C,C+DEFr:   )r   r   rE   N)r4   r5   r6   r
   r   r   r   r   r   r   r   r   r   r   r9   r:   r;   r   r   4  sU    {##N
DG  "c+. "
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           	      D   t         r|d   dvrt        d      t        D ]  }||   	t        t               |d   :|d   dk7  r2t
        j                  d       |d   dk(  rt
        j                  d	       |d
   t        j                         dk7  rdd l	}|j                  |j                        \  }}|d
   }||kD  rt        j                  d| d|        nt||kD  r8	 |j                  |j                  ||f       t
        j                  d|        n7||k  r2t
        j                  d| d| d       nt
        j                  d       || _        i | _        t&        | Q  |        y # t         $ r(}t
        j                  d| d| d|        Y d }~Jd }~ww xY w)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.r[   LRUzAFailed to set chroma_segment_cache_policy: Only LRU is available.rZ   r   zPFailed to set chroma_segment_cache_policy: chroma_memory_limit_bytes is require.r@   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_keysr   r   r   errorplatformr   resource	getrlimitRLIMIT_NOFILEloggingwarning	setrlimitinfo	Exceptionr   r   superr   )	r   r   r   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f
 *+7 I-'/'9'9(:P:P'Q$	9'(>?)+OOopyoz  {S  T]  S^  _ "I- **$22\94M &B<.$QR "I-NN9,Guv  vA  Ah  i m !! % D\NRTUVTWWy  {D  zE  F s   "6E. .	F7FFrG   rE   c                    t        j                  |      rQt        |      }|t        vrt	        d|       t        |   }| j
                  j                  |      }t        ||      }|| j                  vr3 ||       }|| j                  |<   | j                  r|j                          | 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/   r   r   r   	get_classr   r   r   r   r   )r   rG   type_fqnr   fqnimplr   s          r;   r   zSystem.instance  s     d#t}H22 #EdV!LMM%h/C--'',CS$'Dt&:D$(DOOD!}}

t$At}r:   c                     t               }| j                  j                         D ]#  } |j                  |g|j	                           % |j                         S )zYReturn the full set of all components and their dependencies in dependency
        order.)r   r   valuesr   r   static_order)r   sorter	components      r;   
componentszSystem.components  sQ     0A/B//1IFJJy<9#9#9#;< 2 ""$$r:   c                 l    t         |           | j                         D ]  }|j                           y r   )r   r   r   r   r   r   s     r;   r   zSystem.start  s'    *IOO +r:   c                     t         |           t        t        | j	                                     D ]  }|j                           y r   )r   r   reversedlistr   r   s     r;   r   zSystem.stop  s1    !$t'8"9:INN ;r:   c                     | j                   j                  st        d      t        t	        | j                                     D ]  }|j                           y)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   r\   r   r   r   r   r   )r   r   s     r;   r   zSystem.reset_state  sM     }}(( |  "$t'8"9:I!!# ;r:   r   )r4   r5   r6   r=   r   r	   r   r   r   r   r   r   r   r   r   r   r   __classcell__)r   s   @r;   r   r   Z  s    T)_i/00? ?BT!W  *%HY/ %  
  
 $ $r:   r   Cr   rG   rE   c                     | j                  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_moduler   r   r   r   )r   rG   module_name
class_namemodulerJ   s         r;   r   r     sD    !jja0K$$[1F
&*
%CQr:   rJ   c                 8    | j                    d| j                   S )z.Given a class, return its fully qualified namer   )r5   r4   )rJ   s    r;   r   r     s    nnQs||n--r:   )6r   r   r   abcr   enumr   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	getLoggerr4   r   r   r   r   r/   rH   r   DEFAULT_TENANTDEFAULT_DATABASEr3   r=   r   r   r   r   r   objectr   r9   r:   r;   <module>r      sL        & B B B & & &  %  &% " 6 
		8	$R  
  ' )	'
 /' ,->' '(E' 12P' 01O'  3' 45K'  6'  6' #$@' ,-N'  12Y!'" &'D#'$ 45T%'& 67X''( 89X)' T#s(^ . "% d 
I$| I$X C{##G% #GLw$Y w$t CL3 d1g $q' .f .# .Y  &N(%&  Ns$   D& &D? &D<;D<?E	E	