[go: up one dir, main page]

Skip to content

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

Screenshots or screen recordings

Screen recording showing Slash command being created. It doesn't work, until it's associated with a project. Then the agent knows how to respond when I issue the command again

How to set up and validate locally

  1. Checkout this branch as well as the ai-catalog-item-unit-primitive branch in the gitlab-ai-gateway project. And clone the gitlab-cloud-connector repo, in to the parent of your GDK directory, and checkout the poc-add-ai-catalog-item-primitive
  2. 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")
  1. 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).
  2. 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
  3. Link the item to the project
i.update!(project: Project.find_by_full_path("gitlab-duo/test"))
  1. Try the command again and observe that it will give 5 Python tips /pt
Edited by Keeyan Nejad

Merge request reports

Loading