Skip to content

Add ability to modify service name when using chat

Gosia Ksionek requested to merge mk-duo-enterprise-for-slash-commands into master

What does this MR do and why?

When using new slash commands, we need to specify the unit primitive this slash command requires.

We need to check it in Web UI, but also we need to pass it to AI Gateway for second verification.

This is how @nmilojevic1 described it: "So we can send something like 'X-Gitlab-Unit-Primitive' => root_cause_analysis, as a request header and verify in /chat endpoint if the token contains root_cause_analysis scope"

This MR adds this mechanism to chat codebase. To leverage it, we need to override context.ai_request in the slash command class with ::Gitlab::Llm::Chain::Requests::AiGateway.new(user, service_name: :something, tracking_context: tracking_context).

We need AI gateway work as well to make it work: we need in /chat endpoint something similar as in proxy endpoints(https://gitlab.com/gitlab-org/modelops/applied-ml/code-suggestions/ai-assist/-/blob/main/ai_gateway/api/v1/proxy/anthropic.py#L29-31)

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

related to #467382

Merge request reports