chainlit icon indicating copy to clipboard operation
chainlit copied to clipboard

Add Callback for Command autocomplete

Open eiseleMichael opened this issue 3 months ago • 2 comments
trafficstars

When starting a /command there should be a way to listen to it on the server and provide completions for it. These completions could then be used in the frontend to guide the user

A possible solution might look like this:


@cl.on_command_autocomplete
async def on_command_autocomplete(msg: cl.Message) -> list[str] | None:
     if msg.command == "list_languages":
          languages = ["javascript", "python","typescript", "go", "rust"]
          return [lang for lang in languages if lang.startswith(msg.content)
     return None

eiseleMichael avatar Jul 22 '25 11:07 eiseleMichael