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

Easy way to make messages not be nested within a step #1913

Open
JamesLloydPartingtonSerendipityai opened this issue Feb 19, 2025 · 0 comments
Labels
enhancement New feature or request needs-triage

Comments

@JamesLloydPartingtonSerendipityai
Copy link
Contributor

Current situation:
Whenever a message is sent within a step, the message will appear within that step.

What would also be nice to have:
I have a case where we want to use a step, but also allow messages to be sent to the UI which are not nested within the step. For example, we have a COT, but also need the users to see a "suggested" answer before the agent is finished.

We currently have this hacky work around:

from chainlit.context import local_steps


async def tell_user(message: str, **kwargs) -> None:
    
    msg = cl.Message(
        content=message,
        **kwargs
    )
    
    # A hack to allow the feedback feature to work, but also stop the message being inserted within a step
    # The parent_id is needed to enable feedback, so we cannot just set it as None.
    previous_steps = local_steps.get() or []
    parent_step = previous_steps[0] if previous_steps else None
    if parent_step:
        msg.parent_id = parent_step.id
    
    await msg.send()
@dosubot dosubot bot added the enhancement New feature or request label Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs-triage
Projects
None yet
Development

No branches or pull requests

1 participant