
    ug                     L   d dl mZ d dlmZ d dlmZmZmZ d dlZ	d dl
mZ d dl	Z	d dlZd dlZd dlZd dlmZ d dlmZmZmZ d dlmZmZ d d	lmZ d d
lmZ d dlmZ  e	j<                         Z e	j<                  d      Z ejC                  e d       dZ"ejG                          e	jH                  dd      dd e	jH                  dd       e	jH                  dddd      fde%deee%    e	jH                  d      f   deee%    e	jH                  d       f   d!e&d"e'd#dfd$       Z(e jG                          e	jH                  d%       e	jH                  dd&      fde%d'e'd#dfd(       Z)ejG                         d,d)       Z*ejG                         d,d*       Z+e,d+k(  r e        yy)-    )Optional)Console)ProgressSpinnerColumn
TextColumnN)	Annotated)Client)get_directory_sizeset_log_file_path
sizeof_fmt)SettingsSystem)SqliteDB),trigger_vector_segments_max_seq_id_migration)SegmentManagerzUse maintenance utilities)
short_helputils)nameal  
                [38;5;069m(((((((((    [38;5;203m((((([38;5;220m####
             [38;5;069m((((((((((((([38;5;203m((((((((([38;5;220m#########
           [38;5;069m((((((((((((([38;5;203m((((((((((([38;5;220m###########
         [38;5;069m(((((((((((((([38;5;203m(((((((((((([38;5;220m############
        [38;5;069m((((((((((((([38;5;203m(((((((((((((([38;5;220m#############
        [38;5;069m((((((((((((([38;5;203m(((((((((((((([38;5;220m#############
         [38;5;069m(((((((((((([38;5;203m((((((((((((([38;5;220m##############
         [38;5;069m(((((((((((([38;5;203m(((((((((((([38;5;220m##############
           [38;5;069m(((((((((([38;5;203m((((((((((([38;5;220m#############
             [38;5;069m(((((((([38;5;203m(((((((([38;5;220m##############
                [38;5;069m((((([38;5;203m((((    [38;5;220m#########[0m

    z./chroma_dataz"The path to the file or directory.)help	localhostz
chroma.logi@  zThe port to run the server on.Fz
Test mode.T)r   show_envvarhiddenpathhostz)The host to listen to. Default: localhostlog_pathzThe path to the log file.porttestreturnc                    t               }t        d       t        t               t        d       t        d       t        d       |j                  d|  d       |j                  d| d| d       |j                  d       d	t        j                  d
<   | t        j                  d<   dt        j                  d<   d	t        j                  d<   t        j
                  j                  t        j
                  j                  t                    }t        j
                  j                  |      }t        | d|       }d||d|dd}|ryt        j                  di | y)zRun a chroma serverz[1mzRunning Chromaz[0mz$[bold]Saving data to:[/bold] [green]z[/green]z1[bold]Connect to chroma at:[/bold] [green]http://:z][bold]Getting started guide[/bold]: [blue]https://docs.trychroma.com/getting-started[/blue]

TrueIS_PERSISTENTPERSIST_DIRECTORY65535CHROMA_SERVER_NOFILE
CHROMA_CLIz/log_config.ymlzchromadb.app:app      )appr   r   workers
log_configtimeout_keep_aliveN )r   print_logoosenvironr   dirnamerealpath__file__r   uvicornrun)	r   r   r   r   r   consolechromadb_pathr+   configs	            E/var/www/openai/venv/lib/python3.12/site-packages/chromadb/cli/cli.pyr6   r6   '   s0    iG	)	%L	)	
	)MM8hGHMM
;D64&Q MMi
 #)BJJ&*BJJ"#)0BJJ%&%BJJ| GGOOBGG$4$4X$>?M GGOOM2M"m_O#D
TJ!  F KK&    z$The path to a Chroma data directory.z%Force vacuuming without confirmation.forcec                 p   t        d      }t        j                  j                  |       s+|j	                  d|  d       t        j                  d      t        j                  j                  |  d      s+|j	                  d|  d       t        j                  d      |s<t        j                  d	      s'|j	                  d
       t        j                  d      t               }d|_	        | |_
        t        |      }|j                          t        j                  |      }|j                  t               }t#        |       }|j	                          t%        t'        d      t)        d      d      5 }|j+                         }	|j-                  dt/        |	            }
	 t1        ||j                  t2                     |	D ]B  }|j5                  |      }|j7                  |j8                         |j;                  |
d       D 	 |j-                  d      }
	 |j?                          |j@                  }|jC                  dd       |jE                  |       |j;                  |
d       ddd       t#        |       }||z
  }|j	                  dtG        |       d|dz  |z  dd       y# t<        $ r/}|j	                  d|        t        j                  d      d}~ww xY w# t<        $ r/}|j	                  d|        t        j                  d      d}~ww xY w# 1 sw Y   xY w) a  
    Vacuum the database. This may result in a small increase in performance.

    If you recently upgraded Chroma from a version below 0.5.6 to 0.5.6 or above, you should run this command once to greatly reduce the size of your database and enable continuous database pruning. In most other cases, vacuuming will save very little disk space.

    The execution time of this command scales with the size of your database. It blocks both reads and writes to the database while it is running.
    F)	highlightz[bold red]Path z does not exist.[/bold red]r'   )codez/chroma.sqlite3z+ is not a Chroma data directory.[/bold red]zAre you sure you want to vacuum the database? This will block both reads and writes to the database and may take a while. We recommend shutting down the server before running this command. Continue?zVacuum cancelled.r   T)settingsz+[bold green]:heavy_check_mark:[/bold green])finished_textz([progress.description]{task.description})	transientzPurging the log...)total)collection_id)advancez,[bold red]Error purging the log:[/bold red] Nz$Vacuuming (this may take a while)...automatically_purgez/[bold red]Error vacuuming database:[/bold red] d   zE:soap: [bold]vacuum complete![/bold] Database size reduced by [green]z#[/green] (:arrow_down: [bold green]z.1fz%[/bold green]).)$r   r0   r   existsr.   typerExitconfirmr   is_persistentpersist_directoryr   startr	   from_systeminstancer   r
   r   r   r   list_collectionsadd_tasklenr   r   get_collection	purge_logidupdate	Exceptionvacuumr9   set_parameter
set_configr   )r   r<   r7   r@   systemclientsqlitedirectory_size_before_vacuumprogresscollectionstaskcollection_name
collectioner9   directory_size_after_vacuum	size_diffs                    r:   rY   rY   a   s    G 77>>$v-HIJjja  77>>TF/23dV#NO	
 jja   	Q 	)*jja  zH!H!%HX&F
LLN'F__X&F#5d#; MMO	$QR=>
 
--/  !5S=M N	% 97 $/#22?C
  z}} =a0 $/   !GH	%MMO]]F  !6=f%
 	c*A
D #5T":,/JJIMM
OPZ[dPeOf  gJ  LU  X[  L[  ^z  Lz  |  J@  @P  	Q'  	%MMHLM**!$$	%  	%MMKA3OP**!$$	%9
 
sU   <-L,*A&J6L,#?K1"L,6	K.?*K))K..L,1	L):*L$$L))L,,L5c                  .    t        j                  d       y)zOpens help url in your browserzhttps://discord.gg/MMeYNTmh3xN
webbrowseropenr-   r;   r:   r   r      s     OO34r;   c                  .    t        j                  d       y)zOpens docs url in your browserzhttps://docs.trychroma.comNri   r-   r;   r:   docsrm      s     OO01r;   __main__)r   N)-typingr   rich.consoler   rich.progressr   r   r   typer.rich_utilsrI   typing_extensionsr   r5   r0   rj   chromadb.api.clientr	   chromadb.cli.utilsr
   r   r   chromadb.configr   r   chromadb.db.impl.sqliter   chromadb.ingest.impl.utilsr   chromadb.segmentr   Typerr)   	utils_app	add_typerr/   commandOptionstrintboolr6   rY   r   rm   __name__r-   r;   r:   <module>r      s      = =  '   	  & P P , , S +ekkmEKK#>?	 ig &	  B
 	 	T(HIe,ERVW6
6 |u||)TUU	6 |u||)DEE6 6 6 
6 6r 3 %,,u+RS	T
T 	T
 
T Tn 5 5 2 2 zE r;   