jack 1 week ago
parent
commit
7393dfb6d6
1 changed files with 10 additions and 14 deletions
  1. 10 14
      app/providers/r2r.py

+ 10 - 14
app/providers/r2r.py

@@ -25,17 +25,15 @@ class R2R:
         if not self.auth_enabled:
             return
         # if not self.client_sync:
-        self.client_sync = R2RClient(tool_settings.R2R_BASE_URL)
-        self.client_sync.users.login(
-            tool_settings.R2R_USERNAME, tool_settings.R2R_PASSWORD
-        )
+        client_sync = R2RClient(tool_settings.R2R_BASE_URL)
+        client_sync.users.login(tool_settings.R2R_USERNAME, tool_settings.R2R_PASSWORD)
         print(
             "1111111111111111111111111111111122222vvdgdfdf" + tool_settings.R2R_USERNAME
         )
         # print(tool_settings.R2R_USERNAME)
         # print(tool_settings.R2R_PASSWORD)
-        print(self.client_sync)
-        return self.client_sync
+        print(client_sync)
+        return client_sync
 
     async def init(self):
         if not self.auth_enabled:
@@ -46,12 +44,10 @@ class R2R:
         )
         print(tool_settings.R2R_USERNAME)
         print(tool_settings.R2R_PASSWORD)
-        self.client = R2RAsyncClient(tool_settings.R2R_BASE_URL)
-        await self.client.users.login(
-            tool_settings.R2R_USERNAME, tool_settings.R2R_PASSWORD
-        )
-        print(self.client.access_token)
-        return self.client
+        client = R2RAsyncClient(tool_settings.R2R_BASE_URL)
+        await client.users.login(tool_settings.R2R_USERNAME, tool_settings.R2R_PASSWORD)
+        print(client.access_token)
+        return client
 
     async def ingest_file(self, file_path: str, metadata: Optional[dict]):
         client = await self._check_login()
@@ -77,7 +73,7 @@ class R2R:
         )
         search_response = client.retrieval.search(
             query=query,
-            search_mode="basic",
+            # search_mode="basic",
             search_settings={
                 "filters": filters,
                 "limit": tool_settings.R2R_SEARCH_LIMIT,
@@ -140,7 +136,7 @@ class R2R:
 
     def _check_login_sync(self):
         print("access_tokenaccess_tokenaccess_tokenaccess_token")
-        print(self.client_sync)
+        # print(client_sync)
         if not self.auth_enabled:
             return
         # try: