Draft: POC: Enable defining custom slash commands in Ai::Catalog::Item to execute in Duo Chat web and IDE
What does this MR do and why?
This is a proof of concept MR to show how users can define custom slash commands when creating AI Catalog items. These will run custom agent logic, with a custom prompt passed to the GitLab AI Gateway.
For this branch to work, you need to have the GitLab AI Gateway setup locally, and to checkout the ai-catalog-item-unit-primitive branch (gitlab-org/modelops/applied-ml/code-suggestions/ai-assist@main...ai-catalog-item-unit-primitive), as well as the gitlab-cloud-connector project branch poc-add-ai-catalog-item-primitive, (gitlab-org/cloud-connector/gitlab-cloud-connector@main...poc-add-ai-catalog-item-primitive) which should live in the directory outside of your GDK.
What's missing
- Tests
- Validations
- Tying it all to the correct Ai::Catalog::ItemConsumer model, and checking
- Cleaner code: This is a bit messy. I was purely focused on the technical feasibility of custom slash commands
- Getting it working in VS Code: For some reason, the project context is not being passed when in VS Code, so I have no idea what items to enable. I believe this can be fixed entirely on the VS Code plugin side.
- Show the new slash commands as hints when you type
/. This would require work on the backend, frontend and VS code plugin. We may also want to vissualy distinguish between system slash commands and user defined ones.
References
- groupcustom models have an epic to explore custom slash commands: &16030
Screenshots or screen recordings
How to set up and validate locally
- Checkout this branch as well as the
ai-catalog-item-unit-primitivebranch in thegitlab-ai-gatewayproject. And clone thegitlab-cloud-connectorrepo, in to the parent of your GDK directory, and checkout thepoc-add-ai-catalog-item-primitive - Create a new
Ai::Catalog::Item, with a slash command and prompt defined:
i = Ai::Catalog::Item.create!(organization_id: 1, name: "Python Tips", description: "Gives Python tips", item_type: :agent, slash_command: "/pt", pr
ompt: "Give 5 Python tips, each simple enough to explain in a single line")
- Go to an MR for the test project with Duo Chat enabled: http://gdk.test:3000/gitlab-duo/test/-/merge_requests/1 (It's important to go to an issue or MR, as the project context is not passed in other pages).
- Issue the slash command in the chat
/pt. The agent will not know what to do with this command, as the new item has not been linked to the project yet - Link the item to the project
i.update!(project: Project.find_by_full_path("gitlab-duo/test"))
- Try the command again and observe that it will give 5 Python tips
/pt
Edited by Keeyan Nejad