
    i                    n   d dl mZ d dlZd dlmZ  G d de      Z G d de      Z G d d	e      Z G d
 de      Z	 G d de      Z
 G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d  d!e      Zy)"    )annotationsN)Literalc                  T     e Zd ZU dZded<   ded<   ded<   	 	 	 	 	 	 	 	 d	 fdZ xZS )
APIStatusErrorz<Raised when an API response has a status code of 4xx or 5xx.httpx.Responseresponseintstatus_code
str | None
request_idc                   t         |   ||j                  |       || _        |j                  | _        |j
                  j                  d      | _        y )Nbodyzx-request-id)super__init__requestr   r
   headersgetr   )selfmessager   r   	__class__s       O/mnt/e/genesis-system/.venv/lib/python3.12/site-packages/lightrag/exceptions.pyr   zAPIStatusError.__init__   sL     	("2"2> #//"**..~>    )r   strr   r   r   zobject | NonereturnNone)__name__
__module____qualname____doc____annotations__r   __classcell__r   s   @r   r   r      sB    F??)7??L?	? ?r   r   c                  0     e Zd Zdd	 	 	 	 	 d fdZ xZS )APIConnectionErrorzConnection error.)r   c               *    t         |   ||d        y )Nr   r   r   )r   r   r   r   s      r   r   zAPIConnectionError.__init__   s     	'5r   )r   r   r   httpx.Requestr   r   r   r   r   r   r"   r#   s   @r   r%   r%      s(     366>K6	6 6r   r%   c                      e Zd ZU dZded<   y)BadRequestErrori  zLiteral[400]r
   Nr   r   r   r
   r!    r   r   r+   r+           #K#r   r+   c                      e Zd ZU dZded<   y)AuthenticationErrori  zLiteral[401]r
   Nr,   r-   r   r   r0   r0   "   r.   r   r0   c                      e Zd ZU dZded<   y)PermissionDeniedErrori  zLiteral[403]r
   Nr,   r-   r   r   r2   r2   &   r.   r   r2   c                      e Zd ZU dZded<   y)NotFoundErrori  zLiteral[404]r
   Nr,   r-   r   r   r4   r4   *   r.   r   r4   c                      e Zd ZU dZded<   y)ConflictErrori  zLiteral[409]r
   Nr,   r-   r   r   r6   r6   .   r.   r   r6   c                      e Zd ZU dZded<   y)UnprocessableEntityErrori  zLiteral[422]r
   Nr,   r-   r   r   r8   r8   2   r.   r   r8   c                      e Zd ZU dZded<   y)RateLimitErrori  zLiteral[429]r
   Nr,   r-   r   r   r:   r:   6   r.   r   r:   c                        e Zd Zd fdZ xZS )APITimeoutErrorc                (    t         |   d|       y )NzRequest timed out.)r   r   r'   )r   r   r   s     r   r   zAPITimeoutError.__init__;   s    !5wGr   )r   r(   r   r   r)   r#   s   @r   r<   r<   :   s    H Hr   r<   c                  &     e Zd ZdZdd fdZ xZS )StorageNotInitializedErrorzCRaised when storage operations are attempted before initialization.c                *    t         |   | d       y )Nz not initialized. Please ensure proper initialization:

  rag = LightRAG(...)
  await rag.initialize_storages()  # Required - auto-initializes pipeline_status

See: https://github.com/HKUDS/LightRAG#important-initialization-requirementsr'   )r   storage_typer   s     r   r   z#StorageNotInitializedError.__init__B   s!    n [ \	
r   )Storage)rA   r   r   r   r   r    r   r"   r#   s   @r   r?   r?   ?   s    M
 
r   r?   c                  &     e Zd ZdZdd fdZ xZS )PipelineNotInitializedErrorz>Raised when pipeline status is accessed before initialization.c                0    d| d}t         |   |       y )NzPipeline namespace 'a2  ' not found.

Pipeline status should be auto-initialized by initialize_storages().
If you see this error, please ensure:

  1. You called await rag.initialize_storages()
  2. For multi-workspace setups, each LightRAG instance was properly initialized

Standard initialization:
  rag = LightRAG(workspace='your_workspace')
  await rag.initialize_storages()  # Auto-initializes pipeline_status

If you need manual control (advanced):
  from lightrag.kg.shared_storage import initialize_pipeline_status
  await initialize_pipeline_status(workspace='your_workspace')r'   )r   	namespacemsgr   s      r   r   z$PipelineNotInitializedError.__init__P   s*    "9+ .M N 	" 	r   ) )rG   r   rC   r#   s   @r   rE   rE   M   s    H r   rE   c                  &     e Zd ZdZdd fdZ xZS )PipelineCancelledExceptionz=Raised when pipeline processing is cancelled by user request.c                2    t         |   |       || _        y Nr   r   r   r   r   r   s     r   r   z#PipelineCancelledException.__init__h       !r   )zUser cancelledr   r   rC   r#   s   @r   rK   rK   e   s    G r   rK   c                  6     e Zd ZdZ	 d	 	 	 	 	 	 	 d fdZ xZS )ChunkTokenLimitExceededErrorz7Raised when a chunk exceeds the configured token limit.c                    |r|j                         nd }|r|d d nd }|rd| dnd}d| d| d| }t        | 	  |       || _        || _        || _        y )NP   z Preview: ''rI   zChunk token length z exceeds chunk_token_size .)stripr   r   chunk_tokenschunk_token_limitchunk_preview)	r   rY   rZ   r[   previewtruncated_previewpreview_noter   r   s	           r   r   z%ChunkTokenLimitExceededError.__init__p   s     ,9-%%'d,3GCRL=N%6$7q9TV!,/IJ[I\\]n 	 	!(!2.r   rM   )rY   r	   rZ   r	   r[   r   r   r   rC   r#   s   @r   rS   rS   m   s;    A %)	// / "	/
 
/ /r   rS   c                  $     e Zd ZdZd fdZ xZS )DataMigrationErrorz>Raised when data migration from legacy collection/table fails.c                2    t         |   |       || _        y rM   rN   rO   s     r   r   zDataMigrationError.__init__   rP   r   rQ   rC   r#   s   @r   r`   r`      s    H r   r`   )
__future__r   httpxtypingr   	Exceptionr   r%   r+   r0   r2   r4   r6   r8   r:   r<   RuntimeErrorr?   KeyErrorrE   rK   
ValueErrorrS   r`   r-   r   r   <module>ri      s    "  ?Y ? 6 6$n $$. $$N $$N $$N $$~ $$^ $H( H

 
( 0 /: /, r   