Chainlit / chainlit

Build Conversational AI in minutes ⚡️
https://docs.chainlit.io
Apache License 2.0
7.13k stars 935 forks source link

LlamaIndex integration: Add support for llama-index >= 0.10.0 #752

Closed tslmy closed 7 months ago

tslmy commented 8 months ago

LlamaIndex 0.10.0 is a big update. They moved things around. Currently, we are stuck here:

AttributeError: module 'llama_index' has no attribute '__version__'
2024-02-19 22:00:31 - module 'llama_index' has no attribute '__version__'
Traceback (most recent call last):
  File ".../site-packages/chainlit/utils.py", line 39, in wrapper
    return await user_function(**params_values)
   ...
  File ".../site-packages/chainlit/llama_index/__init__.py", line 3, in <module>
    if not check_module_version("llama_index", "0.8.3"):
  File ".../site-packages/chainlit/utils.py", line 87, in check_module_version
    return version.parse(module.__version__) >= version.parse(required_version)
AttributeError: module 'llama_index' has no attribute '__version__'

I tried some monkeypatching:

import llama_index
llama_index.__version__ = "0.10.0"

and it looks like we really need some moving-arounds:

  File ".../site-packages/chainlit/llama_index/callbacks.py", line 8, in <module>
    from llama_index.callbacks import TokenCountingHandler
ImportError: cannot import name 'TokenCountingHandler' from 'llama_index.callbacks' (unknown location)
anoopshrma commented 8 months ago

Yeah seems like Chainlit needs to update llamaindex and update the imports or change it to legacy import if they don't want to move on to v0.10.x

willydouhard commented 8 months ago

WIll look into this!

tituslhy commented 8 months ago

Sorry @willydouhard can I check if this update is about ready? Llamaindex is pushing out updates super frequently sigh. The chainlit llamaindex callback is great for understandability.

felipearosr commented 8 months ago

I hope the issue resolves after my pull request is merged; it passed all the test locally.

tituslhy commented 7 months ago

Hello! Can I double-check if this issue has been resolved?

tslmy commented 7 months ago

Verified it works, at least for simple chat messages.