Self-hosted models: test embedding model on the embeddings route

What does this MR do and why?

Self-hosted models support embedding as a model family. Embedding requests payloads are different from other AI models, so the Test connection functionality on Add Self-hosted model form always fails.

This MR fixes that failure with:

  • Adding a service specifically for testing Self-hosted embedding models: TestSelfHostedEmbeddingModelService. This inherits from the TestEmbeddingModelService, with 2 main differences:
    • the new service does not require the self-hosted model records to be persisted
    • The new service does not validate the dimensions (since the embedding dimensions is not yet specified in the "Add Self-hosted model form")
  • In CloudConnector::StatusChecks::Probes::SelfHosted::ModelConfigurationProbe, call the new TestSelfHostedEmbeddingModelService service for an embedding model

References

Screenshots or screen recordings

Self-hosted embedding model tested through the Add Self-hosted model form.

Regression test: testing the embedding model on the Semantic search Code embeddings page, dimensions is tested.

How to set up and validate locally

Setup a litellm proxy for an embedding model

  1. Install litellm proxy

  2. Configure an embedding model in your proxy. The example below sets up a proxy to Vertex AI's text-embedding-005

    # in a config.yml file
    model_list:
    - model_name: text-embedding-005
      litellm_params:
        model: vertex_ai/text-embedding-005   # what the proxy calls
  3. Run your litellm proxy with litellm --config config.yml. This should output the hostname for the proxy. By default, that is http://0.0.0.0:4000.

Test

  1. Go to the Add Self-hosted model form and add an embedding model
  2. On the Model family field, select EMBEDDING
  3. On the Endpoint field, set your proxy's host with the API version, e.g.: http://0.0.0.0:4000/v1
  4. On the Model identifier field, set the model name from your proxy configuration, e.g.:
  5. (Optional) If you did not set API key authentication for your proxy

Regression Test

Since we've updated the Embeddings::ModelFactory and Embeddings::ModelDefinition, we need to ensure that the existing embeddings indexing pipeline and semantic search functionality are still working:

sf_model = Ai::SelfHostedModel.find_by(identifier: "text-embedding-005") # ensure this self-hosted model is added first
collection_record = ::Ai::ActiveContext::Collections::Code.collection_record
collection_record.reload.update_metadata!(
  current_indexing_embedding_model: {
    field: 'embeddings_v1',
    model_type: 'self_hosted',
    model_ref: sf_model.id.to_s,
    dimensions: 768
  },
  search_embedding_model: {
    field: 'embeddings_v1',
    model_type: 'self_hosted',
    model_ref: sf_model.id.to_s,
    dimensions: 768
  },
)
::Ai::ActiveContext::Collections::Code.current_indexing_embedding_model.generate_embeddings(["test content"])
::Ai::ActiveContext::Collections::Code.search_embedding_model.generate_embeddings(["test content"])

MR acceptance checklist

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

Related to #627970 (closed)

Edited by Pam Artiaga

Merge request reports

Loading
Loading