Skip to content

Commit 6e8e309

Browse files
[ML] Exposing OpenAI URL field in services API (elastic#126638) (elastic#126684)
* Adding url configuration field * Fixing test
1 parent 4dfee46 commit 6e8e309

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
@@ -1589,6 +1589,15 @@ public void testGetConfiguration() throws Exception {
15891589
"type": "str",
15901590
"supported_task_types": ["text_embedding", "completion", "chat_completion"]
15911591
},
1592+
"url": {
1593+
"description": "The absolute URL of the external service to send requests to.",
1594+
"label": "URL",
1595+
"required": false,
1596+
"sensitive": false,
1597+
"updatable": false,
1598+
"type": "str",
1599+
"supported_task_types": ["text_embedding", "completion", "chat_completion"]
1600+
},
15921601
"dimensions": {
15931602
"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.",
15941603
"label": "Dimensions",

0 commit comments

Comments
 (0)