Skip to content

Commit af98763

Browse files
authored
Admin: add 'show version' (infiniflow#11079)
### What problem does this PR solve? ``` admin> show version; show_version +-----------------------+ | version | +-----------------------+ | v0.21.0-241-gc6cf58d5 | +-----------------------+ admin> \q Goodbye! ``` ### Type of change - [x] New Feature (non-breaking change which adds functionality) --------- Signed-off-by: Jin Hai <haijin.chn@gmail.com>
1 parent 5a8fbc5 commit af98763

12 files changed

Lines changed: 41 additions & 8 deletions

File tree

admin/client/admin_client.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
| revoke_permission
5353
| alter_user_role
5454
| show_user_permission
55+
| show_version
5556
5657
// meta command definition
5758
meta_command: "\\" meta_command_name [meta_args]
@@ -93,6 +94,7 @@
9394
RESOURCES: "RESOURCES"i
9495
ON: "ON"i
9596
SET: "SET"i
97+
VERSION: "VERSION"i
9698
9799
list_services: LIST SERVICES ";"
98100
show_service: SHOW SERVICE NUMBER ";"
@@ -121,6 +123,8 @@
121123
alter_user_role: ALTER USER quoted_string SET ROLE identifier ";"
122124
show_user_permission: SHOW USER PERMISSION quoted_string ";"
123125
126+
show_version: SHOW VERSION ";"
127+
124128
action_list: identifier ("," identifier)*
125129
126130
identifier: WORD
@@ -247,6 +251,9 @@ def show_user_permission(self, items):
247251
user_name = items[3]
248252
return {"type": "show_user_permission", "user_name": user_name}
249253

254+
def show_version(self, items):
255+
return {"type": "show_version"}
256+
250257
def action_list(self, items):
251258
return items
252259

@@ -556,6 +563,8 @@ def execute_command(self, parsed_command: Dict[str, Any]):
556563
self._alter_user_role(command_dict)
557564
case 'show_user_permission':
558565
self._show_user_permission(command_dict)
566+
case 'show_version':
567+
self._show_version(command_dict)
559568
case 'meta':
560569
self._handle_meta_command(command_dict)
561570
case _:
@@ -862,6 +871,16 @@ def _show_user_permission(self, command):
862871
print(
863872
f"Fail to show user: {user_name_str} permission, code: {res_json['code']}, message: {res_json['message']}")
864873

874+
def _show_version(self, command):
875+
print("show_version")
876+
url = f'http://{self.host}:{self.port}/api/v1/admin/version'
877+
response = self.session.get(url)
878+
res_json = response.json()
879+
if response.status_code == 200:
880+
self._print_table_simple(res_json['data'])
881+
else:
882+
print(f"Fail to show version, code: {res_json['code']}, message: {res_json['message']}")
883+
865884
def _handle_meta_command(self, command):
866885
meta_command = command['command']
867886
args = command.get('args', [])

admin/server/admin_server.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from auth import init_default_admin, setup_auth
3232
from flask_session import Session
3333
from flask_login import LoginManager
34+
from common.versions import get_ragflow_version
3435

3536
stop_event = threading.Event()
3637

@@ -52,6 +53,7 @@
5253
os.environ.get("MAX_CONTENT_LENGTH", 1024 * 1024 * 1024)
5354
)
5455
Session(app)
56+
logging.info(f'RAGFlow version: {get_ragflow_version()}')
5557
show_configs()
5658
login_manager = LoginManager()
5759
login_manager.init_app(app)

admin/server/routes.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from services import UserMgr, ServiceMgr, UserServiceMgr
2525
from roles import RoleMgr
2626
from api.common.exceptions import AdminException
27+
from common.versions import get_ragflow_version
2728

2829
admin_bp = Blueprint('admin', __name__, url_prefix='/api/v1/admin')
2930

@@ -369,3 +370,13 @@ def get_user_permission(user_name: str):
369370
return success_response(res)
370371
except Exception as e:
371372
return error_response(str(e), 500)
373+
374+
@admin_bp.route('/version', methods=['GET'])
375+
@login_required
376+
@check_admin_auth
377+
def show_version():
378+
try:
379+
res = {"version": get_ragflow_version()}
380+
return success_response(res)
381+
except Exception as e:
382+
return error_response(str(e), 500)

api/apps/auth/github.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def __init__(self, config):
3434

3535
def fetch_user_info(self, access_token, **kwargs):
3636
"""
37-
Fetch github user info.
37+
Fetch GitHub user info.
3838
"""
3939
user_info = {}
4040
try:

api/apps/auth/oidc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def __init__(self, config):
4343
self.jwks_uri = config['jwks_uri']
4444

4545

46-
def _load_oidc_metadata(self, issuer):
46+
@staticmethod
47+
def _load_oidc_metadata(issuer):
4748
"""
4849
Load OIDC metadata from `/.well-known/openid-configuration`.
4950
"""

api/apps/system_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
server_error_response,
3030
generate_confirmation_token,
3131
)
32-
from api.versions import get_ragflow_version
32+
from common.versions import get_ragflow_version
3333
from common.time_utils import current_timestamp, datetime_format
3434
from timeit import default_timer as timer
3535

api/db/runtime_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
from api.versions import get_ragflow_version
16+
from common.versions import get_ragflow_version
1717
from .reload_config_base import ReloadConfigBase
1818

1919

api/ragflow_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from common import settings
4040
from api.db.db_models import init_database_tables as init_web_db
4141
from api.db.init_data import init_web_data
42-
from api.versions import get_ragflow_version
42+
from common.versions import get_ragflow_version
4343
from common.config_utils import show_configs
4444
from rag.utils.mcp_tool_call_conn import shutdown_all_mcp_sessions
4545
from rag.utils.redis_conn import RedisDistributedLock

api/versions.py renamed to common/versions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright 2024 The InfiniFlow Authors. All Rights Reserved.
2+
# Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)