Implementation:Infiniflow Ragflow Api Constants
| Knowledge Sources | |
|---|---|
| Domains | API, Configuration |
| Last Updated | 2026-02-12 06:00 GMT |
Overview
Concrete registry of API-wide constants for naming limits, service configuration, and resource constraints used across the RAGFlow API layer.
Description
The api.constants module defines shared constant values used throughout the API layer including name length limits, base64 image prefixes, API versioning, request timeout boundaries, and resource size constraints for datasets, files, and memory.
Usage
Import these constants when implementing API endpoints or service methods that need to enforce naming limits, validate file sizes, or reference the API version string.
Code Reference
Source Location
- Repository: Infiniflow_Ragflow
- File: api/constants.py
- Lines: 1-29
Signature
NAME_LENGTH_LIMIT = 2**10 # 1024
IMG_BASE64_PREFIX = "data:image/png;base64,"
API_VERSION = "v1"
RAG_FLOW_SERVICE_NAME = "ragflow"
REQUEST_WAIT_SEC = 2
REQUEST_MAX_WAIT_SEC = 300
DATASET_NAME_LIMIT = 128
FILE_NAME_LEN_LIMIT = 255
MEMORY_NAME_LIMIT = 128
MEMORY_SIZE_LIMIT = 10 * 1024 * 1024 # 10 MB
Import
from api.constants import NAME_LENGTH_LIMIT, DATASET_NAME_LIMIT, API_VERSION
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| — | — | — | Module-level constants; no inputs |
Outputs
| Name | Type | Description |
|---|---|---|
| NAME_LENGTH_LIMIT | int | Maximum length for entity names (1024) |
| DATASET_NAME_LIMIT | int | Maximum dataset name length (128) |
| FILE_NAME_LEN_LIMIT | int | Maximum file name length (255) |
| API_VERSION | str | Current API version string ("v1") |
| MEMORY_SIZE_LIMIT | int | Maximum memory size in bytes (10 MB) |
Usage Examples
from api.constants import DATASET_NAME_LIMIT, FILE_NAME_LEN_LIMIT
def validate_dataset_name(name: str) -> bool:
if len(name) > DATASET_NAME_LIMIT:
raise ValueError(f"Dataset name exceeds {DATASET_NAME_LIMIT} characters")
return True