Implementation:Infiniflow Ragflow KnowledgebaseService Update Parser Config
Appearance
| Knowledge Sources | |
|---|---|
| Domains | RAG, Document_Processing |
| Last Updated | 2026-02-12 06:00 GMT |
Overview
Concrete tool for updating parser-specific configuration on a knowledge base provided by RAGFlow KnowledgebaseService.
Description
KnowledgebaseService.update_parser_config performs a deep merge of new parser configuration into the existing parser_config JSON field on the Knowledgebase model. It uses a recursive dfs_update function to merge nested dictionaries without overwriting unrelated keys.
Usage
Call this to fine-tune parser parameters without overwriting the entire configuration. Supports partial updates.
Code Reference
Source Location
- Repository: ragflow
- File: api/db/services/knowledgebase_service.py
- Lines: L295-321
Signature
class KnowledgebaseService(CommonService):
@classmethod
@DB.connection_context()
def update_parser_config(cls, id: str, config: dict) -> None:
"""Deep-merge parser configuration.
Args:
id: str - Knowledge base ID.
config: dict - Parser configuration to merge. Keys include:
chunk_token_num (int), delimiter (str),
layout_recognize (str: "DeepDOC"|"Plain Text"),
table_context_size (int), image_context_size (int),
pages (list), task_page_size (int), llm_id (str),
enable_metadata (bool).
Returns:
None (updates in-place via update_by_id).
"""
Import
from api.db.services.knowledgebase_service import KnowledgebaseService
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| id | str | Yes | Knowledge base ID |
| config | dict | Yes | Parser configuration (partial, deep-merged) |
Outputs
| Name | Type | Description |
|---|---|---|
| (none) | None | Updates in-place; no return value |
Usage Examples
from api.db.services.knowledgebase_service import KnowledgebaseService
# Set chunk size and enable layout recognition
KnowledgebaseService.update_parser_config(
"kb-uuid-123",
{
"chunk_token_num": 512,
"layout_recognize": "DeepDOC",
"delimiter": "\\n!?;。;!?",
"task_page_size": 12
}
)
Related Pages
Implements Principle
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment