mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-17 05:07:23 +08:00
## What this PR does Removes the self-concatenation of the vision model response in the video parsing path, so each generated video description is tokenized and indexed exactly once. A focused regression test exercises the public `picture.chunk` video path with a mocked vision model and asserts that the returned description is passed to `tokenize` once without duplication. ## Root cause The original video parsing implementation used: ```python ans += "\n" + ans tokenize(doc, ans, ...) ``` This duplicates the same model response. The adjacent image path combines two distinct values (`OCR text + vision description`); the video path has only the model response, so concatenating it with itself is an unintended copy/paste error from that image logic. ## Impact Before this fix, every successfully parsed video stored repeated text, increasing token and embedding input and potentially distorting indexed chunk content and retrieval scoring. ## Compatibility The change affects only the video branch in `rag/app/picture.py`. Image parsing, model invocation, prompts, callbacks, and error handling remain unchanged. ## Validation - `pytest --confcutdir=test/unit_test/rag/app test/unit_test/rag/app/test_picture_video.py -q`: 1 passed - Ruff check: passed - Ruff format check for the new test: passed - `git diff --check`: passed Closes #16846. --------- Co-authored-by: openhands <openhands@all-hands.dev>
(1). Deploy RAGFlow services and images
https://ragflow.io/docs/build_docker_image
(2). Configure the required environment for testing
Install Python dependencies (including test dependencies):
uv sync --python 3.13 --only-group test --no-default-groups --frozen
Activate the environment:
source .venv/bin/activate
Install SDK:
uv pip install sdk/python
Modify the .env file: Add the following code:
COMPOSE_PROFILES=${COMPOSE_PROFILES},tei-cpu
TEI_MODEL=BAAI/bge-small-en-v1.5
RAGFLOW_IMAGE=infiniflow/ragflow:v0.26.4 #Replace with the image you are using
Start the container(wait two minutes):
docker compose -f docker/docker-compose.yml up -d
(3). Test Elasticsearch
a) Run sdk tests against Elasticsearch:
export HTTP_API_TEST_LEVEL=p2
export HOST_ADDRESS=http://127.0.0.1:9380 # Ensure that this port is the API port mapped to your localhost
pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} test/testcases/test_sdk_api
b) Run http api tests against Elasticsearch:
pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} test/testcases/test_http_api
(4). Test Infinity
Modify the .env file:
DOC_ENGINE=${DOC_ENGINE:-infinity}
Start the container:
docker compose -f docker/docker-compose.yml down -v
docker compose -f docker/docker-compose.yml up -d
a) Run sdk tests against Infinity:
DOC_ENGINE=infinity pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} test/testcases/test_sdk_api
b) Run http api tests against Infinity:
DOC_ENGINE=infinity pytest -s --tb=short --level=${HTTP_API_TEST_LEVEL} test/testcases/test_http_api