mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-02 00:35:46 +08:00
### What problem does this PR solve? Closes https://github.com/infiniflow/ragflow/issues/14571. Adds CAJAL as a first-class local scientific-writing option in RAGFlow: - registers `agnuxo/cajal-4b-p2pclaw` as a known Ollama chat model with a 32K context setting - adds a built-in “CAJAL scientific paper agent” template under the existing agent template catalog - preconfigures the agent for grounded scientific writing: retrieval first, citation traceability, LaTeX-ready output, and explicit limitations when evidence is missing - adds unit coverage to ensure the template normalizes through RAGFlow’s production template loader, keeps graph form data in sync, and exposes the Ollama model option Behavior/evidence gathered for the requested model: - Hugging Face model metadata for `Agnuxo/CAJAL-4B-P2PCLAW` reports `pipeline_tag=text-generation` and tags including `gguf`, `llama.cpp`, `vllm`, `scientific-research`, `papers`, `academic-writing`, `latex`, and `license:apache-2.0`. - The model card documents CAJAL as a 4B scientific paper generation model with 32K context, local inference, LaTeX/citation specialization, and CPU-only support around 5 tok/s on Ryzen 7 5800X. - Local CPU generation could not be completed on this machine because the advertised Ollama model name is not currently resolvable from Ollama’s registry: both `https://registry.ollama.ai/v2/agnuxo/cajal-4b-p2pclaw/manifests/latest` and `https://registry.ollama.ai/v2/library/agnuxo/cajal-4b-p2pclaw/manifests/latest` returned `404 Not Found`; the Hugging Face repo tree currently exposes an 8.4 GB `model.safetensors` but no GGUF artifact in `main`. The template therefore targets the documented Ollama model name for users who have the local CAJAL deployment/model file available. Verification run locally: ```bash python3 -m pytest test/test_cajal_template_unit.py -q # 3 passed in 0.34s python3 - <<'PY' import json, glob for f in sorted(glob.glob('agent/templates/*.json') + ['conf/llm_factories.json']): with open(f, encoding='utf-8') as fp: json.load(fp) print('json_ok') PY # json_ok python3 -m ruff check test/test_cajal_template_unit.py # All checks passed! git diff --check ``` `uv run pytest test/testcases/test_web_api/test_agent_app/test_cajal_template_unit.py -q` was also attempted first, but dependency setup failed before test collection while building `ormsgpack==1.5.0` from uv with a package metadata parse error. Clearing uv’s `ormsgpack` cache and retrying reproduced the same build failure, so the focused unit test was run with the system Python environment instead. ### Type of change - [ ] Bug Fix (non-breaking change which fixes an issue) - [x] New Feature (non-breaking change which adds functionality) - [ ] Documentation Update - [ ] Refactoring - [ ] Performance Improvement - [ ] Other (please describe): --------- Co-authored-by: sxxtony <sxxtony@users.noreply.github.com> Co-authored-by: yzc <yzc@users.noreply.github.com> Co-authored-by: Zhichang Yu <yuzhichang@gmail.com>
(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.2 #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