ragflow-cli 0.26.2__tar.gz → 0.26.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ragflow-cli
3
- Version: 0.26.2
3
+ Version: 0.26.4
4
4
  Summary: Admin Service's client of [RAGFlow](https://github.com/infiniflow/ragflow). The Admin Service provides user management and system monitoring.
5
5
  Author-email: Lynn <lynn_inf@hotmail.com>
6
6
  License: Apache License, Version 2.0
@@ -42,7 +42,7 @@ It consists of a server-side Service and a command-line client (CLI), both imple
42
42
  ```bash
43
43
  python admin/server/admin_server.py
44
44
  ```
45
- The service will start and listen for incoming connections from the CLI on the configured port.
45
+ The service will start and listen for incoming connections from the CLI on the configured port.
46
46
 
47
47
  #### Using docker image
48
48
 
@@ -62,7 +62,7 @@ It consists of a server-side Service and a command-line client (CLI), both imple
62
62
  1. Ensure the Admin Service is running.
63
63
  2. Install ragflow-cli.
64
64
  ```bash
65
- pip install ragflow-cli==0.26.2
65
+ pip install ragflow-cli==0.26.4
66
66
  ```
67
67
  3. Launch the CLI client:
68
68
  ```bash
@@ -72,9 +72,9 @@ It consists of a server-side Service and a command-line client (CLI), both imple
72
72
  The default password is admin.
73
73
 
74
74
  **Parameters:**
75
-
75
+
76
76
  - -h: RAGFlow admin server host address
77
-
77
+
78
78
  - -p: RAGFlow admin server port
79
79
 
80
80
 
@@ -28,7 +28,7 @@ It consists of a server-side Service and a command-line client (CLI), both imple
28
28
  ```bash
29
29
  python admin/server/admin_server.py
30
30
  ```
31
- The service will start and listen for incoming connections from the CLI on the configured port.
31
+ The service will start and listen for incoming connections from the CLI on the configured port.
32
32
 
33
33
  #### Using docker image
34
34
 
@@ -48,7 +48,7 @@ It consists of a server-side Service and a command-line client (CLI), both imple
48
48
  1. Ensure the Admin Service is running.
49
49
  2. Install ragflow-cli.
50
50
  ```bash
51
- pip install ragflow-cli==0.26.2
51
+ pip install ragflow-cli==0.26.4
52
52
  ```
53
53
  3. Launch the CLI client:
54
54
  ```bash
@@ -58,9 +58,9 @@ It consists of a server-side Service and a command-line client (CLI), both imple
58
58
  The default password is admin.
59
59
 
60
60
  **Parameters:**
61
-
61
+
62
62
  - -h: RAGFlow admin server host address
63
-
63
+
64
64
  - -p: RAGFlow admin server port
65
65
 
66
66
 
@@ -25,14 +25,14 @@ import requests
25
25
 
26
26
  class HttpClient:
27
27
  def __init__(
28
- self,
29
- host: str = "127.0.0.1",
30
- port: int = 9381,
31
- api_version: str = "v1",
32
- api_key: Optional[str] = None,
33
- connect_timeout: float = 5.0,
34
- read_timeout: float = 60.0,
35
- verify_ssl: bool = False,
28
+ self,
29
+ host: str = "127.0.0.1",
30
+ port: int = 9381,
31
+ api_version: str = "v1",
32
+ api_key: Optional[str] = None,
33
+ connect_timeout: float = 5.0,
34
+ read_timeout: float = 60.0,
35
+ verify_ssl: bool = False,
36
36
  ) -> None:
37
37
  self.host = host
38
38
  self.port = port
@@ -71,19 +71,19 @@ class HttpClient:
71
71
  return headers
72
72
 
73
73
  def request(
74
- self,
75
- method: str,
76
- path: str,
77
- *,
78
- use_api_base: bool = True,
79
- auth_kind: Optional[str] = "api",
80
- headers: Optional[Dict[str, str]] = None,
81
- json_body: Optional[Dict[str, Any]] = None,
82
- data: Any = None,
83
- files: Any = None,
84
- params: Optional[Dict[str, Any]] = None,
85
- stream: bool = False,
86
- iterations: int = 1,
74
+ self,
75
+ method: str,
76
+ path: str,
77
+ *,
78
+ use_api_base: bool = True,
79
+ auth_kind: Optional[str] = "api",
80
+ headers: Optional[Dict[str, str]] = None,
81
+ json_body: Optional[Dict[str, Any]] = None,
82
+ data: Any = None,
83
+ files: Any = None,
84
+ params: Optional[Dict[str, Any]] = None,
85
+ stream: bool = False,
86
+ iterations: int = 1,
87
87
  ) -> requests.Response | dict:
88
88
  url = self.build_url(path, use_api_base=use_api_base)
89
89
  merged_headers = self._headers(auth_kind, headers)
@@ -144,18 +144,18 @@ class HttpClient:
144
144
  # )
145
145
 
146
146
  def request_json(
147
- self,
148
- method: str,
149
- path: str,
150
- *,
151
- use_api_base: bool = True,
152
- auth_kind: Optional[str] = "api",
153
- headers: Optional[Dict[str, str]] = None,
154
- json_body: Optional[Dict[str, Any]] = None,
155
- data: Any = None,
156
- files: Any = None,
157
- params: Optional[Dict[str, Any]] = None,
158
- stream: bool = False,
147
+ self,
148
+ method: str,
149
+ path: str,
150
+ *,
151
+ use_api_base: bool = True,
152
+ auth_kind: Optional[str] = "api",
153
+ headers: Optional[Dict[str, str]] = None,
154
+ json_body: Optional[Dict[str, Any]] = None,
155
+ data: Any = None,
156
+ files: Any = None,
157
+ params: Optional[Dict[str, Any]] = None,
158
+ stream: bool = False,
159
159
  ) -> Dict[str, Any]:
160
160
  response = self.request(
161
161
  method,
@@ -336,8 +336,8 @@ reset_default_asr: RESET DEFAULT ASR ";"
336
336
  reset_default_tts: RESET DEFAULT TTS ";"
337
337
 
338
338
  list_user_datasets: LIST DATASETS ";"
339
- create_user_dataset_with_parser: CREATE DATASET quoted_string WITH EMBEDDING quoted_string PARSER quoted_string ";"
340
- create_user_dataset_with_pipeline: CREATE DATASET quoted_string WITH EMBEDDING quoted_string PIPELINE quoted_string ";"
339
+ create_user_dataset_with_parser: CREATE DATASET quoted_string WITH EMBEDDING quoted_string PARSER quoted_string ";"
340
+ create_user_dataset_with_pipeline: CREATE DATASET quoted_string WITH EMBEDDING quoted_string PIPELINE quoted_string ";"
341
341
  drop_user_dataset: DROP DATASET quoted_string ";"
342
342
  list_user_dataset_files: LIST FILES OF DATASET quoted_string ";"
343
343
  list_user_dataset_documents: LIST DOCUMENTS OF DATASET quoted_string ";"
@@ -640,15 +640,13 @@ class RAGFlowCLITransformer(Transformer):
640
640
  dataset_name = items[2].children[0].strip("'\"")
641
641
  embedding = items[5].children[0].strip("'\"")
642
642
  parser_type = items[7].children[0].strip("'\"")
643
- return {"type": "create_user_dataset", "dataset_name": dataset_name, "embedding": embedding,
644
- "parser_type": parser_type}
643
+ return {"type": "create_user_dataset", "dataset_name": dataset_name, "embedding": embedding, "parser_type": parser_type}
645
644
 
646
645
  def create_user_dataset_with_pipeline(self, items):
647
646
  dataset_name = items[2].children[0].strip("'\"")
648
647
  embedding = items[5].children[0].strip("'\"")
649
648
  pipeline = items[7].children[0].strip("'\"")
650
- return {"type": "create_user_dataset", "dataset_name": dataset_name, "embedding": embedding,
651
- "pipeline": pipeline}
649
+ return {"type": "create_user_dataset", "dataset_name": dataset_name, "embedding": embedding, "pipeline": pipeline}
652
650
 
653
651
  def drop_user_dataset(self, items):
654
652
  dataset_name = items[2].children[0].strip("'\"")
@@ -666,7 +664,7 @@ class RAGFlowCLITransformer(Transformer):
666
664
  dataset_names = []
667
665
  dataset_names.append(items[4].children[0].strip("'\""))
668
666
  for i in range(5, len(items)):
669
- if items[i] and hasattr(items[i], 'children') and items[i].children:
667
+ if items[i] and hasattr(items[i], "children") and items[i].children:
670
668
  dataset_names.append(items[i].children[0].strip("'\""))
671
669
  return {"type": "list_user_datasets_metadata", "dataset_names": dataset_names}
672
670
 
@@ -675,7 +673,7 @@ class RAGFlowCLITransformer(Transformer):
675
673
  doc_ids = []
676
674
  if len(items) > 6 and items[6] == "DOCUMENTS":
677
675
  for i in range(7, len(items)):
678
- if items[i] and hasattr(items[i], 'children') and items[i].children:
676
+ if items[i] and hasattr(items[i], "children") and items[i].children:
679
677
  doc_id = items[i].children[0].strip("'\"")
680
678
  doc_ids.append(doc_id)
681
679
  return {"type": "list_user_documents_metadata_summary", "dataset_name": dataset_name, "document_ids": doc_ids}
@@ -698,17 +696,17 @@ class RAGFlowCLITransformer(Transformer):
698
696
  dataset_name = None
699
697
  vector_size = None
700
698
  for i, item in enumerate(items):
701
- if hasattr(item, 'data') and item.data == 'quoted_string':
699
+ if hasattr(item, "data") and item.data == "quoted_string":
702
700
  dataset_name = item.children[0].strip("'\"")
703
- if hasattr(item, 'type') and item.type == 'NUMBER':
704
- if i > 0 and items[i-1].type == 'SIZE' and items[i-2].type == 'VECTOR':
701
+ if hasattr(item, "type") and item.type == "NUMBER":
702
+ if i > 0 and items[i - 1].type == "SIZE" and items[i - 2].type == "VECTOR":
705
703
  vector_size = int(item)
706
704
  return {"type": "create_dataset_table", "dataset_name": dataset_name, "vector_size": vector_size}
707
705
 
708
706
  def drop_dataset_table(self, items):
709
707
  dataset_name = None
710
708
  for item in items:
711
- if hasattr(item, 'data') and item.data == 'quoted_string':
709
+ if hasattr(item, "data") and item.data == "quoted_string":
712
710
  dataset_name = item.children[0].strip("'\"")
713
711
  return {"type": "drop_dataset_table", "dataset_name": dataset_name}
714
712
 
@@ -792,7 +790,7 @@ class RAGFlowCLITransformer(Transformer):
792
790
 
793
791
  def update_chunk(self, items):
794
792
  def get_quoted_value(item):
795
- if hasattr(item, 'children') and item.children:
793
+ if hasattr(item, "children") and item.children:
796
794
  return item.children[0].strip("'\"")
797
795
  return str(item).strip("'\"")
798
796
 
@@ -813,16 +811,16 @@ class RAGFlowCLITransformer(Transformer):
813
811
  for i in range(2, len(items)):
814
812
  item = items[i]
815
813
  # Check for FROM token to stop
816
- if hasattr(item, 'type') and item.type == 'FROM':
814
+ if hasattr(item, "type") and item.type == "FROM":
817
815
  break
818
- if hasattr(item, 'children') and item.children:
816
+ if hasattr(item, "children") and item.children:
819
817
  tag = item.children[0].strip("'\"")
820
818
  tags.append(tag)
821
819
  # Find dataset_name: quoted_string after DATASET
822
820
  dataset_name = None
823
821
  for i, item in enumerate(items):
824
822
  # Check if item is a DATASET token
825
- if hasattr(item, 'type') and item.type == 'DATASET':
823
+ if hasattr(item, "type") and item.type == "DATASET":
826
824
  # Next item should be quoted_string
827
825
  dataset_name = items[i + 1].children[0].strip("'\"")
828
826
  break
@@ -835,10 +833,10 @@ class RAGFlowCLITransformer(Transformer):
835
833
 
836
834
  # Check if it's "REMOVE ALL CHUNKS"
837
835
  for item in items:
838
- if hasattr(item, 'type') and item.type == 'ALL':
836
+ if hasattr(item, "type") and item.type == "ALL":
839
837
  # Find doc_id
840
838
  for j, inner_item in enumerate(items):
841
- if hasattr(inner_item, 'type') and inner_item.type == 'DOCUMENT':
839
+ if hasattr(inner_item, "type") and inner_item.type == "DOCUMENT":
842
840
  doc_id = items[j + 1].children[0].strip("'\"")
843
841
  return {"type": "remove_chunks", "doc_id": doc_id, "delete_all": True}
844
842
 
@@ -846,12 +844,12 @@ class RAGFlowCLITransformer(Transformer):
846
844
  chunk_ids = []
847
845
  doc_id = None
848
846
  for i, item in enumerate(items):
849
- if hasattr(item, 'type') and item.type == 'DOCUMENT':
847
+ if hasattr(item, "type") and item.type == "DOCUMENT":
850
848
  doc_id = items[i + 1].children[0].strip("'\"")
851
- elif hasattr(item, 'children') and item.children:
849
+ elif hasattr(item, "children") and item.children:
852
850
  val = item.children[0].strip("'\"")
853
851
  # Skip if it's "FROM" or "DOCUMENT"
854
- if val.upper() in ['FROM', 'DOCUMENT']:
852
+ if val.upper() in ["FROM", "DOCUMENT"]:
855
853
  continue
856
854
  chunk_ids.append(val)
857
855
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ragflow-cli"
3
- version = "0.26.2"
3
+ version = "0.26.4"
4
4
  description = "Admin Service's client of [RAGFlow](https://github.com/infiniflow/ragflow). The Admin Service provides user management and system monitoring. "
5
5
  authors = [{ name = "Lynn", email = "lynn_inf@hotmail.com" }]
6
6
  license = { text = "Apache License, Version 2.0" }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ragflow-cli
3
- Version: 0.26.2
3
+ Version: 0.26.4
4
4
  Summary: Admin Service's client of [RAGFlow](https://github.com/infiniflow/ragflow). The Admin Service provides user management and system monitoring.
5
5
  Author-email: Lynn <lynn_inf@hotmail.com>
6
6
  License: Apache License, Version 2.0
@@ -42,7 +42,7 @@ It consists of a server-side Service and a command-line client (CLI), both imple
42
42
  ```bash
43
43
  python admin/server/admin_server.py
44
44
  ```
45
- The service will start and listen for incoming connections from the CLI on the configured port.
45
+ The service will start and listen for incoming connections from the CLI on the configured port.
46
46
 
47
47
  #### Using docker image
48
48
 
@@ -62,7 +62,7 @@ It consists of a server-side Service and a command-line client (CLI), both imple
62
62
  1. Ensure the Admin Service is running.
63
63
  2. Install ragflow-cli.
64
64
  ```bash
65
- pip install ragflow-cli==0.26.2
65
+ pip install ragflow-cli==0.26.4
66
66
  ```
67
67
  3. Launch the CLI client:
68
68
  ```bash
@@ -72,9 +72,9 @@ It consists of a server-side Service and a command-line client (CLI), both imple
72
72
  The default password is admin.
73
73
 
74
74
  **Parameters:**
75
-
75
+
76
76
  - -h: RAGFlow admin server host address
77
-
77
+
78
78
  - -p: RAGFlow admin server port
79
79
 
80
80
 
@@ -36,6 +36,7 @@ from user import login_user
36
36
 
37
37
  warnings.filterwarnings("ignore", category=getpass.GetPassWarning)
38
38
 
39
+
39
40
  def encrypt(input_string):
40
41
  pub = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArq9XTUSeYr2+N1h3Afl/z8Dse/2yD0ZGrKwx+EEEcdsBLca9Ynmx3nIB5obmLlSfmskLpBo0UACBmB5rEjBp2Q2f3AG3Hjd4B+gNCG6BDaawuDlgANIhGnaTLrIqWrrcm4EMzJOnAOI1fgzJRsOOUEfaS318Eq9OVO3apEyCCt0lOQK6PuksduOjVxtltDav+guVAA068NrPYmRNabVKRNLJpL8w4D44sfth5RvZ3q9t+6RTArpEtc5sh5ChzvqPOzKGMXW83C95TxmXqpbK6olN4RevSfVjEAgCydH6HN6OhtOQEcnrU97r9H0iZOWwbw3pVrZiUkuRD1R56Wzs2wIDAQAB\n-----END PUBLIC KEY-----"
41
42
  pub_key = RSA.importKey(pub)
@@ -49,9 +50,6 @@ def encode_to_base64(input_string):
49
50
  return base64_encoded.decode("utf-8")
50
51
 
51
52
 
52
-
53
-
54
-
55
53
  class RAGFlowCLI(Cmd):
56
54
  def __init__(self):
57
55
  super().__init__()
@@ -240,9 +238,9 @@ class RAGFlowCLI(Cmd):
240
238
  print(r"""
241
239
  ____ ___ ______________ ________ ____
242
240
  / __ \/ | / ____/ ____/ /___ _ __ / ____/ / / _/
243
- / /_/ / /| |/ / __/ /_ / / __ \ | /| / / / / / / / /
244
- / _, _/ ___ / /_/ / __/ / / /_/ / |/ |/ / / /___/ /____/ /
245
- /_/ |_/_/ |_\____/_/ /_/\____/|__/|__/ \____/_____/___/
241
+ / /_/ / /| |/ / __/ /_ / / __ \ | /| / / / / / / / /
242
+ / _, _/ ___ / /_/ / __/ / / /_/ / |/ |/ / / /___/ /____/ /
243
+ /_/ |_/_/ |_\____/_/ /_/\____/|__/|__/ \____/_____/___/
246
244
  """)
247
245
  self.cmdloop()
248
246
 
@@ -254,15 +252,13 @@ class RAGFlowCLI(Cmd):
254
252
  result = self.parse_command(command)
255
253
  self.execute_command(result)
256
254
 
257
-
258
255
  def parse_connection_args(self, args: List[str]) -> Dict[str, Any]:
259
256
  parser = argparse.ArgumentParser(description="RAGFlow CLI Client", add_help=False)
260
257
  parser.add_argument("-h", "--host", default="127.0.0.1", help="Admin or RAGFlow service host")
261
258
  parser.add_argument("-p", "--port", type=int, default=9381, help="Admin or RAGFlow service port")
262
259
  parser.add_argument("-w", "--password", default="admin", type=str, help="Superuser password")
263
260
  parser.add_argument("-t", "--type", default="admin", type=str, help="CLI mode, admin or user")
264
- parser.add_argument("-u", "--username", default=None,
265
- help="Username (email). In admin mode defaults to admin@ragflow.io, in user mode required.")
261
+ parser.add_argument("-u", "--username", default=None, help="Username (email). In admin mode defaults to admin@ragflow.io, in user mode required.")
266
262
  parser.add_argument("command", nargs="?", help="Single command")
267
263
  try:
268
264
  parsed_args, remaining_args = parser.parse_known_args(args)
@@ -274,7 +270,7 @@ class RAGFlowCLI(Cmd):
274
270
 
275
271
  if remaining_args:
276
272
  if remaining_args[0] == "command":
277
- command_str = ' '.join(remaining_args[1:]) + ';'
273
+ command_str = " ".join(remaining_args[1:]) + ";"
278
274
  auth = True
279
275
  if remaining_args[1] == "register":
280
276
  auth = False
@@ -282,28 +278,14 @@ class RAGFlowCLI(Cmd):
282
278
  if username is None:
283
279
  print("Error: username (-u) is required in user mode")
284
280
  return {"error": "Username required"}
285
- return {
286
- "host": parsed_args.host,
287
- "port": parsed_args.port,
288
- "password": parsed_args.password,
289
- "type": parsed_args.type,
290
- "username": username,
291
- "command": command_str,
292
- "auth": auth
293
- }
281
+ return {"host": parsed_args.host, "port": parsed_args.port, "password": parsed_args.password, "type": parsed_args.type, "username": username, "command": command_str, "auth": auth}
294
282
  else:
295
283
  return {"error": "Invalid command"}
296
284
  else:
297
285
  auth = True
298
286
  if username is None:
299
287
  auth = False
300
- return {
301
- "host": parsed_args.host,
302
- "port": parsed_args.port,
303
- "type": parsed_args.type,
304
- "username": username,
305
- "auth": auth
306
- }
288
+ return {"host": parsed_args.host, "port": parsed_args.port, "type": parsed_args.type, "username": username, "auth": auth}
307
289
  except SystemExit:
308
290
  return {"error": "Invalid connection arguments"}
309
291
 
@@ -321,6 +303,7 @@ class RAGFlowCLI(Cmd):
321
303
  # print(f"Parsed command: {command_dict}")
322
304
  run_command(self.ragflow_client, command_dict)
323
305
 
306
+
324
307
  def main():
325
308
 
326
309
  cli = RAGFlowCLI()