Add Callback for Command autocomplete
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
Just type a slash / in the message input and the auto complete popup is displayed
Thanks for the fast reply @hayescode and sorry for the confusion - I'm not talking about autocompleting the commands (in my example "/list_languages") but the message that comes after it.
My inspiration for this comes from the MCP spec for completions: https://modelcontextprotocol.io/specification/2025-06-18/server/utilities/completion#message-flow and ChatGPT's suggestions:
So maybe Command Suggestions would be a more appropriate term?