Skip to content

Commit

Permalink
fix: add workaround for incorrect Chainlit step output order
Browse files Browse the repository at this point in the history
  • Loading branch information
lsorber committed Dec 3, 2024
1 parent 4a55957 commit b450fe3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/raglite/_chainlit.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ async def handle_message(user_message: cl.Message) -> None:
step.elements = [ # Show the top chunks inline.
cl.Text(content=str(chunk), display="inline") for chunk in chunks[:5]
]
await step.update() # TODO: Workaround for https://github.com/Chainlit/chainlit/issues/602.
# Rerank the chunks and group them into chunk spans.
async with cl.Step(name="rerank", type="rerank") as step:
step.input = chunks
Expand All @@ -112,6 +113,7 @@ async def handle_message(user_message: cl.Message) -> None:
step.elements = [ # Show the top chunk spans inline.
cl.Text(content=str(chunk_span), display="inline") for chunk_span in chunk_spans
]
await step.update() # TODO: Workaround for https://github.com/Chainlit/chainlit/issues/602.
# Stream the LLM response.
assistant_message = cl.Message(content="")
messages: list[dict[str, str]] = cl.chat_context.to_openai()[:-1] # type: ignore[no-untyped-call]
Expand Down

0 comments on commit b450fe3

Please sign in to comment.