Integrate Model Selection with Code Generation & Completion

After !191475 (merged) gets merged we will have the complete functionality basis for model selection that covers Duo chat and /commands.

To avoid going with all tools !190194 (diffs) in one MR, we need to have manageable MRs for groups of features.

Features to implement:

  • code_generations: 0
  • code_completions: 1

Objectives:

  • Integrate with the AI Gateway using the established pattern to use the model selection for root_namespace:
Gitlab::Llm::Chain::Requests::AiGateway.new(
  user,
  tracking_context: tracking_context,
  root_namespace: resource.try(:resource_parent)&.root_ancestor || find_root_namespace
)
  • Allow code generation to use the model selection for root_namespace
  • Allow code completion to use the model selection for root_namespace
  • Add appropriate test coverage for both features

Acceptance Criteria:

  • Both code generation and completion work correctly with the model selection for root_namespace and default, and also self-hosted, nothing is broken
  • Features are all based on ai_model_switching feature flag
Edited by Mohamed Hamda