Skip to content

Commit 39e594f

Browse files
[ML] Exposing OpenAI URL field in services API (#126638)
* Adding url configuration field * Fixing test
1 parent 7ad2369 commit 39e594f

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import static org.elasticsearch.xpack.inference.external.action.ActionUtils.constructFailedToSendRequestMessage;
6161
import static org.elasticsearch.xpack.inference.services.ServiceFields.DIMENSIONS;
6262
import static org.elasticsearch.xpack.inference.services.ServiceFields.MODEL_ID;
63+
import static org.elasticsearch.xpack.inference.services.ServiceFields.URL;
6364
import static org.elasticsearch.xpack.inference.services.ServiceUtils.createInvalidModelException;
6465
import static org.elasticsearch.xpack.inference.services.ServiceUtils.parsePersistedConfigErrorMsg;
6566
import static org.elasticsearch.xpack.inference.services.ServiceUtils.removeFromMap;
@@ -418,6 +419,19 @@ public static InferenceServiceConfiguration get() {
418419
() -> {
419420
var configurationMap = new HashMap<String, SettingsConfiguration>();
420421

422+
configurationMap.put(
423+
URL,
424+
new SettingsConfiguration.Builder(SUPPORTED_TASK_TYPES_FOR_SERVICES_API).setDescription(
425+
"The absolute URL of the external service to send requests to."
426+
)
427+
.setLabel("URL")
428+
.setRequired(false)
429+
.setSensitive(false)
430+
.setUpdatable(false)
431+
.setType(SettingsConfigurationFieldType.STRING)
432+
.build()
433+
);
434+
421435
configurationMap.put(
422436
MODEL_ID,
423437
new SettingsConfiguration.Builder(SUPPORTED_TASK_TYPES_FOR_SERVICES_API).setDescription(

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/OpenAiServiceTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,6 +1590,15 @@ public void testGetConfiguration() throws Exception {
15901590
"type": "str",
15911591
"supported_task_types": ["text_embedding", "completion", "chat_completion"]
15921592
},
1593+
"url": {
1594+
"description": "The absolute URL of the external service to send requests to.",
1595+
"label": "URL",
1596+
"required": false,
1597+
"sensitive": false,
1598+
"updatable": false,
1599+
"type": "str",
1600+
"supported_task_types": ["text_embedding", "completion", "chat_completion"]
1601+
},
15931602
"dimensions": {
15941603
"description": "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.",
15951604
"label": "Dimensions",

0 commit comments

Comments
 (0)