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
Print version when RAGFlow server startup (#3393)
Jin Hai201bbef7c0d7
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.ymlindex 38f1767a17..ff4ff47d78 100644--- a/.github/workflows/tests.yml+++ b/.github/workflows/tests.yml@@ -50,11 +50,11 @@ jobs:RUNNER_WORKSPACE_PREFIX=${RUNNER_WORKSPACE_PREFIX:-$HOME}cp -r ${RUNNER_WORKSPACE_PREFIX}/huggingface.co ${RUNNER_WORKSPACE_PREFIX}/nltk_data ${RUNNER_WORKSPACE_PREFIX}/libssl*.deb ${RUNNER_WORKSPACE_PREFIX}/tika-server*.jar* .sudo docker pull ubuntu:24.04- sudo docker build -f Dockerfile.slim -t infiniflow/ragflow:dev-slim .+ sudo ./build_docker_image.sh slim- name: Build ragflow:devrun: |- sudo docker build -f Dockerfile -t infiniflow/ragflow:dev .+ sudo ./build_docker_image.sh full- name: Start ragflow:dev-slimrun: |diff --git a/README.md b/README.mdindex 82229273c5..96ddf6f335 100644--- a/README.md+++ b/README.md@@ -274,7 +274,7 @@ git clone https://github.com/infiniflow/ragflow.gitcd ragflow/pip3 install huggingface-hub nltkpython3 download_deps.py-docker build -f Dockerfile.slim -t infiniflow/ragflow:dev-slim .+build_docker_image.sh slim```## 🔧 Build a Docker image including embedding models@@ -286,7 +286,7 @@ git clone https://github.com/infiniflow/ragflow.gitcd ragflow/pip3 install huggingface-hub nltkpython3 download_deps.py-docker build -f Dockerfile -t infiniflow/ragflow:dev .+build_docker_image.sh full```## 🔨 Launch service from source for developmentdiff --git a/api/ragflow_server.py b/api/ragflow_server.pyindex da3dff3b09..00cb170420 100644--- a/api/ragflow_server.py+++ b/api/ragflow_server.py@@ -35,7 +35,7 @@ from api.utils.log_utils import loggerfrom api.db.db_models import init_database_tables as init_web_dbfrom api.db.init_data import init_web_data-from api.versions import get_versions+from api.versions import get_versions, RAGFLOW_VERSION_INFOdef update_progress():@@ -56,6 +56,9 @@ if __name__ == '__main__':/_/ |_|/_/ |_|\____//_/ /_/ \____/ |__/|__/""")+ logger.info(+ f'RAGFlow version: {RAGFLOW_VERSION_INFO}'+ )logger.info(f'project base: {utils.file_utils.get_project_base_directory()}')diff --git a/api/versions.py b/api/versions.pyindex 859e75693a..54d151b34f 100644--- a/api/versions.py+++ b/api/versions.py@@ -15,6 +15,7 @@#import dotenvimport typing+import subprocessdef get_versions() -> typing.Mapping[str, typing.Any]:@@ -23,4 +24,29 @@ def get_versions() -> typing.Mapping[str, typing.Any]:def get_rag_version() -> typing.Optional[str]:- return get_versions().get("RAGFLOW_IMAGE", "infiniflow/ragflow:dev").split(":")[-1]\ No newline at end of file+ return get_versions().get("RAGFLOW_IMAGE", "infiniflow/ragflow:dev").split(":")[-1]+++RAGFLOW_VERSION_INFO = "dev"+++def get_closest_tag_and_count():+ # Get the current commit hash+ commit_id = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).strip().decode('utf-8')+ # Get the closest tag+ closest_tag = subprocess.check_output(['git', 'describe', '--tags', '--abbrev=0']).strip().decode('utf-8')+ # Get the commit hash of the closest tag+ closest_tag_commit = subprocess.check_output(['git', 'rev-list', '-n', '1', closest_tag]).strip().decode('utf-8')+ # Get the commit count since the closest tag+ process = subprocess.Popen(['git', 'rev-list', '--count', f'{closest_tag}..HEAD'], stdout=subprocess.PIPE)+ commits_count, _ = process.communicate()+ commits_count = int(commits_count.strip())++ if commits_count == 0:+ return closest_tag+ else:+ return f"{commit_id}({closest_tag}~{commits_count})"+++if RAGFLOW_VERSION_INFO == 'dev':+ RAGFLOW_VERSION_INFO = get_closest_tag_and_count()diff --git a/build_docker_image.sh b/build_docker_image.shnew file mode 100755index 0000000000..4fbef67d98--- /dev/null+++ b/build_docker_image.sh@@ -0,0 +1,46 @@+#!/bin/bash++print_help() {+ echo "Usage: $0 <option>"+ echo " full, build full image"+ echo " slim, build slim image"+ exit 1+}++if [ "$#" -ne 1 ]; then+ print_help+fi++docker_version="full"+if [ "$1" == "full" ]; then+ docker_version="full"+elif [ "$1" == "slim" ]; then+ docker_version="slim"+else+ print_help+fi++# update RAGFlow version+# Get the latest tag+last_tag=$(git describe --tags --abbrev=0)+# Get the number of commits from the last tag+commit_count=$(git rev-list --count "$last_tag..HEAD")+# Get the short commit id+last_commit=$(git rev-parse --short HEAD)++version_info=""+if [ "$commit_count" -eq 0 ]; then+ version_info=$last_tag+else+ printf -v version_info "%s(%s~%d)" "$last_commit" "$last_tag" $commit_count+fi+# Replace the version in the versions.py file+sed -i "s/\"dev\"/\"$version_info\"/" api/versions.py++if [ "$docker_version" == "full" ]; then+ docker build -f Dockerfile -t infiniflow/ragflow:dev .+else+ docker build -f Dockerfile.slim -t infiniflow/ragflow:dev-slim .+fi++git restore api/versions.py\ No newline at end of filediff --git a/docker/update_version.sh b/docker/update_version.shnew file mode 100644index 0000000000..f2e454d596--- /dev/null+++ b/docker/update_version.sh@@ -0,0 +1,16 @@+# update RAGFlow version+# Get the latest tag+last_tag=$(git describe --tags --abbrev=0)+# Get the number of commits from the last tag+commit_count=$(git rev-list --count "$last_tag..HEAD")+# Get the short commit id+last_commit=$(git rev-parse --short HEAD)++version_info=""+if [ "$commit_count" -eq 0 ]; then+ version_info=$last_tag+else+ printf -v version_info "%s(%s~%d)" "$last_commit" "$last_tag" $commit_count+fi+# Replace the version in the versions.py file+sed -i "s/\"dev\"/\"$version_info\"/" api/versions.py