Skip to content

Commit 3af5d9f

Browse files
Auto-generated API code (#2922)
1 parent 9afd050 commit 3af5d9f

File tree

4 files changed

+234
-40
lines changed

4 files changed

+234
-40
lines changed

docs/reference.asciidoc

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2479,7 +2479,6 @@ A partial reduction is performed every time the coordinating node has received a
24792479
** *`ignore_unavailable` (Optional, boolean)*: Whether specified concrete indices should be ignored when unavailable (missing or closed)
24802480
** *`lenient` (Optional, boolean)*: Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
24812481
** *`max_concurrent_shard_requests` (Optional, number)*: The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests
2482-
** *`min_compatible_shard_node` (Optional, string)*
24832482
** *`preference` (Optional, string)*: Specify the node or shard the operation should be performed on (default: random)
24842483
** *`request_cache` (Optional, boolean)*: Specify if request cache should be used for this request or not, defaults to true
24852484
** *`routing` (Optional, string)*: A list of specific routing values
@@ -2622,9 +2621,6 @@ It supports a list of values, such as `open,hidden`.
26222621
local cluster state. If `false` the list of selected nodes are computed
26232622
from the cluster state of the master node. In both cases the coordinating
26242623
node will send requests for further information to each selected node.
2625-
** *`master_timeout` (Optional, string | -1 | 0)*: The period to wait for a connection to the master node.
2626-
If the master node is not available before the timeout expires, the request fails and returns an error.
2627-
To indicated that the request should never timeout, you can set it to `-1`.
26282624

26292625
[discrete]
26302626
==== allocation
@@ -8402,6 +8398,70 @@ These settings are specific to the `cohere` service.
84028398
These settings are specific to the task type you specified.
84038399
** *`timeout` (Optional, string | -1 | 0)*: Specifies the amount of time to wait for the inference endpoint to be created.
84048400

8401+
[discrete]
8402+
==== put_custom
8403+
Create a custom inference endpoint.
8404+
8405+
The custom service gives more control over how to interact with external inference services that aren't explicitly supported through dedicated integrations.
8406+
The custom service gives you the ability to define the headers, url, query parameters, request body, and secrets.
8407+
The custom service supports the template replacement functionality, which enables you to define a template that can be replaced with the value associated with that key.
8408+
Templates are portions of a string that start with `${` and end with `}`.
8409+
The parameters `secret_parameters` and `task_settings` are checked for keys for template replacement. Template replacement is supported in the `request`, `headers`, `url`, and `query_parameters`.
8410+
If the definition (key) is not found for a template, an error message is returned.
8411+
In case of an endpoint definition like the following:
8412+
----
8413+
PUT _inference/text_embedding/test-text-embedding
8414+
{
8415+
"service": "custom",
8416+
"service_settings": {
8417+
"secret_parameters": {
8418+
"api_key": "<some api key>"
8419+
},
8420+
"url": "...endpoints.huggingface.cloud/v1/embeddings",
8421+
"headers": {
8422+
"Authorization": "Bearer ${api_key}",
8423+
"Content-Type": "application/json"
8424+
},
8425+
"request": "{\"input\": ${input}}",
8426+
"response": {
8427+
"json_parser": {
8428+
"text_embeddings":"$.data[*].embedding[*]"
8429+
}
8430+
}
8431+
}
8432+
}
8433+
----
8434+
To replace `${api_key}` the `secret_parameters` and `task_settings` are checked for a key named `api_key`.
8435+
8436+
> info
8437+
> Templates should not be surrounded by quotes.
8438+
8439+
Pre-defined templates:
8440+
* `${input}` refers to the array of input strings that comes from the `input` field of the subsequent inference requests.
8441+
* `${input_type}` refers to the input type translation values.
8442+
* `${query}` refers to the query field used specifically for reranking tasks.
8443+
* `${top_n}` refers to the `top_n` field available when performing rerank requests.
8444+
* `${return_documents}` refers to the `return_documents` field available when performing rerank requests.
8445+
8446+
https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-custom[Endpoint documentation]
8447+
[source,ts]
8448+
----
8449+
client.inference.putCustom({ task_type, custom_inference_id, service, service_settings })
8450+
----
8451+
8452+
[discrete]
8453+
==== Arguments
8454+
8455+
* *Request (object):*
8456+
** *`task_type` (Enum("text_embedding" | "sparse_embedding" | "rerank" | "completion"))*: The type of the inference task that the model will perform.
8457+
** *`custom_inference_id` (string)*: The unique identifier of the inference endpoint.
8458+
** *`service` (Enum("custom"))*: The type of service supported for the specified task type. In this case, `custom`.
8459+
** *`service_settings` ({ headers, input_type, query_parameters, request, response, secret_parameters, url })*: Settings used to install the inference model.
8460+
These settings are specific to the `custom` service.
8461+
** *`chunking_settings` (Optional, { max_chunk_size, overlap, sentence_overlap, strategy })*: The chunking configuration object.
8462+
** *`task_settings` (Optional, { parameters })*: Settings to configure the inference task.
8463+
These settings are specific to the task type you specified.
8464+
84058465
[discrete]
84068466
==== put_deepseek
84078467
Create a DeepSeek inference endpoint.

src/api/api/inference.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,51 @@ export default class Inference {
609609
return await this.transport.request({ path, method, querystring, body, meta }, options)
610610
}
611611

612+
/**
613+
* Create a custom inference endpoint. The custom service gives more control over how to interact with external inference services that aren't explicitly supported through dedicated integrations. The custom service gives you the ability to define the headers, url, query parameters, request body, and secrets. The custom service supports the template replacement functionality, which enables you to define a template that can be replaced with the value associated with that key. Templates are portions of a string that start with `${` and end with `}`. The parameters `secret_parameters` and `task_settings` are checked for keys for template replacement. Template replacement is supported in the `request`, `headers`, `url`, and `query_parameters`. If the definition (key) is not found for a template, an error message is returned. In case of an endpoint definition like the following: ``` PUT _inference/text_embedding/test-text-embedding { "service": "custom", "service_settings": { "secret_parameters": { "api_key": "<some api key>" }, "url": "...endpoints.huggingface.cloud/v1/embeddings", "headers": { "Authorization": "Bearer ${api_key}", "Content-Type": "application/json" }, "request": "{\"input\": ${input}}", "response": { "json_parser": { "text_embeddings":"$.data[*].embedding[*]" } } } } ``` To replace `${api_key}` the `secret_parameters` and `task_settings` are checked for a key named `api_key`. > info > Templates should not be surrounded by quotes. Pre-defined templates: * `${input}` refers to the array of input strings that comes from the `input` field of the subsequent inference requests. * `${input_type}` refers to the input type translation values. * `${query}` refers to the query field used specifically for reranking tasks. * `${top_n}` refers to the `top_n` field available when performing rerank requests. * `${return_documents}` refers to the `return_documents` field available when performing rerank requests.
614+
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-custom | Elasticsearch API documentation}
615+
*/
616+
async putCustom (this: That, params: T.InferencePutCustomRequest | TB.InferencePutCustomRequest, options?: TransportRequestOptionsWithOutMeta): Promise<T.InferencePutCustomResponse>
617+
async putCustom (this: That, params: T.InferencePutCustomRequest | TB.InferencePutCustomRequest, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.InferencePutCustomResponse, unknown>>
618+
async putCustom (this: That, params: T.InferencePutCustomRequest | TB.InferencePutCustomRequest, options?: TransportRequestOptions): Promise<T.InferencePutCustomResponse>
619+
async putCustom (this: That, params: T.InferencePutCustomRequest | TB.InferencePutCustomRequest, options?: TransportRequestOptions): Promise<any> {
620+
const acceptedPath: string[] = ['task_type', 'custom_inference_id']
621+
const acceptedBody: string[] = ['chunking_settings', 'service', 'service_settings', 'task_settings']
622+
const querystring: Record<string, any> = {}
623+
// @ts-expect-error
624+
const userBody: any = params?.body
625+
let body: Record<string, any> | string
626+
if (typeof userBody === 'string') {
627+
body = userBody
628+
} else {
629+
body = userBody != null ? { ...userBody } : undefined
630+
}
631+
632+
for (const key in params) {
633+
if (acceptedBody.includes(key)) {
634+
body = body ?? {}
635+
// @ts-expect-error
636+
body[key] = params[key]
637+
} else if (acceptedPath.includes(key)) {
638+
continue
639+
} else if (key !== 'body') {
640+
// @ts-expect-error
641+
querystring[key] = params[key]
642+
}
643+
}
644+
645+
const method = 'PUT'
646+
const path = `/_inference/${encodeURIComponent(params.task_type.toString())}/${encodeURIComponent(params.custom_inference_id.toString())}`
647+
const meta: TransportRequestMetadata = {
648+
name: 'inference.put_custom',
649+
pathParts: {
650+
task_type: params.task_type,
651+
custom_inference_id: params.custom_inference_id
652+
}
653+
}
654+
return await this.transport.request({ path, method, querystring, body, meta }, options)
655+
}
656+
612657
/**
613658
* Create a DeepSeek inference endpoint. Create an inference endpoint to perform an inference task with the `deepseek` service.
614659
* @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/8.19/infer-service-deepseek.html | Elasticsearch API documentation}

src/api/types.ts

Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3500,9 +3500,10 @@ export interface AggregationsFiltersAggregation extends AggregationsBucketAggreg
35003500
}
35013501

35023502
export interface AggregationsFiltersBucketKeys extends AggregationsMultiBucketBase {
3503+
key?: string
35033504
}
35043505
export type AggregationsFiltersBucket = AggregationsFiltersBucketKeys
3505-
& { [property: string]: AggregationsAggregate | long }
3506+
& { [property: string]: AggregationsAggregate | string | long }
35063507

35073508
export interface AggregationsFormatMetricAggregationBase extends AggregationsMetricAggregationBase {
35083509
format?: string
@@ -4672,7 +4673,7 @@ export interface AnalysisEdgeNGramTokenizer extends AnalysisTokenizerBase {
46724673
custom_token_chars?: string
46734674
max_gram?: integer
46744675
min_gram?: integer
4675-
token_chars?: string | AnalysisTokenChar[]
4676+
token_chars?: AnalysisTokenChar[]
46764677
}
46774678

46784679
export interface AnalysisElisionTokenFilter extends AnalysisTokenFilterBase {
@@ -6961,7 +6962,6 @@ export interface AsyncSearchSubmitRequest extends RequestBase {
69616962
ignore_unavailable?: boolean
69626963
lenient?: boolean
69636964
max_concurrent_shard_requests?: long
6964-
min_compatible_shard_node?: VersionString
69656965
preference?: string
69666966
request_cache?: boolean
69676967
routing?: Routing
@@ -7150,7 +7150,6 @@ export interface CatAliasesRequest extends CatCatRequestBase {
71507150
s?: Names
71517151
expand_wildcards?: ExpandWildcards
71527152
local?: boolean
7153-
master_timeout?: Duration
71547153
}
71557154

71567155
export type CatAliasesResponse = CatAliasesAliasesRecord[]
@@ -10809,7 +10808,14 @@ export interface EsqlAsyncEsqlResult extends EsqlEsqlResult {
1080910808
is_running: boolean
1081010809
}
1081110810

10812-
export interface EsqlClusterInfo {
10811+
export interface EsqlEsqlClusterDetails {
10812+
status: EsqlEsqlClusterStatus
10813+
indices: string
10814+
took?: DurationValue<UnitMillis>
10815+
_shards?: EsqlEsqlShardInfo
10816+
}
10817+
10818+
export interface EsqlEsqlClusterInfo {
1081310819
total: integer
1081410820
successful: integer
1081510821
running: integer
@@ -10819,27 +10825,20 @@ export interface EsqlClusterInfo {
1081910825
details: Record<string, EsqlEsqlClusterDetails>
1082010826
}
1082110827

10822-
export interface EsqlColumnInfo {
10828+
export type EsqlEsqlClusterStatus = 'running' | 'successful' | 'partial' | 'skipped' | 'failed'
10829+
10830+
export interface EsqlEsqlColumnInfo {
1082310831
name: string
1082410832
type: string
1082510833
}
1082610834

10827-
export interface EsqlEsqlClusterDetails {
10828-
status: EsqlEsqlClusterStatus
10829-
indices: string
10830-
took?: DurationValue<UnitMillis>
10831-
_shards?: EsqlEsqlShardInfo
10832-
}
10833-
10834-
export type EsqlEsqlClusterStatus = 'running' | 'successful' | 'partial' | 'skipped' | 'failed'
10835-
1083610835
export interface EsqlEsqlResult {
1083710836
took?: DurationValue<UnitMillis>
1083810837
is_partial?: boolean
10839-
all_columns?: EsqlColumnInfo[]
10840-
columns: EsqlColumnInfo[]
10838+
all_columns?: EsqlEsqlColumnInfo[]
10839+
columns: EsqlEsqlColumnInfo[]
1084110840
values: FieldValue[][]
10842-
_clusters?: EsqlClusterInfo
10841+
_clusters?: EsqlEsqlClusterInfo
1084310842
profile?: any
1084410843
}
1084510844

@@ -13471,6 +13470,32 @@ export interface InferenceContentObject {
1347113470
type: string
1347213471
}
1347313472

13473+
export interface InferenceCustomRequestParams {
13474+
content: string
13475+
}
13476+
13477+
export interface InferenceCustomResponseParams {
13478+
json_parser: any
13479+
}
13480+
13481+
export interface InferenceCustomServiceSettings {
13482+
headers?: any
13483+
input_type?: any
13484+
query_parameters?: any
13485+
request: InferenceCustomRequestParams
13486+
response: InferenceCustomResponseParams
13487+
secret_parameters: any
13488+
url?: string
13489+
}
13490+
13491+
export type InferenceCustomServiceType = 'custom'
13492+
13493+
export interface InferenceCustomTaskSettings {
13494+
parameters?: any
13495+
}
13496+
13497+
export type InferenceCustomTaskType = 'text_embedding' | 'sparse_embedding' | 'rerank' | 'completion'
13498+
1347413499
export interface InferenceDeepSeekServiceSettings {
1347513500
api_key: string
1347613501
model_id: string
@@ -13605,6 +13630,11 @@ export interface InferenceInferenceEndpointInfoCohere extends InferenceInference
1360513630
task_type: InferenceTaskTypeCohere
1360613631
}
1360713632

13633+
export interface InferenceInferenceEndpointInfoCustom extends InferenceInferenceEndpoint {
13634+
inference_id: string
13635+
task_type: InferenceTaskTypeCustom
13636+
}
13637+
1360813638
export interface InferenceInferenceEndpointInfoDeepSeek extends InferenceInferenceEndpoint {
1360913639
inference_id: string
1361013640
task_type: InferenceTaskTypeDeepSeek
@@ -13780,6 +13810,8 @@ export type InferenceTaskTypeAzureOpenAI = 'text_embedding' | 'completion'
1378013810

1378113811
export type InferenceTaskTypeCohere = 'text_embedding' | 'rerank' | 'completion'
1378213812

13813+
export type InferenceTaskTypeCustom = 'text_embedding' | 'sparse_embedding' | 'rerank' | 'completion'
13814+
1378313815
export type InferenceTaskTypeDeepSeek = 'completion' | 'chat_completion'
1378413816

1378513817
export type InferenceTaskTypeELSER = 'sparse_embedding'
@@ -13986,6 +14018,17 @@ export interface InferencePutCohereRequest extends RequestBase {
1398614018

1398714019
export type InferencePutCohereResponse = InferenceInferenceEndpointInfoCohere
1398814020

14021+
export interface InferencePutCustomRequest extends RequestBase {
14022+
task_type: InferenceCustomTaskType
14023+
custom_inference_id: Id
14024+
chunking_settings?: InferenceInferenceChunkingSettings
14025+
service: InferenceCustomServiceType
14026+
service_settings: InferenceCustomServiceSettings
14027+
task_settings?: InferenceCustomTaskSettings
14028+
}
14029+
14030+
export type InferencePutCustomResponse = InferenceInferenceEndpointInfoCustom
14031+
1398914032
export interface InferencePutDeepseekRequest extends RequestBase {
1399014033
task_type: InferenceTaskTypeDeepSeek
1399114034
deepseek_inference_id: Id

0 commit comments

Comments
 (0)