mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-01-23 11:36:38 +08:00
Add list configs and environments (#12438)
### What problem does this PR solve?
1. list configs;
3. list envs;
```
admin> list configs;
+-------------------------------------------------------------------------------------------+-----------+----+---------------+-------+----------------+
| extra | host | id | name | port | service_type |
+-------------------------------------------------------------------------------------------+-----------+----+---------------+-------+----------------+
| {} | 0.0.0.0 | 0 | ragflow_0 | 9380 | ragflow_server |
| {'meta_type': 'mysql', 'password': 'infini_rag_flow', 'username': 'root'} | localhost | 1 | mysql | 5455 | meta_data |
| {'password': 'infini_rag_flow', 'store_type': 'minio', 'user': 'rag_flow'} | localhost | 2 | minio | 9000 | file_store |
| {'password': 'infini_rag_flow', 'retrieval_type': 'elasticsearch', 'username': 'elastic'} | localhost | 3 | elasticsearch | 1200 | retrieval |
| {'db_name': 'default_db', 'retrieval_type': 'infinity'} | localhost | 4 | infinity | 23817 | retrieval |
| {'database': 1, 'mq_type': 'redis', 'password': 'infini_rag_flow'} | localhost | 5 | redis | 6379 | message_queue |
| {'message_queue_type': 'redis'} | | 6 | task_executor | 0 | task_executor |
+-------------------------------------------------------------------------------------------+-----------+----+---------------+-------+----------------+
admin> list envs;
+-------------------------+------------------+
| env | value |
+-------------------------+------------------+
| DOC_ENGINE | elasticsearch |
| DEFAULT_SUPERUSER_EMAIL | admin@ragflow.io |
| DB_TYPE | mysql |
| DEVICE | cpu |
| STORAGE_IMPL | MINIO |
+-------------------------+------------------+
admin>
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
@ -58,6 +58,8 @@ sql_command: list_services
|
||||
| set_variable
|
||||
| show_variable
|
||||
| list_variables
|
||||
| list_configs
|
||||
| list_environments
|
||||
|
||||
// meta command definition
|
||||
meta_command: "\\" meta_command_name [meta_args]
|
||||
@ -103,6 +105,8 @@ SET: "SET"i
|
||||
VERSION: "VERSION"i
|
||||
VAR: "VAR"i
|
||||
VARS: "VARS"i
|
||||
CONFIGS: "CONFIGS"i
|
||||
ENVS: "ENVS"i
|
||||
|
||||
list_services: LIST SERVICES ";"
|
||||
show_service: SHOW SERVICE NUMBER ";"
|
||||
@ -137,6 +141,8 @@ revoke_admin: REVOKE ADMIN quoted_string ";"
|
||||
set_variable: SET VAR identifier identifier ";"
|
||||
show_variable: SHOW VAR identifier ";"
|
||||
list_variables: LIST VARS ";"
|
||||
list_configs: LIST CONFIGS ";"
|
||||
list_environments: LIST ENVS ";"
|
||||
|
||||
show_version: SHOW VERSION ";"
|
||||
|
||||
@ -284,6 +290,12 @@ class AdminTransformer(Transformer):
|
||||
def list_variables(self, items):
|
||||
return {"type": "list_variables"}
|
||||
|
||||
def list_configs(self, items):
|
||||
return {"type": "list_configs"}
|
||||
|
||||
def list_environments(self, items):
|
||||
return {"type": "list_environments"}
|
||||
|
||||
def action_list(self, items):
|
||||
return items
|
||||
|
||||
@ -648,6 +660,10 @@ class AdminCLI(Cmd):
|
||||
self._show_variable(command_dict)
|
||||
case "list_variables":
|
||||
self._list_variables(command_dict)
|
||||
case "list_configs":
|
||||
self._list_configs(command_dict)
|
||||
case "list_environments":
|
||||
self._list_environments(command_dict)
|
||||
case "meta":
|
||||
self._handle_meta_command(command_dict)
|
||||
case _:
|
||||
@ -840,6 +856,24 @@ class AdminCLI(Cmd):
|
||||
else:
|
||||
print(f"Fail to list variables, code: {res_json['code']}, message: {res_json['message']}")
|
||||
|
||||
def _list_configs(self, command):
|
||||
url = f"http://{self.host}:{self.port}/api/v1/admin/configs"
|
||||
response = self.session.get(url)
|
||||
res_json = response.json()
|
||||
if response.status_code == 200:
|
||||
self._print_table_simple(res_json["data"])
|
||||
else:
|
||||
print(f"Fail to list variables, code: {res_json['code']}, message: {res_json['message']}")
|
||||
|
||||
def _list_environments(self, command):
|
||||
url = f"http://{self.host}:{self.port}/api/v1/admin/environments"
|
||||
response = self.session.get(url)
|
||||
res_json = response.json()
|
||||
if response.status_code == 200:
|
||||
self._print_table_simple(res_json["data"])
|
||||
else:
|
||||
print(f"Fail to list variables, code: {res_json['code']}, message: {res_json['message']}")
|
||||
|
||||
def _handle_list_datasets(self, command):
|
||||
username_tree: Tree = command["user_name"]
|
||||
user_name: str = username_tree.children[0].strip("'\"")
|
||||
|
||||
Reference in New Issue
Block a user