Skip to content

[Bug]: KeyError: 'role_llm_funcs' during multimodal processing — asdict(lightrag) missing runtime-injected keys #297

Description

@gksruf123

Do you need to file an issue?

  • I have searched the existing issues and this bug is not already filed.
  • I believe this is a legitimate bug, not just a question or feature request.

Describe the bug

Environment

  • raganything: 1.3.1
  • lightrag-hku: 1.5.2
  • OS: Windows 10

Description

When processing documents with multimodal content (images, tables) enabled, the following error occurs during both batch and individual multimodal processing:

ERROR: Error in multimodal processing: 'role_llm_funcs'

Root Cause

In raganything/modalprocessors.py, BaseModalProcessor.__init__ sets:

self.global_config = asdict(lightrag)

asdict() only serializes dataclass fields. However, role_llm_funcs is not a dataclass fieldit is dynamically injected by LightRAG._build_global_config() at runtime (lightrag/lightrag.py, around line 835):

global_config["role_llm_funcs"] = {
    spec.name: states[spec.name].wrapped ...
}

As a result, when extract_entities() is called inside _process_chunk_for_extraction() with global_config=self.global_config, it raises KeyError: 'role_llm_funcs'.

Fix

Replace asdict(lightrag) with lightrag._build_global_config():

# Before
self.global_config = asdict(lightrag)

# After
self.global_config = lightrag._build_global_config()

Steps to Reproduce

1. Initialize RAGAnything with enable_image_processing=True or enable_table_processing=True
2. Process any PDF containing images or tables
3. Observe KeyError: 'role_llm_funcs' in multimodal processing stage

### Steps to reproduce

_No response_

### Expected Behavior

_No response_

### LightRAG Config Used

# Paste your config here


### Logs and screenshots

_No response_

### Additional Information

- LightRAG Version:
- Operating System:
- Python Version:
- Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions