Chainlit / chainlit

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

Thread does not display: `Accessing 'participantIdentifier' is not allowed.` #1055

Open dahifi opened 1 month ago

dahifi commented 1 month ago

Describe the bug Clicking thread history fails to show thread. Skeleton shows briefly before going to blank screen. To Reproduce Install Chainlit 1.0.505 start server and click any thread in history.

Expected behavior Thread should display

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Downgrading to 1.0.505 or upgrading to the current RC resolves the issue.

ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 408, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/starlette/applications.py", line 123, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/starlette/middleware/cors.py", line 85, in __call__
    await self.app(scope, receive, send)
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 65, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 756, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 776, in app
    await route.handle(scope, receive, send)
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 297, in handle
    await self.app(scope, receive, send)
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 77, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 72, in app
    response = await func(request)
               ^^^^^^^^^^^^^^^^^^^
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/fastapi/routing.py", line 278, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
    return await dependant.call(**values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/chainlit/server.py", line 654, in get_thread
    await is_thread_author(current_user.identifier, thread_id)
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/chainlit/data/acl.py", line 10, in is_thread_author
    thread_author = await data_layer.get_thread_author(thread_id)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/chainlit/data/__init__.py", line 389, in get_thread_author
    thread = await self.get_thread(thread_id)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/chainlit/data/__init__.py", line 451, in get_thread
    thread = await self.client.api.get_thread(id=thread_id)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/literalai/api/__init__.py", line 1563, in get_thread
    return await self.gql_helper(*get_thread_helper(id))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/literalai/api/__init__.py", line 1397, in gql_helper
    response = await self.make_gql_call(description, query, variables)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/literalai/api/__init__.py", line 1333, in make_gql_call
    raise_error(response.text)
  File "/Users/bcm/Library/Caches/pypoetry/virtualenvs/chainlit-template-xtqWlH9c-py3.11/lib/python3.11/site-packages/literalai/api/__init__.py", line 1320, in raise_error
    raise Exception(error)
Exception: {"errors":[{"message":"Accessing 'participantIdentifier' is not allowed.","locations":[{"line":23,"column":9}],"path":["threadDetail","steps",0,"participantIdentifier"],"extensions":{"code":"INVALID_SCHEMA"}},{"message":"Accessing 'participantIdentifier' is not allowed.","locations":[{"line":23,"column":9}],"path":["threadDetail","steps",1,"participantIdentifier"],"extensions":{"code":"INVALID_SCHEMA"}},{"message":"Accessing 'participantIdentifier' is not allowed.","locations":[{"line":23,"column":9}],"path":["threadDetail","steps",2,"participantIdentifier"],"extensions":{"code":"INVALID_SCHEMA"}},{"message":"Accessing 'participantIdentifier' is not allowed.","locations":[{"line":23,"column":9}],"path":["threadDetail","steps",3,"participantIdentifier"],"extensions":{"code":"INVALID_SCHEMA"}}],"data":{"threadDetail":{"id":"71f30b28-850c-4c33-829f-3ee67b7b47d0",

...entire thread history follows.

jannikh commented 1 month ago

I'm having the same issue. The participantIdentifier seems to come from the 'literalai' python package and doesn't have anything to do with my code that uses the chainlit library.

@dahifi Thank you soo much for the tips on resolving this issue!! 🤗 I've been running against a wall for hours trying to fix this bug, thinking it came from one of the changes I introduced to my project

willydouhard commented 1 month ago

Try to force update the version of literalai. pip install -U literalai

BachNgoH commented 1 month ago

I am also facing the same issue. Updating the literalai package resolve it! Thank you so much

kaannt commented 3 weeks ago

When I install chainlit it installs literalai-0.0.601 automatically. However this package seems to be the one that gives the error identified above when using client.api.get_thread. If I uninstall literalai and install literalai-0.0.606 then it works fine, but it complains it is incompatible with chainlit 1.1.202. Not sure if this is more of a pip issue or something to be resolved in chainlit

jannikh commented 3 weeks ago

@kaannt yeah, the combination of recommended packages unfortunately leads to this bug.

As far as I understood the current best workaround (if you don't want to downgrade to an earlier chainlit version that bundles with a compatible, bug-free literalai version) is to force the update of literalai with pip install -U literalai after installing the chainlit library normally (which includes the broken literalai-0.0.601). Especially when using docker or another build tool, I first installed my requirements.txt with the literalai-0.0.601 and then ran pip install -U literalai, as otherwise pip would throw an incompatibility error (pip is just going by which library versions were marked to support each other according to the chainlit devs).

Although they do seem to work well together, this may introduce new bugs due to the versions being officially incompatible. So this is only a temporary workaround to get the chat history back with the current chainlit version. as soon as this bug is fixed you should upgrade the libraries to the newest version (and remove the pip -U command from the build config).

The new prerelease version of chainlit also seems to work well, has chat history available, but I found other bugs such as the message author not being displayed properly, instead showing the application name.