chainlit
chainlit copied to clipboard
Add Callback for Command autocomplete
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