diff --git a/docs/reference/api-reference.md b/docs/reference/api-reference.md index ed819a820..0b3b01cfc 100644 --- a/docs/reference/api-reference.md +++ b/docs/reference/api-reference.md @@ -7849,6 +7849,31 @@ These settings are specific to the `cohere` service. These settings are specific to the task type you specified. - **`timeout` (Optional, string \| -1 \| 0)**: Specifies the amount of time to wait for the inference endpoint to be created. +## client.inference.putContextualai [_inference.put_contextualai] +Create an Contextual AI inference endpoint. + +Create an inference endpoint to perform an inference task with the `contexualai` service. + +To review the available `rerank` models, refer to . + +[Endpoint documentation](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-contextualai) + +```ts +client.inference.putContextualai({ task_type, contextualai_inference_id, service, service_settings }) +``` + +### Arguments [_arguments_inference.put_contextualai] + +#### Request (object) [_request_inference.put_contextualai] +- **`task_type` (Enum("rerank"))**: The type of the inference task that the model will perform. +- **`contextualai_inference_id` (string)**: The unique identifier of the inference endpoint. +- **`service` (Enum("contextualai"))**: The type of service supported for the specified task type. In this case, `contextualai`. +- **`service_settings` ({ api_key, model_id, rate_limit })**: Settings used to install the inference model. These settings are specific to the `contextualai` service. +- **`chunking_settings` (Optional, { max_chunk_size, overlap, sentence_overlap, separator_group, separators, strategy })**: The chunking configuration object. +- **`task_settings` (Optional, { instruction, return_documents, top_k })**: Settings to configure the inference task. +These settings are specific to the task type you specified. +- **`timeout` (Optional, string \| -1 \| 0)**: Specifies the amount of time to wait for the inference endpoint to be created. + ## client.inference.putCustom [_inference.put_custom] Create a custom inference endpoint. @@ -12347,7 +12372,9 @@ client.security.getSettings({ ... }) If no response is received before the timeout expires, the request fails and returns an error. ## client.security.getStats [_security.get_stats] -Get security statistics for all nodes +Get security stats. + +Gather security usage statistics from all node(s) within the cluster. [Endpoint documentation](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-get-stats) diff --git a/src/api/api/inference.ts b/src/api/api/inference.ts index a15aa20e4..8c0d1b7ce 100644 --- a/src/api/api/inference.ts +++ b/src/api/api/inference.ts @@ -223,6 +223,21 @@ export default class Inference { 'timeout' ] }, + 'inference.put_contextualai': { + path: [ + 'task_type', + 'contextualai_inference_id' + ], + body: [ + 'chunking_settings', + 'service', + 'service_settings', + 'task_settings' + ], + query: [ + 'timeout' + ] + }, 'inference.put_custom': { path: [ 'task_type', @@ -1376,6 +1391,73 @@ export default class Inference { return await this.transport.request({ path, method, querystring, body, meta }, options) } + /** + * Create an Contextual AI inference endpoint. Create an inference endpoint to perform an inference task with the `contexualai` service. To review the available `rerank` models, refer to . + * @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-contextualai | Elasticsearch API documentation} + */ + async putContextualai (this: That, params: T.InferencePutContextualaiRequest, options?: TransportRequestOptionsWithOutMeta): Promise + async putContextualai (this: That, params: T.InferencePutContextualaiRequest, options?: TransportRequestOptionsWithMeta): Promise> + async putContextualai (this: That, params: T.InferencePutContextualaiRequest, options?: TransportRequestOptions): Promise + async putContextualai (this: That, params: T.InferencePutContextualaiRequest, options?: TransportRequestOptions): Promise { + const { + path: acceptedPath, + body: acceptedBody, + query: acceptedQuery + } = this[kAcceptedParams]['inference.put_contextualai'] + + const userQuery = params?.querystring + const querystring: Record = userQuery != null ? { ...userQuery } : {} + + let body: Record | string | undefined + const userBody = params?.body + if (userBody != null) { + if (typeof userBody === 'string') { + body = userBody + } else { + body = { ...userBody } + } + } + + for (const key in params) { + if (acceptedBody.includes(key)) { + body = body ?? {} + // @ts-expect-error + body[key] = params[key] + } else if (acceptedPath.includes(key)) { + continue + } else if (key !== 'body' && key !== 'querystring') { + if (acceptedQuery.includes(key) || commonQueryParams.includes(key)) { + // @ts-expect-error + querystring[key] = params[key] + } else { + body = body ?? {} + // @ts-expect-error + body[key] = params[key] + } + } + } + + const method = 'PUT' + const path = `/_inference/${encodeURIComponent(params.task_type.toString())}/${encodeURIComponent(params.contextualai_inference_id.toString())}` + const meta: TransportRequestMetadata = { + name: 'inference.put_contextualai', + pathParts: { + task_type: params.task_type, + contextualai_inference_id: params.contextualai_inference_id + }, + acceptedParams: [ + 'task_type', + 'contextualai_inference_id', + 'chunking_settings', + 'service', + 'service_settings', + 'task_settings', + 'timeout' + ] + } + return await this.transport.request({ path, method, querystring, body, meta }, options) + } + /** * 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": "" }, "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. * @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-custom | Elasticsearch API documentation} diff --git a/src/api/api/security.ts b/src/api/api/security.ts index 6675abbd2..ba10fe760 100644 --- a/src/api/api/security.ts +++ b/src/api/api/security.ts @@ -2471,13 +2471,13 @@ export default class Security { } /** - * Get security statistics for all nodes + * Get security stats. Gather security usage statistics from all node(s) within the cluster. * @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-get-stats | Elasticsearch API documentation} */ - async getStats (this: That, params?: T.TODO, options?: TransportRequestOptionsWithOutMeta): Promise - async getStats (this: That, params?: T.TODO, options?: TransportRequestOptionsWithMeta): Promise> - async getStats (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise - async getStats (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise { + async getStats (this: That, params?: T.SecurityGetStatsRequest, options?: TransportRequestOptionsWithOutMeta): Promise + async getStats (this: That, params?: T.SecurityGetStatsRequest, options?: TransportRequestOptionsWithMeta): Promise> + async getStats (this: That, params?: T.SecurityGetStatsRequest, options?: TransportRequestOptions): Promise + async getStats (this: That, params?: T.SecurityGetStatsRequest, options?: TransportRequestOptions): Promise { const { path: acceptedPath } = this[kAcceptedParams]['security.get_stats'] @@ -2500,6 +2500,7 @@ export default class Security { if (acceptedPath.includes(key)) { continue } else if (key !== 'body' && key !== 'querystring') { + // @ts-expect-error querystring[key] = params[key] } } diff --git a/src/api/types.ts b/src/api/types.ts index 1db7f01e4..f0b85f962 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -4781,7 +4781,9 @@ export interface TaskFailure { export type TaskId = string export interface TextEmbedding { - model_id: string + /** Model ID is required for all dense_vector fields but + * may be inferred for semantic_text fields */ + model_id?: string model_text: string } @@ -8641,6 +8643,7 @@ export interface MappingSearchAsYouTypeProperty extends MappingCorePropertyBase export interface MappingSemanticTextIndexOptions { dense_vector?: MappingDenseVectorIndexOptions + sparse_vector?: MappingSparseVectorIndexOptions } export interface MappingSemanticTextProperty { @@ -18864,6 +18867,7 @@ export interface IlmPolicy { } export interface IlmRolloverAction { + /** The `max_size` condition has been deprecated in 9.3.0 and `max_primary_shard_size` should be used instead */ max_size?: ByteSize max_primary_shard_size?: ByteSize max_age?: Duration @@ -21999,6 +22003,7 @@ export interface IndicesRolloverRolloverConditions { max_age_millis?: DurationValue min_docs?: long max_docs?: long + /** The `max_size` condition has been deprecated in 9.3.0 and `max_primary_shard_size` should be used instead */ max_size?: ByteSize max_size_bytes?: long min_size?: ByteSize @@ -23043,6 +23048,38 @@ export interface InferenceContentObject { type: string } +export interface InferenceContextualAIServiceSettings { + /** A valid API key for your Contexutual AI account. + * + * IMPORTANT: You need to provide the API key only once, during the inference model creation. + * The get inference endpoint API does not retrieve your API key. + * After creating the inference model, you cannot change the associated API key. + * 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. */ + api_key: string + /** The name of the model to use for the inference task. + * Refer to the Contextual AI documentation for the list of available rerank models. */ + model_id: string + /** This setting helps to minimize the number of rate limit errors returned from Contextual AI. + * The `contextualai` service sets a default number of requests allowed per minute depending on the task type. + * For `rerank`, it is set to `1000`. */ + rate_limit?: InferenceRateLimitSetting +} + +export type InferenceContextualAIServiceType = 'contextualai' + +export interface InferenceContextualAITaskSettings { + /** Instructions for the reranking model. Refer to + * Only for the `rerank` task type. */ + instruction?: string + /** Whether to return the source documents in the response. + * Only for the `rerank` task type. */ + return_documents?: boolean + /** The number of most relevant documents to return. + * If not specified, the reranking results of all documents will be returned. + * Only for the `rerank` task type. */ + top_k?: integer +} + export interface InferenceCustomRequestParams { /** The body structure of the request. It requires passing in the string-escaped result of the JSON format HTTP request body. * For example: @@ -23553,6 +23590,13 @@ export interface InferenceInferenceEndpointInfoCohere extends InferenceInference task_type: InferenceTaskTypeCohere } +export interface InferenceInferenceEndpointInfoContextualAi extends InferenceInferenceEndpoint { + /** The inference Id */ + inference_id: string + /** The task type */ + task_type: InferenceTaskTypeContextualAI +} + export interface InferenceInferenceEndpointInfoCustom extends InferenceInferenceEndpoint { /** The inference Id */ inference_id: string @@ -23851,6 +23895,7 @@ export interface InferenceRateLimitSetting { * * `azureopenai` service and task type `text_embedding`: `1440` * * `azureopenai` service and task type `completion`: `120` * * `cohere` service: `10000` + * * `contextualai` service: `1000` * * `elastic` service and task type `chat_completion`: `240` * * `googleaistudio` service: `360` * * `googlevertexai` service: `30000` @@ -23959,6 +24004,8 @@ export type InferenceTaskTypeAzureOpenAI = 'text_embedding' | 'completion' export type InferenceTaskTypeCohere = 'text_embedding' | 'rerank' | 'completion' +export type InferenceTaskTypeContextualAI = 'rerank' + export type InferenceTaskTypeCustom = 'text_embedding' | 'sparse_embedding' | 'rerank' | 'completion' export type InferenceTaskTypeDeepSeek = 'completion' | 'chat_completion' @@ -24399,6 +24446,30 @@ export interface InferencePutCohereRequest extends RequestBase { export type InferencePutCohereResponse = InferenceInferenceEndpointInfoCohere +export interface InferencePutContextualaiRequest extends RequestBase { + /** The type of the inference task that the model will perform. */ + task_type: InferenceTaskTypeContextualAI + /** The unique identifier of the inference endpoint. */ + contextualai_inference_id: Id + /** Specifies the amount of time to wait for the inference endpoint to be created. */ + timeout?: Duration + /** The chunking configuration object. */ + chunking_settings?: InferenceInferenceChunkingSettings + /** The type of service supported for the specified task type. In this case, `contextualai`. */ + service: InferenceContextualAIServiceType + /** Settings used to install the inference model. These settings are specific to the `contextualai` service. */ + service_settings: InferenceContextualAIServiceSettings + /** Settings to configure the inference task. + * These settings are specific to the task type you specified. */ + task_settings?: InferenceContextualAITaskSettings + /** All values in `body` will be added to the request body. */ + body?: string | { [key: string]: any } & { task_type?: never, contextualai_inference_id?: never, timeout?: never, chunking_settings?: never, service?: never, service_settings?: never, task_settings?: never } + /** All values in `querystring` will be added to the request querystring. */ + querystring?: { [key: string]: any } & { task_type?: never, contextualai_inference_id?: never, timeout?: never, chunking_settings?: never, service?: never, service_settings?: never, task_settings?: never } +} + +export type InferencePutContextualaiResponse = InferenceInferenceEndpointInfoContextualAi + export interface InferencePutCustomRequest extends RequestBase { /** The type of the inference task that the model will perform. */ task_type: InferenceCustomTaskType @@ -33187,6 +33258,11 @@ export interface SecurityManageUserPrivileges { applications: string[] } +export interface SecurityNodeSecurityStats { + /** Role statistics. */ + roles: SecurityRolesStats +} + export interface SecurityRealmInfo { name: Name type: string @@ -33352,6 +33428,11 @@ export interface SecurityRoleTemplateScript { options?: Record } +export interface SecurityRolesStats { + /** Document-level security (DLS) statistics. */ + dls: XpackUsageSecurityRolesDls +} + export interface SecuritySearchAccess { /** The document fields that the owners of the role have read access to. */ field_security?: SecurityFieldSecurity @@ -34194,6 +34275,18 @@ export interface SecurityGetSettingsResponse { 'security-tokens': SecuritySecuritySettings } +export interface SecurityGetStatsRequest extends RequestBase { + /** All values in `body` will be added to the request body. */ + body?: string | { [key: string]: any } + /** All values in `querystring` will be added to the request querystring. */ + querystring?: { [key: string]: any } +} + +export interface SecurityGetStatsResponse { + /** A map of node IDs to security statistics for that node. */ + nodes: Record +} + export type SecurityGetTokenAccessTokenGrantType = 'password' | 'client_credentials' | '_kerberos' | 'refresh_token' export interface SecurityGetTokenAuthenticatedUser extends SecurityUser { @@ -39685,9 +39778,22 @@ export interface XpackUsageSecurityRolesDls { } export interface XpackUsageSecurityRolesDlsBitSetCache { + /** Number of entries in the cache. */ count: integer + /** Human-readable amount of memory taken up by the cache. */ memory?: ByteSize + /** Memory taken up by the cache in bytes. */ memory_in_bytes: ulong + /** Total number of cache hits. */ + hits: long + /** Total number of cache misses. */ + misses: long + /** Total number of cache evictions. */ + evictions: long + /** Total combined time spent in cache for hits in milliseconds. */ + hits_time_in_millis: DurationValue + /** Total combined time spent in cache for misses in milliseconds. */ + misses_time_in_millis: DurationValue } export interface XpackUsageSecurityRolesFile {