Skip to content

Conversation

@afoucret
Copy link
Contributor

@afoucret afoucret commented Nov 6, 2025

Draft PR to add support for the completion task type for Elastic Inference Service.

@afoucret afoucret added the :SearchOrg/Inference Label for the Search Inference team label Nov 6, 2025
elasticsearchmachine and others added 2 commits November 6, 2025 13:24
@jonathan-buttner jonathan-buttner added >enhancement :ml Machine learning Team:ML Meta label for the ML team labels Nov 6, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @afoucret, I've created a changelog YAML for you.

@afoucret afoucret requested a review from Copilot November 6, 2025 16:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements support for the completion task type in the Elastic Inference Service (EIS). The implementation adapts simple text inputs from the completion task into chat message format and routes them to the existing EIS chat endpoint. Key architectural changes include introducing a distinction between COMPLETION and CHAT_COMPLETION task types, where completion uses a simpler text-based input format while chat completion uses structured message objects.

  • Introduces ElasticInferenceServiceCompletionModel for the completion task type
  • Refactors the original completion model to ElasticInferenceServiceChatCompletionModel to distinguish between task types
  • Adds request adapters to convert simple text inputs into chat message format

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
ElasticInferenceServiceCompletionRequestTests.java Tests for the completion request adapter that converts text inputs to chat messages
ElasticInferenceServiceCompletionRequestEntityTests.java Tests for the XContent serialization of completion request entities
ElasticInferenceServiceCompletionModelTests.java Tests for the completion model including URI creation and service settings
ElasticInferenceServiceChatCompletionModelTests.java Tests for the chat completion model (renamed from original completion model)
ElasticInferenceServiceAuthorizationHandlerTests.java Updates test references to use ElasticInferenceServiceChatCompletionModel
ElasticInferenceServiceTests.java Updates references and adds COMPLETION to supported task types
ElasticInferenceServiceUnifiedChatCompletionRequest.java Updates to use ElasticInferenceServiceChatCompletionModel
ElasticInferenceServiceCompletionRequestEntity.java Entity class for serializing completion requests to JSON
ElasticInferenceServiceCompletionRequest.java Request adapter for COMPLETION task type
ElasticInferenceServiceCompletionModel.java Model class for COMPLETION task type that adapts inputs to chat format
ElasticInferenceServiceChatCompletionModel.java Renamed model class for CHAT_COMPLETION task type
ElasticInferenceServiceActionVisitor.java Adds visitor method for completion model
ElasticInferenceServiceActionCreator.java Implements action creator for completion requests
ElasticInferenceServiceUnifiedCompletionRequestManager.java Updates to use ElasticInferenceServiceChatCompletionModel
ElasticInferenceService.java Adds COMPLETION to supported task types and creates model instances
137677.yaml Changelog entry for the enhancement

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@jonathan-buttner jonathan-buttner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I left a few suggestions.


public class ElasticInferenceServiceChatCompletionModel extends ElasticInferenceServiceModel {

public static ElasticInferenceServiceChatCompletionModel of(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember correctly, this is the only method that makes this class different from the ElasticInferenceServiceCompletionModel. How about we just use ElasticInferenceServiceCompletionModel and add this method there?

* Request adapter for COMPLETION task type that converts simple text inputs
* into chat message format and sends them to the EIS chat endpoint.
*/
public class ElasticInferenceServiceCompletionRequest extends ElasticInferenceServiceRequest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of creating a new class for this, let's follow the OpenAI example here: https://github.com/elastic/elasticsearch/blob/main/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/action/OpenAiActionCreator.java#L75-L86

Basically we should be able to leverage the existing ElasticInferenceServiceUnifiedChatCompletionRequest and just construct a request with only a list of input.

chunkingSettings
);
case CHAT_COMPLETION -> new ElasticInferenceServiceCompletionModel(
case CHAT_COMPLETION -> new ElasticInferenceServiceChatCompletionModel(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once we switch to using a single model class we should be able to follow what OpenAI does here: and have case CHAT_COMPLETION, COMPLETION -> ...

@afoucret
Copy link
Contributor Author

@jonathan-buttner: thank you for the careful review. I made the requested change and it looks better now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>enhancement :ml Machine learning :SearchOrg/Inference Label for the Search Inference team Team:ML Meta label for the ML team v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants