Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running an extended API endpoint with init_http_context() but chainlit API (cl.Message) isn't working #907

Open
antoineross opened this issue Apr 14, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@antoineross
Copy link

I'm just using the code from the documentation:

from chainlit.server import app
from fastapi import Request
from fastapi.responses import HTMLResponse
from chainlit.context import init_http_context
import chainlit as cl

@app.get("/hello")
async def hello(request: Request):
    init_http_context()
    await cl.Message(content="Hello World").send()
    return HTMLResponse("Hello World")

And my environment is:

python = 3.11
chainlit ==  1.0.502
literalai == 0.0.500
openai == 1.17.1

I have tried the following:

  1. initiating the http context on either/both on api endpoint and on chat start, but it seems like it doesn't work.
  2. I've added a literal_api_key to my environment variable and ran LITERAL_API_KEY="your key" chainlit run main.py, still doesn't work
  3. I've tried doing a websocket session on the api endpoint and still doesnt work:
    code for ws:
@app.get("/hello/{session_id}")
async def hello(request: Request, session_id: str):
    ws_session = WebsocketSession.get_by_id(session_id=session_id)
    init_ws_context(ws_session)
    await cl.Message(content="Hello World").send()
    return HTMLResponse("Data sent to the websocket client")

Have I missed anything?

@antoineross antoineross added the bug Something isn't working label Apr 14, 2024
@peiga
Copy link

peiga commented May 17, 2024

I can confirm, any progress on this issue yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

2 participants