| 
														
															@@ -3,7 +3,8 @@ from r2r import R2RClient 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 from app.libs.util import verify_jwt_expiration 
														 | 
														
														 | 
														
															 from app.libs.util import verify_jwt_expiration 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 from config.llm import tool_settings 
														 | 
														
														 | 
														
															 from config.llm import tool_settings 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-import nest_asyncio 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+# import nest_asyncio 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import asyncio 
														 | 
														
														 | 
														
															 import asyncio 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 # Apply nest_asyncio to allow nested event loops 
														 | 
														
														 | 
														
															 # Apply nest_asyncio to allow nested event loops 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -22,9 +23,8 @@ class R2R: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             return 
														 | 
														
														 | 
														
															             return 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         if not self.client: 
														 | 
														
														 | 
														
															         if not self.client: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             self.client = R2RClient(tool_settings.R2R_BASE_URL) 
														 | 
														
														 | 
														
															             self.client = R2RClient(tool_settings.R2R_BASE_URL) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            self.client.users.login( 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                tool_settings.R2R_USERNAME, tool_settings.R2R_PASSWORD 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            ) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        self.client.users.login(tool_settings.R2R_USERNAME, tool_settings.R2R_PASSWORD) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        print(self.client.access_token) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     def ingest_file(self, file_path: str, metadata: Optional[dict]): 
														 | 
														
														 | 
														
															     def ingest_file(self, file_path: str, metadata: Optional[dict]): 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         self._check_login() 
														 | 
														
														 | 
														
															         self._check_login() 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -47,7 +47,9 @@ class R2R: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     def _check_login(self): 
														 | 
														
														 | 
														
															     def _check_login(self): 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         if not self.auth_enabled: 
														 | 
														
														 | 
														
															         if not self.auth_enabled: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             return 
														 | 
														
														 | 
														
															             return 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        if verify_jwt_expiration(self.client.access_token): 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if not self.client.access_token and verify_jwt_expiration( 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            self.client.access_token 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        ): 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             return 
														 | 
														
														 | 
														
															             return 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         else: 
														 | 
														
														 | 
														
															         else: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             asyncio.create_task(self.init()) 
														 | 
														
														 | 
														
															             asyncio.create_task(self.init()) 
														 |