Skip to content

Add a new API endpoint for the Codebase Search query

Context

In Add the Codebase Search Tool to Agentic Chat - ... (gitlab-org/modelops/applied-ml/code-suggestions/ai-assist#1287 - moved), we will add a Codebase Search Tool in Agentic Chat. This tool will need to query the codebase embeddings, which is accessible through Rails.

In this issue, we will expose a Codebase Semantic Search API in Rails. This should make use of the same ActiveContext query class currently used by Classic Chat's Codebase Search Tool executor.

References

See epic: Add the Codebase Search Tool to Agentic Chat - ... (gitlab-org/modelops/applied-ml/code-suggestions/ai-assist#1287 - moved)

Proposal

  1. In Ai::ActiveContext::Queries::Code, make KNN_COUNT and SEARCH_RESULTS_LIMIT a configurable parameter.
  2. Add a new GraphQL API to expose the codebase query.
    • This should have the following parameters:
      • user
      • search_term
      • [{ project_ids, path (optional) }] (array)
      • knn - for the KNN_COUNT
      • limit - for the SEARCH_RESULTS_LIMIT
    • This should return an array of search results by the given project_id|path combination
Edited by 🤖 GitLab Bot 🤖