mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Admin: add 'show version' (#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>
This commit is contained in:
@ -52,6 +52,7 @@ sql_command: list_services
|
|||||||
| revoke_permission
|
| revoke_permission
|
||||||
| alter_user_role
|
| alter_user_role
|
||||||
| show_user_permission
|
| show_user_permission
|
||||||
|
| show_version
|
||||||
|
|
||||||
// meta command definition
|
// meta command definition
|
||||||
meta_command: "\\" meta_command_name [meta_args]
|
meta_command: "\\" meta_command_name [meta_args]
|
||||||
@ -93,6 +94,7 @@ FOR: "FOR"i
|
|||||||
RESOURCES: "RESOURCES"i
|
RESOURCES: "RESOURCES"i
|
||||||
ON: "ON"i
|
ON: "ON"i
|
||||||
SET: "SET"i
|
SET: "SET"i
|
||||||
|
VERSION: "VERSION"i
|
||||||
|
|
||||||
list_services: LIST SERVICES ";"
|
list_services: LIST SERVICES ";"
|
||||||
show_service: SHOW SERVICE NUMBER ";"
|
show_service: SHOW SERVICE NUMBER ";"
|
||||||
@ -121,6 +123,8 @@ revoke_permission: REVOKE action_list ON identifier FROM ROLE identifier ";"
|
|||||||
alter_user_role: ALTER USER quoted_string SET ROLE identifier ";"
|
alter_user_role: ALTER USER quoted_string SET ROLE identifier ";"
|
||||||
show_user_permission: SHOW USER PERMISSION quoted_string ";"
|
show_user_permission: SHOW USER PERMISSION quoted_string ";"
|
||||||
|
|
||||||
|
show_version: SHOW VERSION ";"
|
||||||
|
|
||||||
action_list: identifier ("," identifier)*
|
action_list: identifier ("," identifier)*
|
||||||
|
|
||||||
identifier: WORD
|
identifier: WORD
|
||||||
@ -247,6 +251,9 @@ class AdminTransformer(Transformer):
|
|||||||
user_name = items[3]
|
user_name = items[3]
|
||||||
return {"type": "show_user_permission", "user_name": user_name}
|
return {"type": "show_user_permission", "user_name": user_name}
|
||||||
|
|
||||||
|
def show_version(self, items):
|
||||||
|
return {"type": "show_version"}
|
||||||
|
|
||||||
def action_list(self, items):
|
def action_list(self, items):
|
||||||
return items
|
return items
|
||||||
|
|
||||||
@ -556,6 +563,8 @@ class AdminCLI(Cmd):
|
|||||||
self._alter_user_role(command_dict)
|
self._alter_user_role(command_dict)
|
||||||
case 'show_user_permission':
|
case 'show_user_permission':
|
||||||
self._show_user_permission(command_dict)
|
self._show_user_permission(command_dict)
|
||||||
|
case 'show_version':
|
||||||
|
self._show_version(command_dict)
|
||||||
case 'meta':
|
case 'meta':
|
||||||
self._handle_meta_command(command_dict)
|
self._handle_meta_command(command_dict)
|
||||||
case _:
|
case _:
|
||||||
@ -862,6 +871,16 @@ class AdminCLI(Cmd):
|
|||||||
print(
|
print(
|
||||||
f"Fail to show user: {user_name_str} permission, code: {res_json['code']}, message: {res_json['message']}")
|
f"Fail to show user: {user_name_str} permission, code: {res_json['code']}, message: {res_json['message']}")
|
||||||
|
|
||||||
|
def _show_version(self, command):
|
||||||
|
print("show_version")
|
||||||
|
url = f'http://{self.host}:{self.port}/api/v1/admin/version'
|
||||||
|
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 show version, code: {res_json['code']}, message: {res_json['message']}")
|
||||||
|
|
||||||
def _handle_meta_command(self, command):
|
def _handle_meta_command(self, command):
|
||||||
meta_command = command['command']
|
meta_command = command['command']
|
||||||
args = command.get('args', [])
|
args = command.get('args', [])
|
||||||
|
|||||||
@ -31,6 +31,7 @@ from config import load_configurations, SERVICE_CONFIGS
|
|||||||
from auth import init_default_admin, setup_auth
|
from auth import init_default_admin, setup_auth
|
||||||
from flask_session import Session
|
from flask_session import Session
|
||||||
from flask_login import LoginManager
|
from flask_login import LoginManager
|
||||||
|
from common.versions import get_ragflow_version
|
||||||
|
|
||||||
stop_event = threading.Event()
|
stop_event = threading.Event()
|
||||||
|
|
||||||
@ -52,6 +53,7 @@ if __name__ == '__main__':
|
|||||||
os.environ.get("MAX_CONTENT_LENGTH", 1024 * 1024 * 1024)
|
os.environ.get("MAX_CONTENT_LENGTH", 1024 * 1024 * 1024)
|
||||||
)
|
)
|
||||||
Session(app)
|
Session(app)
|
||||||
|
logging.info(f'RAGFlow version: {get_ragflow_version()}')
|
||||||
show_configs()
|
show_configs()
|
||||||
login_manager = LoginManager()
|
login_manager = LoginManager()
|
||||||
login_manager.init_app(app)
|
login_manager.init_app(app)
|
||||||
|
|||||||
@ -24,6 +24,7 @@ from responses import success_response, error_response
|
|||||||
from services import UserMgr, ServiceMgr, UserServiceMgr
|
from services import UserMgr, ServiceMgr, UserServiceMgr
|
||||||
from roles import RoleMgr
|
from roles import RoleMgr
|
||||||
from api.common.exceptions import AdminException
|
from api.common.exceptions import AdminException
|
||||||
|
from common.versions import get_ragflow_version
|
||||||
|
|
||||||
admin_bp = Blueprint('admin', __name__, url_prefix='/api/v1/admin')
|
admin_bp = Blueprint('admin', __name__, url_prefix='/api/v1/admin')
|
||||||
|
|
||||||
@ -369,3 +370,13 @@ def get_user_permission(user_name: str):
|
|||||||
return success_response(res)
|
return success_response(res)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return error_response(str(e), 500)
|
return error_response(str(e), 500)
|
||||||
|
|
||||||
|
@admin_bp.route('/version', methods=['GET'])
|
||||||
|
@login_required
|
||||||
|
@check_admin_auth
|
||||||
|
def show_version():
|
||||||
|
try:
|
||||||
|
res = {"version": get_ragflow_version()}
|
||||||
|
return success_response(res)
|
||||||
|
except Exception as e:
|
||||||
|
return error_response(str(e), 500)
|
||||||
|
|||||||
@ -34,7 +34,7 @@ class GithubOAuthClient(OAuthClient):
|
|||||||
|
|
||||||
def fetch_user_info(self, access_token, **kwargs):
|
def fetch_user_info(self, access_token, **kwargs):
|
||||||
"""
|
"""
|
||||||
Fetch github user info.
|
Fetch GitHub user info.
|
||||||
"""
|
"""
|
||||||
user_info = {}
|
user_info = {}
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -43,7 +43,8 @@ class OIDCClient(OAuthClient):
|
|||||||
self.jwks_uri = config['jwks_uri']
|
self.jwks_uri = config['jwks_uri']
|
||||||
|
|
||||||
|
|
||||||
def _load_oidc_metadata(self, issuer):
|
@staticmethod
|
||||||
|
def _load_oidc_metadata(issuer):
|
||||||
"""
|
"""
|
||||||
Load OIDC metadata from `/.well-known/openid-configuration`.
|
Load OIDC metadata from `/.well-known/openid-configuration`.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -29,7 +29,7 @@ from api.utils.api_utils import (
|
|||||||
server_error_response,
|
server_error_response,
|
||||||
generate_confirmation_token,
|
generate_confirmation_token,
|
||||||
)
|
)
|
||||||
from api.versions import get_ragflow_version
|
from common.versions import get_ragflow_version
|
||||||
from common.time_utils import current_timestamp, datetime_format
|
from common.time_utils import current_timestamp, datetime_format
|
||||||
from timeit import default_timer as timer
|
from timeit import default_timer as timer
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
from api.versions import get_ragflow_version
|
from common.versions import get_ragflow_version
|
||||||
from .reload_config_base import ReloadConfigBase
|
from .reload_config_base import ReloadConfigBase
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -39,7 +39,7 @@ from common.file_utils import get_project_base_directory
|
|||||||
from common import settings
|
from common import settings
|
||||||
from api.db.db_models import init_database_tables as init_web_db
|
from api.db.db_models import init_database_tables as init_web_db
|
||||||
from api.db.init_data import init_web_data
|
from api.db.init_data import init_web_data
|
||||||
from api.versions import get_ragflow_version
|
from common.versions import get_ragflow_version
|
||||||
from common.config_utils import show_configs
|
from common.config_utils import show_configs
|
||||||
from rag.utils.mcp_tool_call_conn import shutdown_all_mcp_sessions
|
from rag.utils.mcp_tool_call_conn import shutdown_all_mcp_sessions
|
||||||
from rag.utils.redis_conn import RedisDistributedLock
|
from rag.utils.redis_conn import RedisDistributedLock
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright 2024 The InfiniFlow Authors. All Rights Reserved.
|
# Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@ -37,7 +37,7 @@ import trio
|
|||||||
import faulthandler
|
import faulthandler
|
||||||
from common.constants import FileSource, TaskStatus
|
from common.constants import FileSource, TaskStatus
|
||||||
from common import settings
|
from common import settings
|
||||||
from api.versions import get_ragflow_version
|
from common.versions import get_ragflow_version
|
||||||
from common.data_source.confluence_connector import ConfluenceConnector
|
from common.data_source.confluence_connector import ConfluenceConnector
|
||||||
from common.data_source.utils import load_all_docs_from_checkpoint_connector
|
from common.data_source.utils import load_all_docs_from_checkpoint_connector
|
||||||
from common.signal_utils import start_tracemalloc_and_snapshot, stop_tracemalloc
|
from common.signal_utils import start_tracemalloc_and_snapshot, stop_tracemalloc
|
||||||
|
|||||||
@ -55,7 +55,7 @@ from api.db.services.document_service import DocumentService
|
|||||||
from api.db.services.llm_service import LLMBundle
|
from api.db.services.llm_service import LLMBundle
|
||||||
from api.db.services.task_service import TaskService, has_canceled, CANVAS_DEBUG_DOC_ID, GRAPH_RAPTOR_FAKE_DOC_ID
|
from api.db.services.task_service import TaskService, has_canceled, CANVAS_DEBUG_DOC_ID, GRAPH_RAPTOR_FAKE_DOC_ID
|
||||||
from api.db.services.file2document_service import File2DocumentService
|
from api.db.services.file2document_service import File2DocumentService
|
||||||
from api.versions import get_ragflow_version
|
from common.versions import get_ragflow_version
|
||||||
from api.db.db_models import close_connection
|
from api.db.db_models import close_connection
|
||||||
from rag.app import laws, paper, presentation, manual, qa, table, book, resume, picture, naive, one, audio, \
|
from rag.app import laws, paper, presentation, manual, qa, table, book, resume, picture, naive, one, audio, \
|
||||||
email, tag
|
email, tag
|
||||||
|
|||||||
Reference in New Issue
Block a user