Skip to content

Support Commit in Duo Chat

Eva Kadlecová requested to merge 468460-support-commit-for-duo-chat-chat into master

What does this MR do and why?

Allow Duo Chat users to ask questions about commit. Supports the commit context from the page the user is currently on as well as allows user to specify certain commit (pasting a link or reference to the commit).

GraphQl changes: !160867 (merged)

Related MR in AI Gateway: gitlab-org/modelops/applied-ml/code-suggestions/ai-assist!1157 (merged)

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.

How to set up and validate locally

  1. From Rails console enable feature flags:
Feature.enable(:ai_commit_reader_for_chat)
Feature.enable(:v2_chat_agent_integration)
  1. Run GDK.
  2. In AI gateway repo checkout the 468460-support-commit-for-duo-chat branch and run AI gateway.
  3. Run rails console GITLAB_SIMULATE_SAAS=1 rails c
  4. Trigger CompletionWorker job from the rails console.
commit = Project.find(2).commit_by(oid: "6d394385cf567f80a8fd85055db1ab4c5295806f"); 
namespace_id = commit.project.project_namespace; 
options = {:client_subscription_id=>"02280262-f810-4670-8062-324fae5c9955", :namespace_id=>namespace_id, :content=>"summarize this commit"}; 
message_attributes = { request_id: SecureRandom.uuid, content: "summarize this commit", role: ::Gitlab::Llm::AiMessage::ROLE_USER, ai_action: :chat, user: User.first, context: ::Gitlab::Llm::AiMessageContext.new(resource: commit) }; 
message = ::Gitlab::Llm::AiMessage.for(action: :chat).new(message_attributes); 
::Llm::CompletionWorker.perform_for(message, options)
  1. Check the response in the Duo Chat. The commit should be summarized.

Related to #468460 (closed)

Edited by Eva Kadlecová

Merge request reports

Loading