Chainlit / chainlit

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

State of release candidate #607

Closed fabian-peschke closed 10 months ago

fabian-peschke commented 10 months ago

When using 1.0.0rc2 there are the following issues:

No bugs in terminal. Are these bugs known or has the implementation changed?

fabian-peschke commented 10 months ago

Found Message now takes id instead of parent_id and is working as expected now in rc2

willydouhard commented 10 months ago

TaskList and Avatar should work correctly, can you share a snippet of code to reproduce? Message no longer have children, instead a new Step concept has been introduced.

willydouhard commented 10 months ago

Opened https://github.com/Chainlit/chainlit/pull/608 to fix the task list and avatars

fabian-peschke commented 10 months ago

This is the code the worked before v1 release for the avatar (now with metadata):

@cl.on_chat_start
async def start():
    user = user_session.get("user")

    user_data = user.metadata
    user_image = user_data["image"]
    if user_image:
        user_image = base64.b64decode(user_image.split(',')[1])
    else:
        user_image = b" "

    await cl.Avatar(
        name=user.identifier,
        content=user_image
    ).send()

    current_path = os.path.dirname(os.path.abspath(__file__))

    await cl.Avatar(
        name="XX",
        path=f"{current_path}/assets/XX.jpeg"
    ).send()

This is how the tasklist worked before:

@cl.on_message
async def main(message: cl.Message):
    import asyncio

    msg = cl.Message(content="Init", author="XX")
    await msg.send()

    task_list = cl.TaskList(name="Steps")
    elements = []
    actions = []
    status = "Running..."
    task_list.status = status

    task = cl.Task(title="SOME NAME", status=cl.TaskStatus.READY)
    await task_list.add_task(task)
    await task_list.send()

    await asyncio.sleep(5)
    msg.content = "Done"
    await msg.send()

    task_list.status = "done"
    await task_list.send()
fabian-peschke commented 10 months ago

If its not possible to append a message to a message how can I give the step a language? Like "python" or something like this?

willydouhard commented 10 months ago

Here are the pre release docs

fabian-peschke commented 10 months ago

Okay this helped me on figuring out the cl.step part like so:

@cl.step
async def handle_debug_info(debug: dict):
    current_step = cl.context.current_step
    current_step.language = "python"
    return "def some_python(x: int)"

Why isn't a syntax like this not possible?:

@cl.step(language="python")
async def handle_debug_info(debug: dict):
    return "def some_python(x: int)"
willydouhard commented 10 months ago

I think I did not want to overload the decorator with all the step field.