Cinnamon/kotaemon

[BUG] unable to work with a broken chat history

spdc-elm opened this issue · 0 comments

Description

(Screenshot attached below)

If I got an error in a history, I have to start a new chat. That's awful.
Below is the error message on my server. I guessed it was the empty chat histories generated by previous error that caused these errors.

I suggest adding a new feature on webui, which can delete history or modify history chat.

The problem might happen on other cases besides using nanograph search!

Reproduction steps

1. Start a new chat, set search all in nanograph.
2. Use any method (like network error) to generate a broken chat history.
3. Try to continue chatting normally
4. You might see you cannot proceed anymore in this broken history. And the server side will receive errors like my description.

Screenshots

Image

Logs

......

File "/path/to/venv/lib/python3.10/site-packages/theflow/middleware.py", line 141, in __call__
    _output = self.next_call(*args, ​**kwargs)

File "/path/to/venv/lib/python3.10/site-packages/theflow/middleware.py", line 117, in __call__
    return self.next_call(*args, ​**kwargs)

File "/path/to/venv/lib/python3.10/site-packages/theflow/base.py", line 1017, in _runx
    return self.run(*args, ​**kwargs)

File "/path/to/libs/ktem/ktem/index/file/graph/nano_pipelines.py", line 499, in run
    entities, relationships, reports, sources = asyncio.run(

File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)

File "uvloop/loop.pyx", line 1518, in uvloop.loop.Loop.run_until_complete

File "/path/to/libs/ktem/ktem/index/file/graph/nano_pipelines.py", line 179, in nano_graph_rag_build_local_query_context
    use_text_units = await _find_most_related_text_unit_from_entities(

File "/path/to/venv/lib/python3.10/site-packages/nano_graphrag/_op.py", line 772, in _find_most_related_text_unit_from_entities
    all_text_units = truncate_list_by_token_size(

File "/path/to/venv/lib/python3.10/site-packages/nano_graphrag/_utils.py", line 74, in truncate_list_by_token_size
    tokens += len(encode_string_by_tiktoken(key(data)))

File "/path/to/venv/lib/python3.10/site-packages/nano_graphrag/_op.py", line 774, in <lambda>
    key=lambda x: x["data"]["content"],

TypeError: 'NoneType' object is not subscriptable

Browsers

None

OS

Ubuntu 22.04

Additional information

None