Skip to content

[ML] Remove Voyageai request manager classes #124512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

jonathan-buttner
Copy link
Contributor

This PR refactors some of the VoyageAI logic:

  • Remove the request manager classes
  • Remove the account class
  • Refactor the URI logic to expose them via the VoyageAIModel base class

Follows the same pattern as the OpenAI PR: #124144

@jonathan-buttner jonathan-buttner added >non-issue :ml Machine learning Team:ML Meta label for the ML team auto-backport Automatically create backport pull requests when merged Feature:GenAI Features around GenAI v8.19.0 v9.1.0 labels Mar 10, 2025
@@ -34,5 +34,9 @@ public static URI buildUri(URI accountUri, String service, CheckedSupplier<URI,
}
}

public static URI buildUri(String service, CheckedSupplier<URI, URISyntaxException> uriBuilder) {
return buildUri(null, service, uriBuilder);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just a helper that converts a URI exception to an ElasticsearchStatusException.

@@ -77,11 +71,7 @@ public boolean[] getTruncationInfo() {
return null;
}

public VoyageAIEmbeddingsTaskSettings getTaskSettings() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unused

import java.util.Map;
import java.util.Objects;

public abstract class VoyageAIModel extends Model {
public abstract class VoyageAIModel extends RateLimitGroupingModel {
private static final String DEFAULT_MODEL_FAMILY = "default_model_family";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moving the rate limiting logic inside the model class

@@ -73,22 +88,20 @@ public SecureString apiKey() {
return apiKey;
}

public VoyageAIRateLimitServiceSettings rateLimitServiceSettings() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not used


public abstract ExecutableAction accept(VoyageAIActionVisitor creator, Map<String, Object> taskSettings, InputType inputType);
return Objects.hash(modelFamily, apiKey);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a notable change. Previously the request manager was not including the apiKey in the grouping. This didn't seem right to me though because it'd mean that all users who were using the same model id family would be rate limited together. From the voyageai docs it does seem like you can have more granular rate limits per project. This doesn't accomplish that but at least it's a step in that direction because we shouldn't be grouping all users together.

// should only be used for testing
VoyageAIEmbeddingsModel(
String modelId,
String inferenceId,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixing naming

String service,
String url,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For testing we allow a string url.

@@ -339,26 +341,6 @@ public void testExecute_ThrowsElasticsearchException_WhenSenderOnFailureIsCalled
MatcherAssert.assertThat(thrownException.getMessage(), is("Failed to send VoyageAI embeddings request. Cause: failed"));
}

public void testExecute_ThrowsElasticsearchException_WhenSenderOnFailureIsCalled_WhenUrlIsNull() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this was copied from openai. The voyageai url cannot be specified in the service settings so it should never be null.

@jonathan-buttner jonathan-buttner marked this pull request as ready for review March 12, 2025 12:48
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/ml-core (Team:ML)

Copy link
Member

@davidkyle davidkyle left a comment

Choose a reason for hiding this comment

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

LGTM

@jonathan-buttner jonathan-buttner merged commit 1bee2cc into elastic:main Mar 13, 2025
17 checks passed
@jonathan-buttner jonathan-buttner deleted the ml-inference-remove-voyage-request-managers branch March 13, 2025 17:47
@jonathan-buttner
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.x

Questions ?

Please refer to the Backport tool documentation

jonathan-buttner added a commit to jonathan-buttner/elasticsearch that referenced this pull request Mar 13, 2025
* Removing voyage request managers

* Fixing tests

(cherry picked from commit 1bee2cc)
elasticsearchmachine pushed a commit that referenced this pull request Mar 13, 2025
* Removing voyage request managers

* Fixing tests

(cherry picked from commit 1bee2cc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged Feature:GenAI Features around GenAI :ml Machine learning >non-issue Team:ML Meta label for the ML team v8.19.0 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants