Update go server (#13589)

### What problem does this PR solve?

1. Add more CLI command
2. Add some license hooks

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-03-13 14:41:02 +08:00
committed by GitHub
parent ef94a9c291
commit 5c955a31cc
13 changed files with 200 additions and 47 deletions

View File

@ -95,6 +95,7 @@ sql_command: login_user
| list_server_configs
| show_fingerprint
| set_license
| set_license_config
| show_license
| check_license
| benchmark
@ -185,6 +186,7 @@ SERVER: "SERVER"i
FINGERPRINT: "FINGERPRINT"i
LICENSE: "LICENSE"i
CHECK: "CHECK"i
CONFIG: "CONFIG"i
login_user: LOGIN USER quoted_string ";"
list_services: LIST SERVICES ";"
@ -232,6 +234,7 @@ list_environments: LIST ENVS ";"
show_fingerprint: SHOW FINGERPRINT ";"
set_license: SET LICENSE quoted_string ";"
set_license_config: SET LICENSE CONFIG NUMBER NUMBER ";"
show_license: SHOW LICENSE ";"
check_license: CHECK LICENSE ";"
@ -496,6 +499,11 @@ class RAGFlowCLITransformer(Transformer):
license = items[2].children[0].strip("'\"")
return {"type": "set_license", "license": license}
def set_license_config(self, items):
value1: int = int(items[3])
value2: int = int(items[4])
return {"type": "set_license_config", "value1": value1, "value2": value2}
def show_license(self, items):
return {"type": "show_license"}

View File

@ -604,6 +604,18 @@ class RAGFlowClient:
else:
print(f"Fail to set license, code: {res_json['code']}, message: {res_json['message']}")
def set_license_config(self, command):
if self.server_type != "admin":
print("This command is only allowed in ADMIN mode")
value1 = command["value1"]
value2 = command["value2"]
response = self.http_client.request("POST", "/admin/license/config", json_body={"value1": value1, "value2": value2}, use_api_base=True, auth_kind="admin")
res_json = response.json()
if response.status_code == 200:
print("Set license successfully")
else:
print(f"Fail to set license, code: {res_json['code']}, message: {res_json['message']}")
def show_license(self, command):
if self.server_type != "admin":
print("This command is only allowed in ADMIN mode")
@ -1560,6 +1572,8 @@ def run_command(client: RAGFlowClient, command_dict: dict):
client.show_fingerprint(command_dict)
case "set_license":
client.set_license(command_dict)
case "set_license_config":
client.set_license_config(command_dict)
case "show_license":
client.show_license(command_dict)
case "check_license":