Skip to content

Comments

Fix error 'history messages'#1114

Closed
bennoloeffler wants to merge 2 commits intoHKUDS:mainfrom
bennoloeffler:FIX_Error__'history_messages'
Closed

Fix error 'history messages'#1114
bennoloeffler wants to merge 2 commits intoHKUDS:mainfrom
bennoloeffler:FIX_Error__'history_messages'

Conversation

@bennoloeffler
Copy link

Description

Using kotaemon with lightrag, I get this error message, when adding files to lightrag:

Indexing [1/1]: AMF-Imagebroschuere.pdf
=> Converting AMF-Imagebroschuere.pdf to text
=> Converted AMF-Imagebroschuere.pdf to text
=> [AMF-Imagebroschuere.pdf] Processed 28 chunks
=> Finished indexing AMF-Imagebroschuere.pdf
[GraphRAG] Creating/Updating index... This can take a long time.
[GraphRAG] Creating index: 0 / 14 documents.
Error: 'history_messages'

Related Issues

When
light_rag.insert_custom_chunks(doc, chunks)
is used, it seems to happen under specific circumstances.

Changes Made

    #REPLACED
    pipeline_status["history_messages"].append(log_message)

    #by:
    
    # BEL: history_messages is missing
    history_messages_available = pipeline_status.get('history_messages', False)
    if not history_messages_available:
       pipeline_status['history_messages'] = ['BEL: initial history entry'] 
    pipeline_status["history_messages"].append(log_message)
    
    # in lightrag.py

Checklist

  • [?] Changes tested locally: Do not know how
  • [?] Code reviewed: Nobody there to do
  • Documentation updated (if necessary)
  • Unit tests added (if applicable)

Additional Notes

It seems to NOT BE IDEAL, because it is not getting to the root. But I want to use it.
I may thank anybody who is more into it to fix it at the root.

@LarFii
Copy link
Collaborator

LarFii commented Mar 21, 2025

Thanks for sharing! The logic for checking and initializing history_messages is repeated in multiple places. To reduce redundancy and improve maintainability, consider extracting this logic into a separate function. This will make the code cleaner and easier to manage.

Example function:

   def ensure_history_messages_initialized(pipeline_status):
       history_messages_available = pipeline_status.get('history_messages', False)
       if not history_messages_available:
           pipeline_status['history_messages'] = ['BEL: initial history entry']

Then, replace the repeated code with a call to this function:

   async with pipeline_status_lock:
       pipeline_status["latest_message"] = log_message
       ensure_history_messages_initialized(pipeline_status)
       pipeline_status["history_messages"].append(log_message)

@danielaskdd
Copy link
Collaborator

The error is probably cause by missing initialize_pipeline_status. You should add the following line before you create LightRAG:

await initialize_pipeline_status()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants