RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Feat: build ragflow-cli (#10544)
Lynn578ea34b3e26
diff --git a/.gitignore b/.gitignoreindex 956cd633ff..16bd4e7ffd 100644--- a/.gitignore+++ b/.gitignore@@ -149,6 +149,7 @@ out# Nuxt.js build / generate output.nuxtdist+admin/release# Gatsby files.cache/diff --git a/admin/README.md b/admin/README.mdindex c5e1c0b98a..1200e81232 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 CLI1. Ensure the Admin Service is running.-2. Launch the CLI client:+2. Install ragflow-cli.+ ```bash+ pip install ragflow-cli+ ```+3. Launch the CLI client:```bash- python admin/admin_client.py -h 0.0.0.0 -p 9381+ 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 <id>;`- Shows detailed status information for the service identified by `<id>`.-- `STARTUP SERVICE <id>;`- - Attempts to start the service identified by `<id>`.-- `SHUTDOWN SERVICE <id>;`- - Attempts to gracefully shut down the service identified by `<id>`.-- `RESTART SERVICE <id>;`- - Attempts to restart the service identified by `<id>`.+### 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 '<username>';`- Shows details and permissions for the specified user. The username must be enclosed in single or double quotes.++- `CREATE USER <username> <password>;`+ - Create user by username and password. The username and password must be enclosed in single or double quotes.+- `DROP USER '<username>';`- Removes the specified user from the system. Use with caution.- `ALTER USER PASSWORD '<username>' '<new_password>';`- Changes the password for the specified user.+- `ALTER USER ACTIVE <username> <on/off>;`+ - Changes the user to active or inactive.+### Data and Agent Commandsdiff --git a/admin/build_cli_release.sh b/admin/build_cli_release.shnew file mode 100755index 0000000000..c9fd6d9d90--- /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 filediff --git a/admin/pyproject.toml b/admin/pyproject.tomlnew file mode 100644index 0000000000..825fedce4e--- /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 = "[email protected]" }]+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.mdindex d36ed0ff54..faafbf1980 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 code1. 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:++ ```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:-The service will start and listen for incoming connections from the CLI on the configured port. Default port is 9381.+ ```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 CLI1. 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.++ ```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`.+β Enter superuser's password to login. Default password is `admin`.