ragflow-cli 0.26.0__tar.gz → 0.26.2__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.
- {ragflow_cli-0.26.0 → ragflow_cli-0.26.2}/PKG-INFO +3 -3
- {ragflow_cli-0.26.0 → ragflow_cli-0.26.2}/README.md +1 -1
- {ragflow_cli-0.26.0 → ragflow_cli-0.26.2}/pyproject.toml +2 -2
- {ragflow_cli-0.26.0 → ragflow_cli-0.26.2}/ragflow_cli.egg-info/PKG-INFO +3 -3
- {ragflow_cli-0.26.0 → ragflow_cli-0.26.2}/ragflow_client.py +116 -63
- {ragflow_cli-0.26.0 → ragflow_cli-0.26.2}/user.py +2 -2
- {ragflow_cli-0.26.0 → ragflow_cli-0.26.2}/http_client.py +0 -0
- {ragflow_cli-0.26.0 → ragflow_cli-0.26.2}/parser.py +0 -0
- {ragflow_cli-0.26.0 → ragflow_cli-0.26.2}/ragflow_cli.egg-info/SOURCES.txt +0 -0
- {ragflow_cli-0.26.0 → ragflow_cli-0.26.2}/ragflow_cli.egg-info/dependency_links.txt +0 -0
- {ragflow_cli-0.26.0 → ragflow_cli-0.26.2}/ragflow_cli.egg-info/entry_points.txt +0 -0
- {ragflow_cli-0.26.0 → ragflow_cli-0.26.2}/ragflow_cli.egg-info/requires.txt +0 -0
- {ragflow_cli-0.26.0 → ragflow_cli-0.26.2}/ragflow_cli.egg-info/top_level.txt +0 -0
- {ragflow_cli-0.26.0 → ragflow_cli-0.26.2}/ragflow_cli.py +0 -0
- {ragflow_cli-0.26.0 → ragflow_cli-0.26.2}/setup.cfg +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ragflow-cli
|
|
3
|
-
Version: 0.26.
|
|
3
|
+
Version: 0.26.2
|
|
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
|
|
7
|
-
Requires-Python: <3.
|
|
7
|
+
Requires-Python: <3.14,>=3.13
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
Requires-Dist: requests<3.0.0,>=2.30.0
|
|
10
10
|
Requires-Dist: beartype<1.0.0,>=0.20.0
|
|
@@ -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.
|
|
65
|
+
pip install ragflow-cli==0.26.2
|
|
66
66
|
```
|
|
67
67
|
3. Launch the CLI client:
|
|
68
68
|
```bash
|
|
@@ -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.
|
|
51
|
+
pip install ragflow-cli==0.26.2
|
|
52
52
|
```
|
|
53
53
|
3. Launch the CLI client:
|
|
54
54
|
```bash
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "ragflow-cli"
|
|
3
|
-
version = "0.26.
|
|
3
|
+
version = "0.26.2"
|
|
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" }
|
|
7
7
|
readme = "README.md"
|
|
8
|
-
requires-python = ">=3.
|
|
8
|
+
requires-python = ">=3.13,<3.14"
|
|
9
9
|
dependencies = [
|
|
10
10
|
"requests>=2.30.0,<3.0.0",
|
|
11
11
|
"beartype>=0.20.0,<1.0.0",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ragflow-cli
|
|
3
|
-
Version: 0.26.
|
|
3
|
+
Version: 0.26.2
|
|
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
|
|
7
|
-
Requires-Python: <3.
|
|
7
|
+
Requires-Python: <3.14,>=3.13
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
Requires-Dist: requests<3.0.0,>=2.30.0
|
|
10
10
|
Requires-Dist: beartype<1.0.0,>=0.20.0
|
|
@@ -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.
|
|
65
|
+
pip install ragflow-cli==0.26.2
|
|
66
66
|
```
|
|
67
67
|
3. Launch the CLI client:
|
|
68
68
|
```bash
|
|
@@ -56,7 +56,7 @@ class RAGFlowClient:
|
|
|
56
56
|
|
|
57
57
|
def login_user(self, command):
|
|
58
58
|
try:
|
|
59
|
-
response = self.http_client.request("GET", "/system/ping", use_api_base=
|
|
59
|
+
response = self.http_client.request("GET", "/system/ping", use_api_base=True, auth_kind="web")
|
|
60
60
|
if response.status_code == 200 and response.content == b"pong":
|
|
61
61
|
pass
|
|
62
62
|
else:
|
|
@@ -86,11 +86,11 @@ class RAGFlowClient:
|
|
|
86
86
|
def ping_server(self, command):
|
|
87
87
|
iterations = command.get("iterations", 1)
|
|
88
88
|
if iterations > 1:
|
|
89
|
-
response = self.http_client.request("GET", "/system/ping", use_api_base=
|
|
89
|
+
response = self.http_client.request("GET", "/system/ping", use_api_base=True, auth_kind="web",
|
|
90
90
|
iterations=iterations)
|
|
91
91
|
return response
|
|
92
92
|
else:
|
|
93
|
-
response = self.http_client.request("GET", "/system/ping", use_api_base=
|
|
93
|
+
response = self.http_client.request("GET", "/system/ping", use_api_base=True, auth_kind="web")
|
|
94
94
|
if response.status_code == 200 and response.content == b"pong":
|
|
95
95
|
print("Server is alive")
|
|
96
96
|
else:
|
|
@@ -106,8 +106,8 @@ class RAGFlowClient:
|
|
|
106
106
|
enc_password = encrypt_password(password)
|
|
107
107
|
print(f"Register user: {nickname}, email: {username}, password: ******")
|
|
108
108
|
payload = {"email": username, "nickname": nickname, "password": enc_password}
|
|
109
|
-
response = self.http_client.request(method="POST", path="/
|
|
110
|
-
json_body=payload, use_api_base=
|
|
109
|
+
response = self.http_client.request(method="POST", path="/users",
|
|
110
|
+
json_body=payload, use_api_base=True, auth_kind="web")
|
|
111
111
|
res_json = response.json()
|
|
112
112
|
if response.status_code == 200:
|
|
113
113
|
if res_json["code"] == 0:
|
|
@@ -727,45 +727,133 @@ class RAGFlowClient:
|
|
|
727
727
|
def create_model_provider(self, command):
|
|
728
728
|
if self.server_type != "user":
|
|
729
729
|
print("This command is only allowed in USER mode")
|
|
730
|
-
|
|
730
|
+
return
|
|
731
|
+
provider_name: str = command["provider_name"]
|
|
731
732
|
api_key: str = command["provider_key"]
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
print(f"
|
|
733
|
+
|
|
734
|
+
# Step 1: Add provider
|
|
735
|
+
provider_payload = {"provider_name": provider_name}
|
|
736
|
+
provider_response = self.http_client.request("PUT", "/providers", json_body=provider_payload,
|
|
737
|
+
use_api_base=True, auth_kind="web")
|
|
738
|
+
provider_res = provider_response.json()
|
|
739
|
+
if provider_response.status_code == 200 and provider_res.get("code") == 0:
|
|
740
|
+
print(f"Success to add provider {provider_name}")
|
|
741
|
+
else:
|
|
742
|
+
msg = provider_res.get("message", "")
|
|
743
|
+
if "duplicated" in msg.lower() or "already exist" in msg.lower():
|
|
744
|
+
print(f"Note: provider {provider_name} already exists, continuing to add instance")
|
|
745
|
+
else:
|
|
746
|
+
print(f"Fail to add provider {provider_name}, code: {provider_res.get('code')}, message: {msg}")
|
|
747
|
+
return
|
|
748
|
+
|
|
749
|
+
# Step 2: Add instance
|
|
750
|
+
instance_payload = {
|
|
751
|
+
"instance_name": "default",
|
|
752
|
+
"api_key": api_key,
|
|
753
|
+
"region": "default",
|
|
754
|
+
"base_url": ""
|
|
755
|
+
}
|
|
756
|
+
instance_response = self.http_client.request("POST", f"/providers/{provider_name}/instances",
|
|
757
|
+
json_body=instance_payload, use_api_base=True,
|
|
758
|
+
auth_kind="web")
|
|
759
|
+
instance_res = instance_response.json()
|
|
760
|
+
if instance_response.status_code == 200 and instance_res.get("code") == 0:
|
|
761
|
+
print(f"Success to add instance for provider {provider_name}")
|
|
762
|
+
else:
|
|
763
|
+
msg = instance_res.get("message", "")
|
|
764
|
+
if "already exist" in msg.lower():
|
|
765
|
+
print(f"Note: instance for provider {provider_name} already exists, skipping")
|
|
766
|
+
else:
|
|
767
|
+
print(f"Fail to add instance for provider {provider_name}, code: {instance_res.get('code')}, message: {msg}")
|
|
740
768
|
|
|
741
769
|
def drop_model_provider(self, command):
|
|
742
770
|
if self.server_type != "user":
|
|
743
771
|
print("This command is only allowed in USER mode")
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
response = self.http_client.request("
|
|
772
|
+
return
|
|
773
|
+
provider_name: str = command["provider_name"]
|
|
774
|
+
response = self.http_client.request("DELETE", f"/providers/{provider_name}", use_api_base=True,
|
|
747
775
|
auth_kind="web")
|
|
748
776
|
res_json = response.json()
|
|
749
|
-
if response.status_code == 200 and res_json
|
|
750
|
-
print(f"Success to drop model provider {
|
|
777
|
+
if response.status_code == 200 and res_json.get("code") == 0:
|
|
778
|
+
print(f"Success to drop model provider {provider_name}")
|
|
751
779
|
else:
|
|
752
|
-
print(
|
|
753
|
-
|
|
780
|
+
print(f"Fail to drop model provider {provider_name}, code: {res_json.get('code')}, message: {res_json.get('message')}")
|
|
781
|
+
|
|
782
|
+
# Mapping from legacy model_type keys to API model_type values
|
|
783
|
+
_MODEL_TYPE_MAP = {
|
|
784
|
+
"llm_id": "chat",
|
|
785
|
+
"embd_id": "embedding",
|
|
786
|
+
"img2txt_id": "vision",
|
|
787
|
+
"reranker_id": "rerank",
|
|
788
|
+
"asr_id": "asr",
|
|
789
|
+
"tts_id": "tts",
|
|
790
|
+
}
|
|
754
791
|
|
|
755
792
|
def set_default_model(self, command):
|
|
756
793
|
if self.server_type != "user":
|
|
757
794
|
print("This command is only allowed in USER mode")
|
|
795
|
+
return
|
|
758
796
|
|
|
759
|
-
|
|
797
|
+
model_type_key: str = command["model_type"]
|
|
760
798
|
model_id: str = command["model_id"]
|
|
761
|
-
|
|
799
|
+
|
|
800
|
+
model_type = self._MODEL_TYPE_MAP.get(model_type_key)
|
|
801
|
+
if model_type is None:
|
|
802
|
+
print(f"Unknown model type: {model_type_key}")
|
|
803
|
+
return
|
|
804
|
+
|
|
805
|
+
model_name, model_instance, model_provider = self._parse_model_id(model_id)
|
|
806
|
+
|
|
807
|
+
payload = {
|
|
808
|
+
"model_provider": model_provider,
|
|
809
|
+
"model_instance": model_instance,
|
|
810
|
+
"model_type": model_type,
|
|
811
|
+
"model_name": model_name,
|
|
812
|
+
}
|
|
813
|
+
response = self.http_client.request("PATCH", "/models/default", json_body=payload, use_api_base=True,
|
|
814
|
+
auth_kind="web")
|
|
815
|
+
res_json = response.json()
|
|
816
|
+
if response.status_code == 200 and res_json.get("code") == 0:
|
|
817
|
+
print(f"Success to set default {model_type} to {model_id}")
|
|
818
|
+
else:
|
|
819
|
+
print(f"Fail to set default {model_type}, code: {res_json.get('code')}, message: {res_json.get('message')}")
|
|
762
820
|
|
|
763
821
|
def reset_default_model(self, command):
|
|
764
822
|
if self.server_type != "user":
|
|
765
823
|
print("This command is only allowed in USER mode")
|
|
824
|
+
return
|
|
825
|
+
|
|
826
|
+
model_type_key: str = command["model_type"]
|
|
827
|
+
model_type = self._MODEL_TYPE_MAP.get(model_type_key)
|
|
828
|
+
if model_type is None:
|
|
829
|
+
print(f"Unknown model type: {model_type_key}")
|
|
830
|
+
return
|
|
831
|
+
|
|
832
|
+
payload = {"model_type": model_type}
|
|
833
|
+
response = self.http_client.request("PATCH", "/models/default", json_body=payload, use_api_base=True,
|
|
834
|
+
auth_kind="web")
|
|
835
|
+
res_json = response.json()
|
|
836
|
+
if response.status_code == 200 and res_json.get("code") == 0:
|
|
837
|
+
print(f"Success to reset default {model_type}")
|
|
838
|
+
else:
|
|
839
|
+
print(f"Fail to reset default {model_type}, code: {res_json.get('code')}, message: {res_json.get('message')}")
|
|
840
|
+
|
|
841
|
+
@staticmethod
|
|
842
|
+
def _parse_model_id(model_id: str):
|
|
843
|
+
"""Parse model_id into (model_name, model_instance, model_provider).
|
|
766
844
|
|
|
767
|
-
|
|
768
|
-
|
|
845
|
+
Accepted formats:
|
|
846
|
+
- model_name@instance@provider -> (model_name, instance, provider)
|
|
847
|
+
- model_name@provider -> (model_name, "default", provider)
|
|
848
|
+
- model_name -> (model_name, "default", "")
|
|
849
|
+
"""
|
|
850
|
+
parts = model_id.split("@")
|
|
851
|
+
if len(parts) >= 3:
|
|
852
|
+
return parts[0], parts[1], parts[-1]
|
|
853
|
+
elif len(parts) == 2:
|
|
854
|
+
return parts[0], "default", parts[1]
|
|
855
|
+
else:
|
|
856
|
+
return model_id, "default", ""
|
|
769
857
|
|
|
770
858
|
def list_user_datasets(self, command):
|
|
771
859
|
if self.server_type != "user":
|
|
@@ -1430,7 +1518,7 @@ class RAGFlowClient:
|
|
|
1430
1518
|
|
|
1431
1519
|
payload = {
|
|
1432
1520
|
"question": command_dict["question"],
|
|
1433
|
-
"
|
|
1521
|
+
"dataset_ids": dataset_ids,
|
|
1434
1522
|
"similarity_threshold": 0.2,
|
|
1435
1523
|
"vector_similarity_weight": 0.3,
|
|
1436
1524
|
# "top_k": 1024,
|
|
@@ -1438,11 +1526,11 @@ class RAGFlowClient:
|
|
|
1438
1526
|
}
|
|
1439
1527
|
iterations = command_dict.get("iterations", 1)
|
|
1440
1528
|
if iterations > 1:
|
|
1441
|
-
response = self.http_client.request("POST", "/
|
|
1529
|
+
response = self.http_client.request("POST", "/retrieval", json_body=payload, use_api_base=True,
|
|
1442
1530
|
auth_kind="web", iterations=iterations)
|
|
1443
1531
|
return response
|
|
1444
1532
|
else:
|
|
1445
|
-
response = self.http_client.request("POST", "/
|
|
1533
|
+
response = self.http_client.request("POST", "/retrieval", json_body=payload, use_api_base=True,
|
|
1446
1534
|
auth_kind="web")
|
|
1447
1535
|
res_json = response.json()
|
|
1448
1536
|
if response.status_code == 200:
|
|
@@ -1825,41 +1913,6 @@ class RAGFlowClient:
|
|
|
1825
1913
|
print(f"Fail to list chats, code: {res_json['code']}, message: {res_json['message']}")
|
|
1826
1914
|
return None
|
|
1827
1915
|
|
|
1828
|
-
def _get_default_models(self):
|
|
1829
|
-
response = self.http_client.request("GET", "/user/tenant_info", use_api_base=False, auth_kind="web")
|
|
1830
|
-
res_json = response.json()
|
|
1831
|
-
if response.status_code == 200:
|
|
1832
|
-
if res_json["code"] == 0:
|
|
1833
|
-
return res_json["data"]
|
|
1834
|
-
else:
|
|
1835
|
-
print(f"Fail to list user default models, code: {res_json['code']}, message: {res_json['message']}")
|
|
1836
|
-
return None
|
|
1837
|
-
else:
|
|
1838
|
-
print(f"Fail to list user default models, HTTP code: {response.status_code}, message: {res_json}")
|
|
1839
|
-
return None
|
|
1840
|
-
|
|
1841
|
-
def _set_default_models(self, model_type, model_id):
|
|
1842
|
-
current_payload = self._get_default_models()
|
|
1843
|
-
if current_payload is None:
|
|
1844
|
-
return
|
|
1845
|
-
else:
|
|
1846
|
-
current_payload.update({model_type: model_id})
|
|
1847
|
-
payload = {
|
|
1848
|
-
"tenant_id": current_payload["tenant_id"],
|
|
1849
|
-
"llm_id": current_payload["llm_id"],
|
|
1850
|
-
"embd_id": current_payload["embd_id"],
|
|
1851
|
-
"img2txt_id": current_payload["img2txt_id"],
|
|
1852
|
-
"asr_id": current_payload["asr_id"],
|
|
1853
|
-
"tts_id": current_payload["tts_id"],
|
|
1854
|
-
}
|
|
1855
|
-
response = self.http_client.request("POST", "/user/set_tenant_info", json_body=payload, use_api_base=False,
|
|
1856
|
-
auth_kind="web")
|
|
1857
|
-
res_json = response.json()
|
|
1858
|
-
if response.status_code == 200 and res_json["code"] == 0:
|
|
1859
|
-
print(f"Success to set default llm to {model_type}")
|
|
1860
|
-
else:
|
|
1861
|
-
print(f"Fail to set default llm to {model_type}, code: {res_json['code']}, message: {res_json['message']}")
|
|
1862
|
-
|
|
1863
1916
|
def _format_service_detail_table(self, data):
|
|
1864
1917
|
if isinstance(data, list):
|
|
1865
1918
|
return data
|
|
@@ -49,7 +49,7 @@ def encrypt_password(password_plain: str) -> str:
|
|
|
49
49
|
def register_user(client: HttpClient, email: str, nickname: str, password: str) -> None:
|
|
50
50
|
password_enc = encrypt_password(password)
|
|
51
51
|
payload = {"email": email, "nickname": nickname, "password": password_enc}
|
|
52
|
-
res = client.request_json("POST", "/
|
|
52
|
+
res = client.request_json("POST", "/users", use_api_base=True, auth_kind=None, json_body=payload)
|
|
53
53
|
if res.get("code") == 0:
|
|
54
54
|
return
|
|
55
55
|
msg = res.get("message", "")
|
|
@@ -64,7 +64,7 @@ def login_user(client: HttpClient, server_type: str, email: str, password: str)
|
|
|
64
64
|
if server_type == "admin":
|
|
65
65
|
response = client.request("POST", "/admin/login", use_api_base=True, auth_kind=None, json_body=payload)
|
|
66
66
|
else:
|
|
67
|
-
response = client.request("POST", "/
|
|
67
|
+
response = client.request("POST", "/auth/login", use_api_base=True, auth_kind=None, json_body=payload)
|
|
68
68
|
try:
|
|
69
69
|
res = response.json()
|
|
70
70
|
except Exception as exc:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|