Skip to content

Commit fbbe736

Browse files
committed
Draft Watsonx inference API
1 parent d22ee5a commit fbbe736

File tree

5 files changed

+190
-0
lines changed

5 files changed

+190
-0
lines changed

specification/_doc_ids/table.csv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ inference-api-delete,https://www.elastic.co/docs/api/doc/elasticsearch/operation
310310
inference-api-get,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-get
311311
inference-api-post,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-inference
312312
inference-api-put,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put
313+
inference-api-put-watsonx,https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-service-watsonx-ai.html
313314
inference-api-stream,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-stream-inference
314315
inference-api-update,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-update
315316
inference-processor,https://www.elastic.co/guide/en/elasticsearch/reference/current/inference-processor.html
@@ -847,4 +848,7 @@ watcher-api-start,https://www.elastic.co/docs/api/doc/elasticsearch/operation/op
847848
watcher-api-stats,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-watcher-stats
848849
watcher-api-stop,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-watcher-stop
849850
watcher-api-update-settings,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-watcher-update-settings
851+
watsonx-api-keys,https://cloud.ibm.com/iam/apikeys
852+
watsonx-api-models,https://www.ibm.com/products/watsonx-ai/foundation-models
853+
watsonx-api-version,https://cloud.ibm.com/apidocs/watsonx-ai#active-version-dates
850854
xpack-rollup,https://www.elastic.co/guide/en/elasticsearch/reference/current/xpack-rollup.html
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"inference.put": {
3+
"documentation": {
4+
"url": "https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-service-watsonx-ai.html",
5+
"description": "Configure a Watsonx inference endpoint"
6+
},
7+
"stability": "stable",
8+
"visibility": "public",
9+
"headers": {
10+
"accept": ["application/json"],
11+
"content_type": ["application/json"]
12+
},
13+
"url": {
14+
"paths": [
15+
{
16+
"path": "/_inference/text_embedding/{watsonx_inference_id}",
17+
"methods": ["PUT"],
18+
"parts": {
19+
"watsonx_inference_id": {
20+
"type": "string",
21+
"description": "The inference Id"
22+
}
23+
}
24+
}
25+
]
26+
},
27+
"body": {
28+
"description": "The inference endpoint's task and service settings"
29+
}
30+
}
31+
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { RequestBase } from '@_types/Base'
21+
import { Id } from '@_types/common'
22+
import { integer } from '@_types/Numeric'
23+
24+
/**
25+
* Create a Watsonx inference endpoint.
26+
*
27+
* Creates an inference endpoint to perform an inference task with the `watsonxai` service.
28+
* The only valid task type for the model to perform is `text_embedding`.
29+
* You need an IBM Cloud Databases for Elasticsearch deployment to use the `watsonxai` inference service.
30+
* You can provision one through the IBM catalog, the Cloud Databases CLI plug-in, the Cloud Databases API, or Terraform.
31+
*
32+
* When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running.
33+
* After creating the endpoint, wait for the model deployment to complete before using it.
34+
* To verify the deployment status, use the get trained model statistics API.
35+
* Look for `"state": "fully_allocated"` in the response and ensure that the `"allocation_count"` matches the `"target_allocation_count"`.
36+
* Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources.
37+
* @rest_spec_name inference.put_watsonx
38+
* @availability stack since=8.11.0 stability=stable visibility=public
39+
* @availability serverless stability=stable visibility=public
40+
* @cluster_privileges manage_inference
41+
* @doc_id inference-api-put-watsonx
42+
*/
43+
export interface Request extends RequestBase {
44+
urls: [
45+
{
46+
path: '/_inference/text_embedding/{watsonx_inference_id}'
47+
methods: ['PUT']
48+
}
49+
]
50+
path_parts: {
51+
/**
52+
* The unique identifier of the inference endpoint.
53+
*/
54+
watsonx_inference_id: Id
55+
}
56+
body: {
57+
/**
58+
* The type of service supported for the specified task type. In this case, `watsonxai`.
59+
*/
60+
service: ServiceType
61+
/**
62+
* Settings used to install the inference model. These settings are specific to the `watsonxai` service.
63+
*/
64+
service_settings: WatsonxServiceSettings
65+
}
66+
}
67+
68+
export enum ServiceType {
69+
watsonxai
70+
}
71+
72+
export class RateLimitSetting {
73+
/**
74+
* By default, the `watsonxai` service sets the number of requests allowed per minute to 120.
75+
* @server_default 120
76+
*/
77+
requests_per_minute?: integer
78+
}
79+
80+
export class WatsonxServiceSettings {
81+
/**
82+
* A valid API key of your Watsonx account.
83+
* You can find your Watsonx API keys or you can create a new one on the API keys page.
84+
*
85+
* IMPORTANT: You need to provide the API key only once, during the inference model creation.
86+
* The get inference endpoint API does not retrieve your API key.
87+
* After creating the inference model, you cannot change the associated API key.
88+
* If you want to use a different API key, delete the inference model and recreate it with the same name and the updated API key.
89+
* @ext_doc_id watsonx-api-keys
90+
*/
91+
api_key: string
92+
/**
93+
* A version parameter that takes a version date in the format of `YYYY-MM-DD`.
94+
* For the active version data parameters, refer to the Wastonx documentation.
95+
* @ext_doc_id watsonx-api-version
96+
*/
97+
api_version: string
98+
/**
99+
* The name of the model to use for the inference task.
100+
* Refer to the IBM Embedding Models section in the Watsonx documentation for the list of available text embedding models.
101+
* @ext_doc_id watsonx-api-models
102+
*/
103+
model_id: string
104+
/**
105+
* The identifier of the IBM Cloud project to use for the inference task.
106+
*/
107+
project_id: string
108+
/**
109+
* This setting helps to minimize the number of rate limit errors returned from Watsonx.
110+
*/
111+
rate_limit?: RateLimitSetting
112+
/**
113+
* The URL of the inference endpoint that you created on Watsonx.
114+
*/
115+
url: string
116+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { InferenceEndpointInfo } from '@inference/_types/Services'
21+
22+
export class Response {
23+
body: InferenceEndpointInfo
24+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# summary:
2+
description: Run `PUT _inference/text_embedding/watsonx-embeddings` to create an Watonsx inference endpoint that performs a text embedding task.
3+
# method_request: "PUT _inference/text_embedding/watsonx-embeddings"
4+
# type: "request"
5+
value: |-
6+
{
7+
"service": "watsonxai",
8+
"service_settings": {
9+
"api_key": "Watsonx-API-Key",
10+
"url": "Wastonx-URL",
11+
"model_id": "ibm/slate-30m-english-rtrvr",
12+
"project_id": "IBM-Cloud-ID",
13+
"api_version": "2024-03-14"
14+
}
15+
}

0 commit comments

Comments
 (0)