diff --git a/.gitignore b/.gitignore index 956cd633f..16bd4e7ff 100644 --- a/.gitignore +++ b/.gitignore @@ -149,6 +149,7 @@ out # Nuxt.js build / generate output .nuxt dist +admin/release # Gatsby files .cache/ diff --git a/admin/README.md b/admin/README.md index c5e1c0b98..1200e8123 100644 --- a/admin/README.md +++ b/admin/README.md @@ -15,22 +15,48 @@ It consists of a server-side Service and a command-line client (CLI), both imple - **Admin Service**: A backend service that interfaces with the RAGFlow system to execute administrative operations and monitor its status. - **Admin CLI**: A command-line interface that allows users to connect to the Admin Service and issue commands for system management. + + ### Starting the Admin Service -1. Before start Admin Service, please make sure RAGFlow system is already started. +#### Launching from source code + +1. Before start Admin Service, please make sure RAGFlow system is already started. + +2. Launch from source code: + + ```bash + python admin/admin_server.py + ``` + The service will start and listen for incoming connections from the CLI on the configured port. + +#### Using docker image + +1. Before startup, please configure the `docker_compose.yml` file to enable admin server: + + ```bash + command: + - --enable-adminserver + ``` + +2. Start the containers, the service will start and listen for incoming connections from the CLI on the configured port. + -2. Run the service script: - ```bash - python admin/admin_server.py - ``` - The service will start and listen for incoming connections from the CLI on the configured port. ### Using the Admin CLI 1. Ensure the Admin Service is running. -2. Launch the CLI client: +2. Install ragflow-cli. ```bash - python admin/admin_client.py -h 0.0.0.0 -p 9381 + pip install ragflow-cli + ``` +3. Launch the CLI client: + ```bash + ragflow-cli -h 0.0.0.0 -p 9381 + ``` + Enter superuser's password to login. Default password is `admin`. + + ## Supported Commands @@ -42,12 +68,7 @@ Commands are case-insensitive and must be terminated with a semicolon (`;`). - Lists all available services within the RAGFlow system. - `SHOW SERVICE ;` - Shows detailed status information for the service identified by ``. -- `STARTUP SERVICE ;` - - Attempts to start the service identified by ``. -- `SHUTDOWN SERVICE ;` - - Attempts to gracefully shut down the service identified by ``. -- `RESTART SERVICE ;` - - Attempts to restart the service identified by ``. + ### User Management Commands @@ -55,10 +76,17 @@ Commands are case-insensitive and must be terminated with a semicolon (`;`). - Lists all users known to the system. - `SHOW USER '';` - Shows details and permissions for the specified user. The username must be enclosed in single or double quotes. + +- `CREATE USER ;` + - Create user by username and password. The username and password must be enclosed in single or double quotes. + - `DROP USER '';` - Removes the specified user from the system. Use with caution. - `ALTER USER PASSWORD '' '';` - Changes the password for the specified user. +- `ALTER USER ACTIVE ;` + - Changes the user to active or inactive. + ### Data and Agent Commands diff --git a/admin/build_cli_release.sh b/admin/build_cli_release.sh new file mode 100755 index 000000000..c9fd6d9d9 --- /dev/null +++ b/admin/build_cli_release.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +set -e + +echo "๐Ÿš€ Start building..." +echo "================================" + +PROJECT_NAME="ragflow-cli" + +RELEASE_DIR="release" +BUILD_DIR="dist" +SOURCE_DIR="src" +PACKAGE_DIR="ragflow_cli" + +echo "๐Ÿงน Clean old build folder..." +rm -rf release/ + +echo "๐Ÿ“ Prepare source code..." +mkdir release/$PROJECT_NAME/$SOURCE_DIR -p +cp pyproject.toml release/$PROJECT_NAME/pyproject.toml +cp README.md release/$PROJECT_NAME/README.md + +mkdir release/$PROJECT_NAME/$SOURCE_DIR/$PACKAGE_DIR -p +cp admin_client.py release/$PROJECT_NAME/$SOURCE_DIR/$PACKAGE_DIR/admin_client.py + +if [ -d "release/$PROJECT_NAME/$SOURCE_DIR" ]; then + echo "โœ… source dir: release/$PROJECT_NAME/$SOURCE_DIR" +else + echo "โŒ source dir not exist: release/$PROJECT_NAME/$SOURCE_DIR" + exit 1 +fi + +echo "๐Ÿ”จ Make build file..." +cd release/$PROJECT_NAME +export PYTHONPATH=$(pwd) +python -m build + +echo "โœ… check build result..." +if [ -d "$BUILD_DIR" ]; then + echo "๐Ÿ“ฆ Package generated:" + ls -la $BUILD_DIR/ +else + echo "โŒ Build Failed: $BUILD_DIR not exist." + exit 1 +fi + +echo "๐ŸŽ‰ Build finished successfully!" \ No newline at end of file diff --git a/admin/pyproject.toml b/admin/pyproject.toml new file mode 100644 index 000000000..825fedce4 --- /dev/null +++ b/admin/pyproject.toml @@ -0,0 +1,24 @@ +[project] +name = "ragflow-cli" +version = "0.21.0.dev2" +description = "Admin Service's client of [RAGFlow](https://github.com/infiniflow/ragflow). The Admin Service provides user management and system monitoring. " +authors = [{ name = "Lynn", email = "lynn_inf@hotmail.com" }] +license = { text = "Apache License, Version 2.0" } +readme = "README.md" +requires-python = ">=3.10,<3.13" +dependencies = [ + "requests>=2.30.0,<3.0.0", + "beartype>=0.18.5,<0.19.0", + "pycryptodomex>=3.10.0", + "lark>=1.1.0", +] + +[dependency-groups] +test = [ + "pytest>=8.3.5", + "requests>=2.32.3", + "requests-toolbelt>=1.0.0", +] + +[project.scripts] +ragflow-cli = "ragflow_cli.admin_client:main" diff --git a/docs/guides/manage_users_and_services.md b/docs/guides/manage_users_and_services.md index d36ed0ff5..faafbf198 100644 --- a/docs/guides/manage_users_and_services.md +++ b/docs/guides/manage_users_and_services.md @@ -12,33 +12,50 @@ The Admin CLI and Admin Service form a client-server architectural suite for RAG -## Starting the Admin Service +### Starting the Admin Service + +#### Launching from source code 1. Before start Admin Service, please make sure RAGFlow system is already started. -2. Switch to ragflow/ directory and run the service script: -```bash -source .venv/bin/activate -export PYTHONPATH=$(pwd) -python admin/admin_server.py -``` +2. Launch from source code: -The service will start and listen for incoming connections from the CLI on the configured port. Default port is 9381. + ```bash + python admin/admin_server.py + ``` + + The service will start and listen for incoming connections from the CLI on the configured port. + +#### Using docker image + +1. Before startup, please configure the `docker_compose.yml` file to enable admin server: + + ```bash + command: + - --enable-adminserver + ``` + +2. Start the containers, the service will start and listen for incoming connections from the CLI on the configured port. -## Using the Admin CLI +### Using the Admin CLI 1. Ensure the Admin Service is running. -2. Launch the CLI client: -```bash -source .venv/bin/activate -export PYTHONPATH=$(pwd) -python admin/admin_client.py -h 0.0.0.0 -p 9381 -``` +2. Install ragflow-cli. -Enter superuser's password to login. Default password is `admin`. + ```bash + pip install ragflow-cli + ``` + +3. Launch the CLI client: + + ```bash + ragflow-cli -h 0.0.0.0 -p 9381 + ``` + +โ€‹ Enter superuser's password to login. Default password is `admin`.