forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Inference API] Add Azure AI Studio Embeddings and Chat Completion Su…
…pport (elastic#108472) * redo after messy merge commit * cleanups; refactoring; and added a few tests * filter xContent ratelimit; reduce boilerplate code * fix checkstyle issue * ... and spotlessApply * set lower rate limit 240; rename back files * clean lint * fix code and tests after merge * change completion temp and top_p to double * clean lint * add default max_new_tokens of 64 * constrain top_p temperature to 0.0-2.0 range * remove Snowflake provider; cleanups
- Loading branch information
Showing
55 changed files
with
7,191 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
.../org/elasticsearch/xpack/inference/external/action/azureaistudio/AzureAiStudioAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.inference.external.action.azureaistudio; | ||
|
||
import org.elasticsearch.ElasticsearchException; | ||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.core.TimeValue; | ||
import org.elasticsearch.inference.InferenceServiceResults; | ||
import org.elasticsearch.xpack.inference.external.action.ExecutableAction; | ||
import org.elasticsearch.xpack.inference.external.http.sender.AzureAiStudioRequestManager; | ||
import org.elasticsearch.xpack.inference.external.http.sender.InferenceInputs; | ||
import org.elasticsearch.xpack.inference.external.http.sender.Sender; | ||
|
||
import static org.elasticsearch.xpack.inference.external.action.ActionUtils.createInternalServerError; | ||
import static org.elasticsearch.xpack.inference.external.action.ActionUtils.wrapFailuresInElasticsearchException; | ||
|
||
public class AzureAiStudioAction implements ExecutableAction { | ||
protected final Sender sender; | ||
protected final AzureAiStudioRequestManager requestCreator; | ||
protected final String errorMessage; | ||
|
||
protected AzureAiStudioAction(Sender sender, AzureAiStudioRequestManager requestCreator, String errorMessage) { | ||
this.sender = sender; | ||
this.requestCreator = requestCreator; | ||
this.errorMessage = errorMessage; | ||
} | ||
|
||
@Override | ||
public void execute(InferenceInputs inferenceInputs, TimeValue timeout, ActionListener<InferenceServiceResults> listener) { | ||
try { | ||
ActionListener<InferenceServiceResults> wrappedListener = wrapFailuresInElasticsearchException(errorMessage, listener); | ||
|
||
sender.send(requestCreator, inferenceInputs, timeout, wrappedListener); | ||
} catch (ElasticsearchException e) { | ||
listener.onFailure(e); | ||
} catch (Exception e) { | ||
listener.onFailure(createInternalServerError(e, errorMessage)); | ||
} | ||
} | ||
} |
Oops, something went wrong.