-
Couldn't load subscription status.
- Fork 25.6k
[ML] Adding fields for Inference service configuration API #121103
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
| import org.elasticsearch.inference.SettingsConfiguration; | ||
| import org.elasticsearch.inference.SimilarityMeasure; | ||
| import org.elasticsearch.inference.TaskType; | ||
| import org.elasticsearch.inference.configuration.SettingsConfigurationFieldType; | ||
| import org.elasticsearch.rest.RestStatus; | ||
| import org.elasticsearch.xpack.inference.chunking.ChunkingSettingsBuilder; | ||
| import org.elasticsearch.xpack.inference.chunking.EmbeddingRequestChunker; | ||
|
|
@@ -51,6 +52,7 @@ | |
| import java.util.Map; | ||
| import java.util.Set; | ||
|
|
||
| import static org.elasticsearch.xpack.inference.services.ServiceFields.MODEL_ID; | ||
| import static org.elasticsearch.xpack.inference.services.ServiceUtils.createInvalidModelException; | ||
| import static org.elasticsearch.xpack.inference.services.ServiceUtils.parsePersistedConfigErrorMsg; | ||
| import static org.elasticsearch.xpack.inference.services.ServiceUtils.removeFromMap; | ||
|
|
@@ -363,6 +365,19 @@ public static InferenceServiceConfiguration get() { | |
| () -> { | ||
| var configurationMap = new HashMap<String, SettingsConfiguration>(); | ||
|
|
||
| configurationMap.put( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's optional for the It's required for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
required but with a default? 🧐 |
||
| MODEL_ID, | ||
| new SettingsConfiguration.Builder(supportedTaskTypes).setDescription( | ||
| "The name of the model to use for the inference task." | ||
| ) | ||
| .setLabel("Model ID") | ||
| .setRequired(false) | ||
| .setSensitive(false) | ||
| .setUpdatable(false) | ||
| .setType(SettingsConfigurationFieldType.STRING) | ||
| .build() | ||
| ); | ||
|
|
||
| configurationMap.putAll(DefaultSecretSettings.toSettingsConfiguration(supportedTaskTypes)); | ||
| configurationMap.putAll(RateLimitSettings.toSettingsConfiguration(supportedTaskTypes)); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
| import org.elasticsearch.inference.SettingsConfiguration; | ||
| import org.elasticsearch.inference.SimilarityMeasure; | ||
| import org.elasticsearch.inference.TaskType; | ||
| import org.elasticsearch.inference.configuration.SettingsConfigurationFieldType; | ||
| import org.elasticsearch.rest.RestStatus; | ||
| import org.elasticsearch.xpack.inference.chunking.ChunkingSettingsBuilder; | ||
| import org.elasticsearch.xpack.inference.chunking.EmbeddingRequestChunker; | ||
|
|
@@ -49,6 +50,7 @@ | |
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| import static org.elasticsearch.xpack.inference.services.ServiceFields.DIMENSIONS; | ||
| import static org.elasticsearch.xpack.inference.services.ServiceUtils.createInvalidModelException; | ||
| import static org.elasticsearch.xpack.inference.services.ServiceUtils.parsePersistedConfigErrorMsg; | ||
| import static org.elasticsearch.xpack.inference.services.ServiceUtils.removeFromMap; | ||
|
|
@@ -339,6 +341,33 @@ public static InferenceServiceConfiguration get() { | |
| () -> { | ||
| var configurationMap = new HashMap<String, SettingsConfiguration>(); | ||
|
|
||
| configurationMap.put( | ||
| JinaAIServiceSettings.MODEL_ID, | ||
| new SettingsConfiguration.Builder(supportedTaskTypes).setDescription( | ||
| "The name of the model to use for the inference task." | ||
| ) | ||
| .setLabel("Model ID") | ||
| .setRequired(true) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Required for both text embedding and rerank: https://api.jina.ai/redoc#tag/embeddings |
||
| .setSensitive(false) | ||
| .setUpdatable(false) | ||
| .setType(SettingsConfigurationFieldType.STRING) | ||
| .build() | ||
| ); | ||
|
|
||
| configurationMap.put( | ||
| DIMENSIONS, | ||
| new SettingsConfiguration.Builder(EnumSet.of(TaskType.TEXT_EMBEDDING)).setDescription( | ||
| "The number of dimensions the resulting embeddings should have. For more information refer to " | ||
| + "https://api.jina.ai/redoc#tag/embeddings/operation/create_embedding_v1_embeddings_post." | ||
| ) | ||
| .setLabel("Dimensions") | ||
| .setRequired(false) | ||
| .setSensitive(false) | ||
| .setUpdatable(false) | ||
| .setType(SettingsConfigurationFieldType.INTEGER) | ||
| .build() | ||
| ); | ||
|
|
||
| configurationMap.putAll(DefaultSecretSettings.toSettingsConfiguration(supportedTaskTypes)); | ||
| configurationMap.putAll(RateLimitSettings.toSettingsConfiguration(supportedTaskTypes)); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,8 +56,8 @@ | |
|
|
||
| import static org.elasticsearch.xpack.inference.external.action.ActionUtils.constructFailedToSendRequestMessage; | ||
| import static org.elasticsearch.xpack.inference.external.action.openai.OpenAiActionCreator.COMPLETION_ERROR_PREFIX; | ||
| import static org.elasticsearch.xpack.inference.services.ServiceFields.DIMENSIONS; | ||
| import static org.elasticsearch.xpack.inference.services.ServiceFields.MODEL_ID; | ||
| import static org.elasticsearch.xpack.inference.services.ServiceFields.URL; | ||
| import static org.elasticsearch.xpack.inference.services.ServiceUtils.createInvalidModelException; | ||
| import static org.elasticsearch.xpack.inference.services.ServiceUtils.parsePersistedConfigErrorMsg; | ||
| import static org.elasticsearch.xpack.inference.services.ServiceUtils.removeFromMap; | ||
|
|
@@ -440,19 +440,16 @@ public static InferenceServiceConfiguration get() { | |
| ); | ||
|
|
||
| configurationMap.put( | ||
| URL, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we want to expose the URL for users. This was meant to be an internal way to test. Although I know we've leveraged that to connect to other providers that adhere to the OpenAI spec. So If we want to keep this I can understand the argument for that. We should make it optional though. Let me know what you think. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. URL is configurable in the API so that it can be used with a LocalAI server https://www.elastic.co/search-labs/blog/localai-for-text-embeddings It shouldn't be configurable in the UI though as it makes little sense to change this when creating up an OpenAI endpoint |
||
| new SettingsConfiguration.Builder(SUPPORTED_TASK_TYPES_FOR_SERVICES_API).setDefaultValue( | ||
| "https://api.openai.com/v1/chat/completions" | ||
| DIMENSIONS, | ||
| new SettingsConfiguration.Builder(EnumSet.of(TaskType.TEXT_EMBEDDING)).setDescription( | ||
| "The number of dimensions the resulting embeddings should have. For more information refer to " | ||
| + "https://platform.openai.com/docs/api-reference/embeddings/create#embeddings-create-dimensions." | ||
| ) | ||
| .setDescription( | ||
| "The OpenAI API endpoint URL. For more information on the URL, refer to the " | ||
| + "https://platform.openai.com/docs/api-reference." | ||
| ) | ||
| .setLabel("URL") | ||
| .setRequired(true) | ||
| .setLabel("Dimensions") | ||
| .setRequired(false) | ||
| .setSensitive(false) | ||
| .setUpdatable(false) | ||
| .setType(SettingsConfigurationFieldType.STRING) | ||
| .setType(SettingsConfigurationFieldType.INTEGER) | ||
| .build() | ||
| ); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need to be required because it's defaulted for all task types. For example:
https://github.com/elastic/elasticsearch/blob/main/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/request/alibabacloudsearch/AlibabaCloudSearchSparseRequest.java#L58