+
    ih                        R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt	^ RI
Ht ^ RIt^ RIHt ]! 4        ^ RIHt ^ RIHt ^ RIHt ^ RIt^ RIHt ]! R4       ]P2                  P5                  ]P2                  P7                  ]4      4      t]P2                  P5                  ]4      t]P2                  P?                  ^ ]4       ^ R	I H!t! ]! R
RRR7      t"^ RI#t#^ RI$t$^ RI%t%R]PL                  R&   R]PL                  R&   ]$PN                  ! R](R7       ]%PR                  ! R4      PU                  ]%PV                  4       Rt,]! R4       ]! R],R7      t-]! R4       ]! R4       / t.. s/R t0^ RI1t1]1Pd                  ! ]0RR7      Pg                  4        R t4]1Pd                  ! ]4RR7      Pg                  4        R R  lt5R! R" lt6 ! R# R$]4      t7R% t8R& R' lt9R( R) lt:R* R+ lt;]"Py                  R,4      R- R. l4       t=R# )/a  
Backend API for Dr. Robert Young's semantic search Q&A system

This module provides a FastAPI application that:
1. Performs semantic search on scraped blog articles
2. Generates contextual answers using local LLM
3. Provides performance timing information
N)deque)load_dotenv)FastAPI)StreamingResponse)	BaseModel)SentenceTransformerz&[INFO] Using only Ollama (local mode).)get_connectionz$Dr. Robert Young Semantic Search APIzBSemantic search and Q&A system for Dr. Robert Young's blog contentz1.0.0)titledescriptionversionfalseTOKENIZERS_PARALLELISM1HF_HUB_DISABLE_TELEMETRYignore)categorysentence_transformerscpuz5[MODEL] Loading embedding model (from local cache)...zall-MiniLM-L6-v2)devicez[MODEL] Embedding model ready!z[LLM] Using Ollama (Local mode)c                 n    \        R4       \        4       p V P                  RR7      pVP                  R4       VP	                  4       pVP                  4        V P                  4        . pV Fl  p \        P                  ! \        P                  ! VR,          4      4      pVP                  RVR,          RVR,          RVR,          R	VR	,          RV/4       Kn  	  Vs\        R
\        \        4       R24       R#   \         d     K  i ; i  \         d   p\        RT 24        Rp?R# Rp?ii ; i)z:Load all article embeddings from DB into memory at startupz2
[CACHE] Loading article embeddings into memory...T
dictionaryzDSELECT id, title, url, content, embedding FROM dr_young_all_articles	embeddingidr	   urlcontentz[CACHE] Loaded z articles into memory!z[CACHE] Failed to load cache: N)printr   cursorexecutefetchallclosenparrayastliteral_evalappend	Exceptionarticle_cachelen)conncurrows	new_cacherembes          KC:\Users\Aakash\Desktop\Scrapping\Chatbot-Dr.Young O Robert\backend\main.pyload_article_cacher1   M   s   4CDkkTk*Z[||~		

	A
hhs//+?@  !D'QwZ1U8q|"   "M 233IJK    4.qc2334s=   A/D 2A(C>"D >D	D DD D4D//D4T)targetdaemonc            	     ,    \        R4       \        P                  ! RRRRRRR/^<R	7      p V P                  ^8X  d   \        R
4       R# \        RV P                   24       R#   \         d%   p\        RT 24       \        R4        Rp?R# Rp?ii ; i)z
Warm up the Ollama model by making a simple request
This pre-loads the model into memory to avoid delays on first user request
z
[OLLAMA] Warming up model...#http://localhost:11434/api/generatemodelllama3.2:latestpromptHellostreamT)jsontimeoutz&[OLLAMA] Model warmed up successfully!z![OLLAMA] Warm-up returned status z[OLLAMA] Warm-up failed: zB[OLLAMA] Model will load on first request (may take 10-15 seconds)N)r   requestspoststatus_coder&   )responser/   s     r0   warm_up_ollama_modelrA   p   s    
T./==1*'$
 
 3&:;5h6J6J5KLM T)!-.RSSTs   AA$ 
A$ $B/BBc                $    V ^8  d   QhR\         /# )   conversation_idstr)formats   "r0   __annotate__rH      s     0 0c 0    c                X    V \         9  d   \        ^R7      \         V &   \         V ,          # )z%Get conversation history for given ID)maxlen)conversation_memoryr   )rD   s   &r0   get_conversation_historyrM      s%    11/4AO,//rI   c                <    V ^8  d   QhR\         R\         R\         /# )rC   rD   questionanswerrE   )rG   s   "r0   rH   rH      s!     4 4 4 4S 4rI   c           	        \        V 4      pVP                  RVRVR\        P                  ! 4       /4       \        RV  R24       \        RVR,           R24       \        R	VR,           R24       \        R
\	        V4       24       R# )z'Add interaction to conversation historyrO   rP   	timestampz[SAVED] Session [z]:z   Question: :N<   Nz...z   Answer: z   Total interactions: N)rM   r%   timer   r(   )rD   rO   rP   historys   &&& r0   add_to_conversation_historyrV      s    &7GNNH&TYY[  
o.b
12	M(3-
,-	Ks}C
()	#CL>
23rI   c                   4   a  ] tR t^t o RtRtV 3R ltRtV tR# )ChatRequestz
Request model for chat endpoint

Attributes:
    question (str): The user's question to be answered
    conversation_id (str): Optional conversation identifier to maintain context
defaultc                2   < V ^8  d   Qh/ S[ ;R&   S[ ;R&   # )rC   rO   rD   rE   )rG   __classdict__s   "r0   rH   ChatRequest.__annotate__   s      M  $ rI    N)	__name__
__module____qualname____firstlineno____doc__rD   __annotate_func____static_attributes____classdictcell__)r[   s   @r0   rX   rX      s      %O  rI   rX   c                    \         P                  ! W4      \         P                  P                  V 4      \         P                  P                  V4      ,          ,          # )z
Calculate cosine similarity between two vectors

Args:
    a (numpy.ndarray): First vector
    b (numpy.ndarray): Second vector
    
Returns:
    float: Cosine similarity score between 0 and 1
)r!   dotlinalgnorm)abs   &&r0   cosinerl      s6     66!<299>>!,ryy~~a/@@AArI   c                0    V ^8  d   QhR\         R\         /# )rC   textreturnrE   )rG   s   "r0   rH   rH      s        rI   c                    \         P                  ! RRV 4      p \         P                  ! RRV 4      p \         P                  ! RRV \         P                  \         P                  ,          R7      p V P	                  RR4      p V P                  4       # )	z
Clean and preprocess context text for LLM consumption

This function removes unwanted formatting elements that might confuse the LLM.

Args:
    text (str): Raw text content to be cleaned
    
Returns:
    str: Cleaned text ready for LLM processing
z\n?\s*\d+[\.]\)\s* u   [•\-–▪]z\n\s*References?\s*:\s*$ )flags   ZeolitéZeolite)resub	MULTILINE
IGNORECASEreplacestrip)rn   s   &r0   clean_contextr|      sn     66'd3D 66"C.D 66-r4r||bmm?[\D <<
I.D::<rI   c                $    V ^8  d   QhR\         /# rC   r8   rE   )rG   s   "r0   rH   rH      s     S< S<s S<rI   c              #    "    \         P                  ! RRRRV RRRRR	R
RRRRR//RRR7      ;_uu_ 4       pVP                  ^8w  dY   \        VR4      '       d   VP                  MRp\        RVP                   RV 24       RVP                   R2x   RRR4       R# RpVP                  4        F  pV'       g   K   \        P                  ! VP                  R4      4      pRV9   d/   VR,          '       d    RpVR,          P                  RR4      pVx  VP                  R4      '       d    MK  	  V'       g   R x  RRR4       R#   \        P                   d     K  \         d   pR\        T4       2x   Rp? KO  Rp?ii ; i  + '       g   i     R# ; i  \         P                  P                    d	    R!x   R# \         P                  P"                   d	    R"x   R# \         d_   p\        R#\%        T4      P&                   R\        T4       24       R$\%        T4      P&                   R%\        T4       2x   Rp?R# Rp?ii ; i5i)&a  
Call locally running LLM via Ollama with streaming capability

This function establishes a streaming connection to the Ollama service
and yields response chunks as they become available, enabling real-time
response delivery to the client.

Args:
    prompt (str): Formatted prompt including context and question

Yields:
    str: Response chunks from the LLM as they are generated

Raises:
    Exception: If connection to Ollama fails or streaming encounters errors
r5   r6   r7   r8   r:   Toptionstemperature皙?top_p?repeat_penalty333333?num_predict   ,  r;   r:   r<   rn   zNo error detailsz[OLLAMA ERROR] Status z: z$[LLM ERROR]: Ollama returned status z?. The model may be loading. Please wait a moment and try again.NFutf-8r@   rt   ru   donez[PARSING ERROR]: zT[LLM ERROR]: No response received. The model may still be loading. Please try again.zZ[LLM ERROR]: Cannot connect to Ollama service. Is it running? Start it with 'ollama serve'za[LLM ERROR]: Ollama request timed out. The model may be loading or the prompt may be too complex.z[OLLAMA EXCEPTION]: [LLM ERROR]: z - )r=   r>   r?   hasattrrn   r   
iter_linesr;   loadsdecoderz   getJSONDecodeErrorr&   rF   
exceptionsConnectionErrorTimeouttyper^   )r8   r-   
error_textreceived_responselinedatachunkr/   s   &       r0   call_llama2_streamr      sA    "B<]]1*&$!3S$c!3		
 
 
 }}#'.q&'9'9QVV?Q
.q}}oR
|LM<Q]]O  LK  L  L-
 
2 !& ::dkk'&:;D "T)d:.>.>,0) $Z 0 8 8Y O# xx'' ( '4 %llo
 
\ ++   -c!fX66c
 
 
r .. kjj&& rqq <$T!W%5%5$6bQABd1g../s3q6(;;;<s   I2F" A FF" I F :E;5E1F?FF" IF	"F%F	.F	/F	?FF	FF	F" IF" "#III%I*I-I6I7AI
IIIc                $    V ^8  d   QhR\         /# r~   rE   )rG   s   "r0   rH   rH   /  s     6) 6)c 6)rI   c              #    "    \         P                  ! RRRRV RRRRR	R
RRRRR//RRR7      ;_uu_ 4       pVP                  4        Fo  pV'       g   K  \        P                  ! VP                  R4      4      pRV9   d   VR,          P                  RR4      pVx  VP                  R4      '       g   Ko   M	  RRR4       R#   + '       g   i     R# ; i  \         d   pR\        T4       2x   Rp?R# Rp?ii ; i5i)a  
Call locally running LLM via Ollama with streaming capability for direct responses

This function establishes a streaming connection to the Ollama service
and yields response chunks as they become available.

Args:
    prompt (str): Formatted prompt including context and question

Yields:
    str: Response chunks from the LLM as they are generated

Raises:
    Exception: If connection to Ollama fails or streaming encounters errors
r5   r6   r7   r8   r:   Tr   r   r   r   r   r   r   r   r   r   r   r   r@   rt   ru   r   Nz
[LLM ERROR]: )
r=   r>   r   r;   r   r   rz   r   r&   rF   )r8   r-   r   r   r   r/   s   &     r0   call_llama2_stream_directr   /  s     &)]]1*&$!3S$c!3		
 
 
   zz$++g"67 % ,44ZKEK 88F## '%
 
 
 
D  )Ax((()sX   D2C A;C6C:C DC	C DC C>#C93D9C>>Dz/chatc                $    V ^8  d   QhR\         /# )rC   q)rX   )rG   s   "r0   rH   rH   j  s     w w+ wrI   c                4  a a&a'a(a)a*a+a,a-a.a/a0a1a2a3a4"   \         P                   ! 4       o3\        S P                  4      p\        RS P                   24       \        R\	        V4       R24       \         P                   ! 4       p\
        P                  S P                  RRR7      p\         P                   ! 4       V,
          o+\         P                   ! 4       p\        4       o&S&P                  RR7      o)\         P                   ! 4       V,
          o*. p\         P                   ! 4       pRp\         EF  p\        W8R	,          4      p	0 R
kRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkRkR kR!kR"kR#kR$kR%kR&kR'kR(kR)kR*kR+kR,kR-kR.kR/kR0kR1kR2kp
S P                  P                  4       P                  4        Uu. uF  qV
9  g   K  \	        V4      ^8  g   K  VNK!  	  ppV'       d   VR3,          P                  4       o4VP                  R44      ;'       g    R5R6,          P                  4       o'\        V43R7 lV 4       4      p\        V'3R8 lV 4       4      pV	\!        VR9,          R:4      ,          p	V	\!        VR;,          R<4      ,          p	W8  d   T	pV	R=8  g   EKz  VP#                  W34       EK  	  \%        VR> RR?7      p\'        4       p. pV Fh  w  ppVR3,          P)                  4       P                  4       pVV9  d%   VP+                  V4       VP#                  VV34       \	        V4      ^8X  g   Kh   M	  Tp\         P                   ! 4       V,
          o2\        R@VRA 24       V'       d=   \-        V^4       F+  w  pw  r\        RBV RCVR3,          RD,           REV	RA 24       K-  	  M\        RFS P                   RG24       V'       Eg|   S P                  P                  4       o0V'       g   \        RHS P                   RG24       RIo,EM$V'       Ed   V'       d
   VRu,          M/ pV'       d!   VP                  RJR54      P                  4       MR5pV'       d!   VP                  RKR54      P                  4       MR5pV RLV 2p\'        VP                  4       4      p\'        S0P                  4       4      p\	        VP/                  V4      4      p\	        VP1                  V4      4      pV^ 8  d
   VV,          M^ pVRM8  gk   \2        ;QJ d4    V03RN lVP                  4       RO,           4       F  '       g   K   RM)	  RPM%! V03RN lVP                  4       RO,           4       4      '       d   \        RQVRR RSS P                   RG24       \        RTVRD,           RUVRD,           RV24       VRW,           RXS P                   RY2o-\         P                   ! 4       o.V-V.V 3RZ lp\5        V! 4       R[R\7      # \        R]VRR RSS P                   RG24       \        R^VRD,           RUVRD,           RV24       RIo,V,3R_ lp\5        V! 4       R[R\7      # \         P                   ! 4       p. p . o1V F  w  p!pS1P#                  R3VR3,          R`VR`,          /4       S)P7                  RaVRb,          34       S)P9                  4       p"V"'       g   K]  \;        V"R4,          4      p#V P#                  V#4       K  	  \        RcRv 24       \        Rd\	        V 4       Re24       \-        V^4       FD  w  pw  r\        RfV RgVR3,           24       \        RhVR`,           24       \        RiV	RA 24       KF  	  \        Rv 4       RjP=                  V 4      p$\         P                   ! 4       V,
          o(\        Rk\	        V$4       Rl\	        V$Rm,          4       24       \        RnS P                   24       \        RcRw 24       \        Ro4       \        Rw 4       \        V$Rm,          4       \        Rw 4       \        Rp4       \        Rv 4       RqV$Rm,           RrS P                   Rs2o/\         P                   ! 4       o.V&V(V)V*V+V.V/V V1V2V33Rt lp%\5        V%! 4       R[R\7      # u upi 5i)xa  
Main chat endpoint that processes user questions with session-based memory

This endpoint performs semantic search on the blog database, maintains conversation
context, and generates contextual answers using a local LLM.

Args:
    q (ChatRequest): The user's question request with optional conversation ID
    
Returns:
    StreamingResponse: Streaming response containing answer and references
z[SESSION] CONVERSATION: z[HISTORY] LENGTH: z interactionsTr   )convert_to_numpyr   r   g        r   whathowwhyistherj   andoesdocanfromtoofinandorforthisthatitimemygiveexplainexampleabouttellmeanreallyhelpneedusingafterlongtermthesethosethemtheirsuchr	   r   rr   :Ni  Nc              3   8   <"   T F  qS9   g   K  ^x  K  	  R# 5i   Nr]   ).0wtitle_lowers   & r0   	<genexpr>chat.<locals>.<genexpr>  s     P+;aK?O+;   
c              3   8   <"   T F  qS9   g   K  ^x  K  	  R# 5ir   r]   )r   r   content_lowers   & r0   r   r     s     !T-=mAS!!-=r   g?g333333?g{Gz?r   g      ?c                     V ^ ,          # )    r]   )xs   &r0   <lambda>chat.<locals>.<lambda>  s    !A$rI   )keyreversez[SEARCH] Highest score found: z.3fz[SEARCH] Match z: ':N2   Nz' score=z#[SEARCH] No match above 0.25 for: ''z?[CASE 4] TRIGGERED: No DB match + No conversation history for 'a#  I don't have reliable information about this specific topic in the available content. Could you please provide more details or rephrase your question? Alternatively, you might want to ask about related topics like general health principles, wellness practices, or preventive care approaches.rO   rP   rq   g333333?c              3   ,   <"   T F	  qS9   x  K  	  R # 5i)Nr]   )r   wordquestion_lowers   & r0   r   r     s     ,nPm^-CPms   :N
   NFz4[CASE 3] TRIGGERED: No DB match + Continuing topic (.2fz similarity) for 'z   Matching against: Question='z...' Answer='z...':Ni  Nz

Q: z
A:c               3     <"   R p  \         pV! S4       F=  pVP                  4       '       g   K  W,          p Vx  \        P                  ! R4       K?  	  RP	                  V P                  4       4      p\        SP                  SP                  V4       \        P                  ! 4       S,
          p\        RVR R24       R#   \         d   pR\        T4       2x   Rp?R# Rp?ii ; i5i)rr   {Gz?rq   z[TIMING] CASE 3 LLM: r   sr   N)r   r{   rT   sleepjoinsplitrV   rD   rO   r   r&   rF   )	full_answerllm_functionr   clean_answerllm_timer/   
llm_prompt	llm_startr   s	         r0   stream_case3_response#chat.<locals>.stream_case3_response  s     "$K7'@%1*%=E${{}} + 4&+ $

4 0	 &> (+xx0A0A0C'D3A4E4EqzzS_`#'99;#: 5hs^1EF$ 7 -c!fX6667s4   C-$C BC C-C*C%C-%C**C-z
text/plain)
media_typez3[CASE 4] TRIGGERED: No DB match + Different topic (z   Context: Question='c               3      <"   SP                  4       p \        V 4       F>  w  rY!\        V 4      ^,
          8  d   RMR,           x  \        P                  ! R4       K@  	  R# 5i)r   rq   rr   r   N)r   	enumerater(   rT   r   )wordsr   r   general_answers      r0   stream_general_response%chat.<locals>.stream_general_response  sK     "((*E$U+Ua%7cR@@

4  ,s   A A#r   z7SELECT content FROM dr_young_all_articles WHERE id = %sr   
z
[CONTEXT] z articles matched:z  [z	] Title: z      URL: z      Score: z

u'   
[CONTEXT → MODEL] Total Characters: z | Sent to LLM: :Nip  Nz[QUESTION] z[FULL CONTEXT FROM DB]:z[END CONTEXT]a`  <|system|>
You are a strict Q&A assistant for Dr. Robert O. Young's alkaline lifestyle research.

RULES:
1. ONLY use information from the CONTEXT below. Do NOT add outside knowledge.
2. If context lacks the answer, say: "I don't have enough information based on the available articles."
3. Do NOT invent, guess, or fabricate any facts not in the context.
4. Start your answer directly. No preambles like "Sure!", "Based on the context..." etc.
5. Use professional scientific tone. Be concise and accurate.
6. Use numbered lists (1.) or bullet points (-). Each item on its own line.
7. Always spell "Zeolite" (no accents) and "pH" (lowercase p, uppercase H).
8. CRITICAL: When the context labels something as "FALSE" or a "myth", it means that claim is WRONG. Do NOT present false/myth claims as facts. Instead explain why they are wrong according to the context.
9. Dr. Young PROMOTES the alkaline lifestyle. All answers should reflect his pro-alkaline position as stated in the context.
10. Do NOT recommend fruits, dairy, sugar, or acidic foods as healthy unless the context explicitly says so.
</s>
<|user|>
CONTEXT:
z

QUESTION: z
</s>
<|assistant|>c            	   3     <"   R p  \         pV! S4       FO  pVP                  4       '       g   K  VP                  RR4      pW,          p Vx  \        P                  ! R4       KQ  	  . p\        4       pS FR  pVR,          P                  4       P                  4       pWd9  g   K0  VP                  V4       VP                  V4       KT  	  V'       dX   Rx  V F#  pVR,          '       g   K  RVR,           R2x  K%  	  R	x  \        V^4       F  w  ruV R
VR,           R2x  K  	  RP                  V P                  4       4      p\        SP                  SP                  V4       \        P                  ! 4       S,
          p	\        P                  ! 4       S,
          p
\        R4       \        RSR RSR RSR R24       \        RSR RV	R RV
R R24        SP%                  4        SP%                  4        R#   \          d   pR\#        T4       2x   Rp?LCRp?ii ; i    R# ; i   SP%                  4        SP%                  4        i     i ; i; i5i)rr   rt   ru   r   r	   z

See here for more info:
r   z- r   z
References:
z. rq   z	[TIMING]:zEmbedding: r   zs | DB: zs | Search: r   z	Context: z	s | LLM: zs | Total: r   N)r   r{   rz   rT   r   setlowerr%   addr   r   r   rV   rD   rO   r   r&   rF   r    )r   r   r   unique_referencesseen_titlesreftitle_cleanr   r   r   
total_timer/   r)   context_timer*   db_time
embed_timer   r8   r   
referencessearch_time
start_times               r0   stream_responsechat.<locals>.stream_responseh  s    /	-L%f-;;==!MM*i@E(KKJJt$ . !#%K!!'l00288:1%,,S1OOK0	 " !55,C5zz "3u:,b11 - (''(91=FACr#g,r22 > 88K$5$5$78L'(9(91::|Tyy{Y.Hz1J+K
3/x}LQ\]`PaabcdIl3/y#kR\]`Qaabcd		

  	+!#a&**	+			

s}   I$H A1H &-H H .C0H  H) ?IH&H!H1 !H&&H1 )H.+I1I3 IIIIIz<============================================================u   ────────────────────────────────────────────────────────────)rT   rM   rD   r   r(   embed_modelencoderO   r   r   r'   rl   r   r   r   summinr%   sortedr   r{   r   r   intersectionunionanyr   r   fetchoner|   r   )5r   rU   embed_start	query_embdb_startscoredsearch_starthighest_scoreartscore
skip_wordsr   meaningful_wordstitle_matchescontent_matchesr  unique_scoredr   	title_keyr   last_interactionlast_questionlast_answercombined_contextconversation_keywordscurrent_keywordsoverlaptotal_uniquesimilarity_ratior   r   context_startcontext_parts_content_rowcleanedcontextr  r)   r   r  r*   r  r  r   r   r   r8   r   r  r	  r
  r   s5   f                                     @@@@@@@@@@@@@@@r0   chatr4  i  ss	     J 'q'8'89G 
$Q%6%6$7
89	s7|nM
:; ))+K""	

 # I
 {*J yy{HD
+++
&CiikH$G F 99;LM}yk"23 Lf  Le  LU  LD  L%  L  Ld  LF  LD  LRW  LY_  Lae  Lgk  Lmq  Lsx  Lz~  L  AF  L  HN  L  PV  L  X\  L  ^a  L  cg  L  im  L  ou  L  w@  L  BK  L  MT  L  V\  L  ^d  L  fn  L  pv  L  x~  L  @G  L  IP  L  RX  L  Z`  L  bi  L  kr  L  tz  L  |C  L  EK  L
'(zz'7'7'9'?'?'Ah'A!jEXA]`ab]cfg]gAA'Ahg,,,.K WWY/552u=CCEM  P+;PPM!!T-=!TTO S-t44ES4/66E !M 4<MM5,'7 < F=F%KM3L&&(..0	K'OOI&  !S*}"  F))+,K 
*=*=
>?(3OA|OA3c#g,s*;)<HU3KPQ  4 	3AJJ<qAB 6))+ STUT^T^S__`abE  W /6wr{2L\,00R@FFHbdMHX*..x<BBD^`K #0+?$'(8(>(>(@$A!">#7#7#9: /<<=MNOG4::;KLML9E9Iw5q  #%,nP`PfPfPhilPm,n,nP`PfPfPhilPm,n)n)nLM]^aLbbtuvuu  uA  AB  C  D7c8J7K=YdehYiXjjnop #.d"3!4 5JJ< 
 !IIK	7, ))>)@\ZZ KL\]`Kaastut~t~s  @A  B  C.}S/A.B-P[\_P`OaaefgI 	! !!8!:|TT IIKMMJ3S\3u:
 	
 	MPSTXPY|\lln;#K	$:;G  )  
Bvh-	Js=)**<
=>$VQ/<EA3iG~./CJ<()eC[)* 0 
VH kk-(G99;.L 
4S\NBRSVW^_dWeSfRg
hi	K

|
$%	Bxj/	#%	XJ	'%.	XJ	M	VH" 	  ::, 'F. 		I4 4l  E isr   F.b bbb%8bBb&BbBb!b;%b!b)b<)b&B2b)b2b8EbGb)>rb   sysosrT   rv   r#   r;   
subprocessnumpyr!   collectionsr   asynciodotenvr   fastapir   fastapi.responsesr   pydanticr   r=   r   r   r   pathdirnameabspath__file__current_dirproject_rootinsertdatabase.dbr   apptorchwarningsloggingenvironfilterwarningsFutureWarning	getLoggersetLevelERRORr   r  rL   r'   r1   	threadingThreadstartrA   rM   rV   rX   rl   r|   r   r   r>   r4  r]   rI   r0   <module>rT     s    	  	 
         /   5 . / ggoobggooh78ww{+ <   & 
0T   '.

# $),

% &   = 9   ) * 3 3GMM B	 = >! & ' ' (   4<  	  *4 8 > > @T4 
  ,T : @ @ B04 	%) 	%B:S<l6)t 'w wrI   