Chainlit / chainlit

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

cookbook example for llama-index broken under 0.6.2 #298

Closed scsich closed 1 year ago

scsich commented 1 year ago

Hi there, app.py from your cookbook examples with streaming turned on (default) yields a context error (below). Setting streaming to false causes this to work. Any ideas?

Traceback (most recent call last):
  File "/home/user/.pyenv/versions/3.11.4/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "/home/user/.pyenv/versions/3.11.4/lib/python3.11/threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "/home/user/wobs/venv311/lib/python3.11/site-packages/llama_index/llms/base.py", line 137, in wrapped_llm_chat
    event_id = callback_manager.on_event_start(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/wobs/venv311/lib/python3.11/site-packages/llama_index/callbacks/base.py", line 82, in on_event_start
    handler.on_event_start(event_type, payload, event_id=event_id, **kwargs)
  File "/home/user/wobs/venv311/lib/python3.11/site-packages/chainlit/llama_index/callbacks.py", line 45, in on_event_start
    Message(
  File "/home/user/wobs/venv311/lib/python3.11/site-packages/chainlit/message.py", line 171, in __init__
    super().__post_init__()
  File "/home/user/wobs/venv311/lib/python3.11/site-packages/chainlit/message.py", line 37, in __post_init__
    self.emitter = get_emitter()
                   ^^^^^^^^^^^^^
  File "/home/user/wobs/venv311/lib/python3.11/site-packages/chainlit/context.py", line 22, in get_emitter
    raise ChainlitContextException()
chainlit.context.ChainlitContextException: Chainlit context not found

Config file is generated by 0.6.2 (themes removed):

[project]
# If true (default), the app will be available to anonymous users.
# If false, users will need to authenticate and be part of the project to use the app.
public = true

# The project ID (found on https://cloud.chainlit.io).
# The project ID is required when public is set to false or when using the cloud database.
#id = ""

# Uncomment if you want to persist the chats.
# local will create a database in your .chainlit directory (requires node.js installed).
# cloud will use the Chainlit cloud database.
# custom will load use your custom client.
database = "local"

# Whether to enable telemetry (default: true). No personal data is collected.
enable_telemetry = true

# List of environment variables to be provided by each user to use the app.
user_env = []

# Duration (in seconds) during which the session is saved when the connection is lost
session_timeout = 3600

[UI]
# Name of the app and chatbot.
name = "Wobs"

# Description of the app and chatbot. This is used for HTML tags.
# description = ""

# The default value for the expand messages settings.
default_expand_messages = true

# Hide the chain of thought details from the user in the UI.
hide_cot = false

[meta]
generated_by = "0.6.2"
ramnes commented 1 year ago

Fixed already but not released yet. :)

See #256 and #290