diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index 347d64ef68..71c6e0a4b2 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -17861,6 +17861,92 @@ "x-state": "Added in 9.0.0" } }, + "/_inference/{task_type}/{cohere_inference_id}": { + "put": { + "tags": [ + "inference" + ], + "summary": "Create a Cohere inference endpoint", + "description": "Create an inference endpoint to perform an inference task with the `cohere` service.\n\nWhen you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running.\nAfter creating the endpoint, wait for the model deployment to complete before using it.\nTo verify the deployment status, use the get trained model statistics API.\nLook for `\"state\": \"fully_allocated\"` in the response and ensure that the `\"allocation_count\"` matches the `\"target_allocation_count\"`.\nAvoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources.", + "operationId": "inference-put-cohere", + "parameters": [ + { + "in": "path", + "name": "task_type", + "description": "The type of the inference task that the model will perform.", + "required": true, + "deprecated": false, + "schema": { + "$ref": "#/components/schemas/inference.put_cohere:CohereTaskType" + }, + "style": "simple" + }, + { + "in": "path", + "name": "cohere_inference_id", + "description": "The unique identifier of the inference endpoint.", + "required": true, + "deprecated": false, + "schema": { + "$ref": "#/components/schemas/_types:Id" + }, + "style": "simple" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "chunking_settings": { + "$ref": "#/components/schemas/inference._types:InferenceChunkingSettings" + }, + "service": { + "$ref": "#/components/schemas/inference.put_cohere:ServiceType" + }, + "service_settings": { + "$ref": "#/components/schemas/inference.put_cohere:CohereServiceSettings" + }, + "task_settings": { + "$ref": "#/components/schemas/inference.put_cohere:CohereTaskSettings" + } + }, + "required": [ + "service", + "service_settings" + ] + }, + "examples": { + "PutCohereRequestExample1": { + "summary": "A text embedding task", + "description": "Run `PUT _inference/text_embedding/cohere-embeddings` to create an inference endpoint that performs a text embedding task.", + "value": "{\n \"service\": \"cohere\",\n \"service_settings\": {\n \"api_key\": \"Cohere-Api-key\",\n \"model_id\": \"embed-english-light-v3.0\",\n \"embedding_type\": \"byte\"\n }\n}" + }, + "PutCohereRequestExample2": { + "summary": "A rerank task", + "description": "Run `PUT _inference/rerank/cohere-rerank` to create an inference endpoint that performs a rerank task.", + "value": "{\n \"service\": \"cohere\",\n \"service_settings\": {\n \"api_key\": \"Cohere-API-key\",\n \"model_id\": \"rerank-english-v3.0\"\n },\n \"task_settings\": {\n \"top_n\": 10,\n \"return_documents\": true\n }\n}" + } + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/inference._types:InferenceEndpointInfo" + } + } + } + } + }, + "x-state": "Added in 8.13.0" + } + }, "/_inference/{task_type}/{eis_inference_id}": { "put": { "tags": [ @@ -77417,31 +77503,54 @@ "inference._types:ServiceSettings": { "type": "object" }, - "inference.put_eis:EisTaskType": { + "inference.put_cohere:CohereTaskType": { "type": "string", "enum": [ - "chat_completion" + "completion", + "rerank", + "text_embedding" ] }, - "inference.put_eis:ServiceType": { + "inference.put_cohere:ServiceType": { "type": "string", "enum": [ - "elastic" + "cohere" ] }, - "inference.put_eis:EisServiceSettings": { + "inference.put_cohere:CohereServiceSettings": { "type": "object", "properties": { + "api_key": { + "externalDocs": { + "url": "https://dashboard.cohere.com/api-keys" + }, + "description": "A valid API key for your Cohere account.\nYou can find or create your Cohere API keys on the Cohere API key settings page.\n\nIMPORTANT: You need to provide the API key only once, during the inference model creation.\nThe get inference endpoint API does not retrieve your API key.\nAfter creating the inference model, you cannot change the associated API key.\nIf you want to use a different API key, delete the inference model and recreate it with the same name and the updated API key.", + "type": "string" + }, + "embedding_type": { + "$ref": "#/components/schemas/inference.put_cohere:EmbeddingType" + }, "model_id": { - "description": "The name of the model to use for the inference task.", + "description": "For a `completion`, `rerank`, or `text_embedding` task, the name of the model to use for the inference task.\n\n* For the available `completion` models, refer to the [Cohere command docs](https://docs.cohere.com/docs/models#command).\n* For the available `rerank` models, refer to the [Cohere rerank docs](https://docs.cohere.com/reference/rerank-1).\n* For the available `text_embedding` models, refer to [Cohere embed docs](https://docs.cohere.com/reference/embed).\n\nThe default value for a text embedding task is `embed-english-v2.0`.", "type": "string" }, "rate_limit": { "$ref": "#/components/schemas/inference._types:RateLimitSetting" + }, + "similarity": { + "$ref": "#/components/schemas/inference.put_cohere:SimilarityType" } }, "required": [ - "model_id" + "api_key" + ] + }, + "inference.put_cohere:EmbeddingType": { + "type": "string", + "enum": [ + "byte", + "float", + "int8" ] }, "inference._types:RateLimitSetting": { @@ -77453,6 +77562,77 @@ } } }, + "inference.put_cohere:SimilarityType": { + "type": "string", + "enum": [ + "cosine", + "dot_product", + "l2_norm" + ] + }, + "inference.put_cohere:CohereTaskSettings": { + "type": "object", + "properties": { + "input_type": { + "$ref": "#/components/schemas/inference.put_cohere:InputType" + }, + "return_documents": { + "description": "For a `rerank` task, return doc text within the results.", + "type": "boolean" + }, + "top_n": { + "description": "For a `rerank` task, the number of most relevant documents to return.\nIt defaults to the number of the documents.\nIf this inference endpoint is used in a `text_similarity_reranker` retriever query and `top_n` is set, it must be greater than or equal to `rank_window_size` in the query.", + "type": "number" + }, + "truncate": { + "$ref": "#/components/schemas/inference.put_cohere:TruncateType" + } + } + }, + "inference.put_cohere:InputType": { + "type": "string", + "enum": [ + "classification", + "clustering", + "ingest", + "search" + ] + }, + "inference.put_cohere:TruncateType": { + "type": "string", + "enum": [ + "END", + "NONE", + "START" + ] + }, + "inference.put_eis:EisTaskType": { + "type": "string", + "enum": [ + "chat_completion" + ] + }, + "inference.put_eis:ServiceType": { + "type": "string", + "enum": [ + "elastic" + ] + }, + "inference.put_eis:EisServiceSettings": { + "type": "object", + "properties": { + "model_id": { + "description": "The name of the model to use for the inference task.", + "type": "string" + }, + "rate_limit": { + "$ref": "#/components/schemas/inference._types:RateLimitSetting" + } + }, + "required": [ + "model_id" + ] + }, "inference.put_elser:ElserTaskType": { "type": "string", "enum": [ diff --git a/output/schema/schema.json b/output/schema/schema.json index bed096e8c3..090a9f5f66 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -9352,6 +9352,51 @@ } ] }, + { + "availability": { + "serverless": { + "stability": "stable", + "visibility": "public" + }, + "stack": { + "since": "8.13.0", + "stability": "stable", + "visibility": "public" + } + }, + "description": "Create a Cohere inference endpoint.\n\nCreate an inference endpoint to perform an inference task with the `cohere` service.\n\nWhen you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running.\nAfter creating the endpoint, wait for the model deployment to complete before using it.\nTo verify the deployment status, use the get trained model statistics API.\nLook for `\"state\": \"fully_allocated\"` in the response and ensure that the `\"allocation_count\"` matches the `\"target_allocation_count\"`.\nAvoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources.", + "docId": "inference-api-put-cohere", + "docUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/infer-service-cohere.html", + "name": "inference.put_cohere", + "privileges": { + "cluster": [ + "manage_inference" + ] + }, + "request": { + "name": "Request", + "namespace": "inference.put_cohere" + }, + "requestBodyRequired": false, + "requestMediaType": [ + "application/json" + ], + "response": { + "name": "Response", + "namespace": "inference.put_cohere" + }, + "responseMediaType": [ + "application/json" + ], + "urls": [ + { + "methods": [ + "PUT" + ], + "path": "/_inference/{task_type}/{cohere_inference_id}" + } + ] + }, { "availability": { "serverless": { @@ -150708,6 +150753,378 @@ }, "specLocation": "inference/put/PutResponse.ts#L22-L24" }, + { + "kind": "interface", + "name": { + "name": "CohereServiceSettings", + "namespace": "inference.put_cohere" + }, + "properties": [ + { + "description": "A valid API key for your Cohere account.\nYou can find or create your Cohere API keys on the Cohere API key settings page.\n\nIMPORTANT: You need to provide the API key only once, during the inference model creation.\nThe get inference endpoint API does not retrieve your API key.\nAfter creating the inference model, you cannot change the associated API key.\nIf you want to use a different API key, delete the inference model and recreate it with the same name and the updated API key.", + "extDocId": "cohere-api-keys", + "extDocUrl": "https://dashboard.cohere.com/api-keys", + "name": "api_key", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + } + }, + { + "description": "For a `text_embedding` task, the types of embeddings you want to get back.\nUse `byte` for signed int8 embeddings (this is a synonym of `int8`).\nUse `float` for the default float embeddings.\nUse `int8` for signed int8 embeddings.", + "name": "embedding_type", + "required": false, + "serverDefault": "float", + "type": { + "kind": "instance_of", + "type": { + "name": "EmbeddingType", + "namespace": "inference.put_cohere" + } + } + }, + { + "description": "For a `completion`, `rerank`, or `text_embedding` task, the name of the model to use for the inference task.\n\n* For the available `completion` models, refer to the [Cohere command docs](https://docs.cohere.com/docs/models#command).\n* For the available `rerank` models, refer to the [Cohere rerank docs](https://docs.cohere.com/reference/rerank-1).\n* For the available `text_embedding` models, refer to [Cohere embed docs](https://docs.cohere.com/reference/embed).\n\nThe default value for a text embedding task is `embed-english-v2.0`.", + "name": "model_id", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + } + }, + { + "description": "This setting helps to minimize the number of rate limit errors returned from Cohere.\nBy default, the `cohere` service sets the number of requests allowed per minute to 10000.", + "name": "rate_limit", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "RateLimitSetting", + "namespace": "inference._types" + } + } + }, + { + "description": "The similarity measure.\nIf the `embedding_type` is `float`, the default value is `dot_product`.\nIf the `embedding_type` is `int8` or `byte`, the default value is `cosine`.", + "name": "similarity", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "SimilarityType", + "namespace": "inference.put_cohere" + } + } + } + ], + "specLocation": "inference/put_cohere/PutCohereRequest.ts#L119-L160" + }, + { + "kind": "interface", + "name": { + "name": "CohereTaskSettings", + "namespace": "inference.put_cohere" + }, + "properties": [ + { + "description": "For a `text_embedding` task, the type of input passed to the model.\nValid values are:\n\n* `classification`: Use it for embeddings passed through a text classifier.\n* `clustering`: Use it for the embeddings run through a clustering algorithm.\n* `ingest`: Use it for storing document embeddings in a vector database.\n* `search`: Use it for storing embeddings of search queries run against a vector database to find relevant documents.\n\nIMPORTANT: The `input_type` field is required when using embedding models `v3` and higher.", + "name": "input_type", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "InputType", + "namespace": "inference.put_cohere" + } + } + }, + { + "description": "For a `rerank` task, return doc text within the results.", + "name": "return_documents", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "boolean", + "namespace": "_builtins" + } + } + }, + { + "description": "For a `rerank` task, the number of most relevant documents to return.\nIt defaults to the number of the documents.\nIf this inference endpoint is used in a `text_similarity_reranker` retriever query and `top_n` is set, it must be greater than or equal to `rank_window_size` in the query.", + "name": "top_n", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "integer", + "namespace": "_types" + } + } + }, + { + "description": "For a `text_embedding` task, the method to handle inputs longer than the maximum token length.\nValid values are:\n\n* `END`: When the input exceeds the maximum input token length, the end of the input is discarded.\n* `NONE`: When the input exceeds the maximum input token length, an error is returned.\n* `START`: When the input exceeds the maximum input token length, the start of the input is discarded.", + "name": "truncate", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "TruncateType", + "namespace": "inference.put_cohere" + } + } + } + ], + "specLocation": "inference/put_cohere/PutCohereRequest.ts#L162-L194" + }, + { + "kind": "enum", + "members": [ + { + "name": "completion" + }, + { + "name": "rerank" + }, + { + "name": "text_embedding" + } + ], + "name": { + "name": "CohereTaskType", + "namespace": "inference.put_cohere" + }, + "specLocation": "inference/put_cohere/PutCohereRequest.ts#L84-L88" + }, + { + "kind": "enum", + "members": [ + { + "name": "byte" + }, + { + "name": "float" + }, + { + "name": "int8" + } + ], + "name": { + "name": "EmbeddingType", + "namespace": "inference.put_cohere" + }, + "specLocation": "inference/put_cohere/PutCohereRequest.ts#L94-L98" + }, + { + "kind": "enum", + "members": [ + { + "name": "classification" + }, + { + "name": "clustering" + }, + { + "name": "ingest" + }, + { + "name": "search" + } + ], + "name": { + "name": "InputType", + "namespace": "inference.put_cohere" + }, + "specLocation": "inference/put_cohere/PutCohereRequest.ts#L100-L105" + }, + { + "kind": "request", + "attachedBehaviors": [ + "CommonQueryParameters" + ], + "body": { + "kind": "properties", + "properties": [ + { + "description": "The chunking configuration object.", + "extDocId": "inference-chunking", + "extDocUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/current/inference-apis.html#infer-chunking-config", + "name": "chunking_settings", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "InferenceChunkingSettings", + "namespace": "inference._types" + } + } + }, + { + "description": "The type of service supported for the specified task type. In this case, `cohere`.", + "name": "service", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "ServiceType", + "namespace": "inference.put_cohere" + } + } + }, + { + "description": "Settings used to install the inference model.\nThese settings are specific to the `cohere` service.", + "name": "service_settings", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "CohereServiceSettings", + "namespace": "inference.put_cohere" + } + } + }, + { + "description": "Settings to configure the inference task.\nThese settings are specific to the task type you specified.", + "name": "task_settings", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "CohereTaskSettings", + "namespace": "inference.put_cohere" + } + } + } + ] + }, + "description": "Create a Cohere inference endpoint.\n\nCreate an inference endpoint to perform an inference task with the `cohere` service.\n\nWhen you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running.\nAfter creating the endpoint, wait for the model deployment to complete before using it.\nTo verify the deployment status, use the get trained model statistics API.\nLook for `\"state\": \"fully_allocated\"` in the response and ensure that the `\"allocation_count\"` matches the `\"target_allocation_count\"`.\nAvoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources.", + "examples": { + "PutCohereRequestExample1": { + "description": "Run `PUT _inference/text_embedding/cohere-embeddings` to create an inference endpoint that performs a text embedding task.", + "summary": "A text embedding task", + "value": "{\n \"service\": \"cohere\",\n \"service_settings\": {\n \"api_key\": \"Cohere-Api-key\",\n \"model_id\": \"embed-english-light-v3.0\",\n \"embedding_type\": \"byte\"\n }\n}" + }, + "PutCohereRequestExample2": { + "description": "Run `PUT _inference/rerank/cohere-rerank` to create an inference endpoint that performs a rerank task.", + "summary": "A rerank task", + "value": "{\n \"service\": \"cohere\",\n \"service_settings\": {\n \"api_key\": \"Cohere-API-key\",\n \"model_id\": \"rerank-english-v3.0\"\n },\n \"task_settings\": {\n \"top_n\": 10,\n \"return_documents\": true\n }\n}" + } + }, + "inherits": { + "type": { + "name": "RequestBase", + "namespace": "_types" + } + }, + "name": { + "name": "Request", + "namespace": "inference.put_cohere" + }, + "path": [ + { + "description": "The type of the inference task that the model will perform.", + "name": "task_type", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "CohereTaskType", + "namespace": "inference.put_cohere" + } + } + }, + { + "description": "The unique identifier of the inference endpoint.", + "name": "cohere_inference_id", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "Id", + "namespace": "_types" + } + } + } + ], + "query": [], + "specLocation": "inference/put_cohere/PutCohereRequest.ts#L28-L82" + }, + { + "kind": "response", + "body": { + "kind": "value", + "value": { + "kind": "instance_of", + "type": { + "name": "InferenceEndpointInfo", + "namespace": "inference._types" + } + } + }, + "name": { + "name": "Response", + "namespace": "inference.put_cohere" + }, + "specLocation": "inference/put_cohere/PutCohereResponse.ts#L22-L24" + }, + { + "kind": "enum", + "members": [ + { + "name": "cohere" + } + ], + "name": { + "name": "ServiceType", + "namespace": "inference.put_cohere" + }, + "specLocation": "inference/put_cohere/PutCohereRequest.ts#L90-L92" + }, + { + "kind": "enum", + "members": [ + { + "name": "cosine" + }, + { + "name": "dot_product" + }, + { + "name": "l2_norm" + } + ], + "name": { + "name": "SimilarityType", + "namespace": "inference.put_cohere" + }, + "specLocation": "inference/put_cohere/PutCohereRequest.ts#L107-L111" + }, + { + "kind": "enum", + "members": [ + { + "name": "END" + }, + { + "name": "NONE" + }, + { + "name": "START" + } + ], + "name": { + "name": "TruncateType", + "namespace": "inference.put_cohere" + }, + "specLocation": "inference/put_cohere/PutCohereRequest.ts#L113-L117" + }, { "kind": "interface", "name": { diff --git a/output/typescript/types.ts b/output/typescript/types.ts index ce9788f29f..d44be328ad 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -13252,6 +13252,46 @@ export interface InferencePutRequest extends RequestBase { export type InferencePutResponse = InferenceInferenceEndpointInfo +export interface InferencePutCohereCohereServiceSettings { + api_key: string + embedding_type?: InferencePutCohereEmbeddingType + model_id?: string + rate_limit?: InferenceRateLimitSetting + similarity?: InferencePutCohereSimilarityType +} + +export interface InferencePutCohereCohereTaskSettings { + input_type?: InferencePutCohereInputType + return_documents?: boolean + top_n?: integer + truncate?: InferencePutCohereTruncateType +} + +export type InferencePutCohereCohereTaskType = 'completion' | 'rerank' | 'text_embedding' + +export type InferencePutCohereEmbeddingType = 'byte' | 'float' | 'int8' + +export type InferencePutCohereInputType = 'classification' | 'clustering' | 'ingest' | 'search' + +export interface InferencePutCohereRequest extends RequestBase { + task_type: InferencePutCohereCohereTaskType + cohere_inference_id: Id + body?: { + chunking_settings?: InferenceInferenceChunkingSettings + service: InferencePutCohereServiceType + service_settings: InferencePutCohereCohereServiceSettings + task_settings?: InferencePutCohereCohereTaskSettings + } +} + +export type InferencePutCohereResponse = InferenceInferenceEndpointInfo + +export type InferencePutCohereServiceType = 'cohere' + +export type InferencePutCohereSimilarityType = 'cosine' | 'dot_product' | 'l2_norm' + +export type InferencePutCohereTruncateType = 'END' | 'NONE' | 'START' + export interface InferencePutEisEisServiceSettings { model_id: string rate_limit?: InferenceRateLimitSetting diff --git a/specification/_doc_ids/table.csv b/specification/_doc_ids/table.csv index a61bbb9a21..0e3ad7fc1f 100644 --- a/specification/_doc_ids/table.csv +++ b/specification/_doc_ids/table.csv @@ -94,6 +94,8 @@ cluster-state,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/c cluster-stats,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/cluster-stats.html cluster-update-settings,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/cluster-update-settings.html cluster,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/cluster.html +cohere-api-keys,https://dashboard.cohere.com/api-keys +cohere-models,https://docs.cohere.com/docs/models#command common-options,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/common-options.html community-id-processor,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/community-id-processor.html connector-sync-job-cancel,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/cancel-connector-sync-job-api.html @@ -322,6 +324,7 @@ inference-api-delete,https://www.elastic.co/guide/en/elasticsearch/reference/{br inference-api-get,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/get-inference-api.html inference-api-post,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/post-inference-api.html inference-api-post-eis-chat-completion,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/post-inference-api.html +inference-api-put-cohere,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/infer-service-cohere.html inference-api-put,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/put-inference-api.html inference-api-put-eis,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/infer-service-elastic.html inference-api-put-elser,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/infer-service-elser.html diff --git a/specification/_json_spec/inference.put_cohere.json b/specification/_json_spec/inference.put_cohere.json new file mode 100644 index 0000000000..a00518f2c5 --- /dev/null +++ b/specification/_json_spec/inference.put_cohere.json @@ -0,0 +1,35 @@ +{ + "inference.put_cohere": { + "documentation": { + "url": "https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-service-cohere.html", + "description": "Configure a Cohere inference endpoint" + }, + "stability": "stable", + "visibility": "public", + "headers": { + "accept": ["application/json"], + "content_type": ["application/json"] + }, + "url": { + "paths": [ + { + "path": "/_inference/{task_type}/{cohere_inference_id}", + "methods": ["PUT"], + "parts": { + "task_type": { + "type": "string", + "description": "The task type" + }, + "cohere_inference_id": { + "type": "string", + "description": "The inference Id" + } + } + } + ] + }, + "body": { + "description": "The inference endpoint's task and service settings" + } + } +} diff --git a/specification/inference/put_cohere/PutCohereRequest.ts b/specification/inference/put_cohere/PutCohereRequest.ts new file mode 100644 index 0000000000..f54a4ef19e --- /dev/null +++ b/specification/inference/put_cohere/PutCohereRequest.ts @@ -0,0 +1,194 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { + InferenceChunkingSettings, + RateLimitSetting +} from '@inference/_types/Services' +import { RequestBase } from '@_types/Base' +import { Id } from '@_types/common' +import { integer } from '@_types/Numeric' + +/** + * Create a Cohere inference endpoint. + * + * Create an inference endpoint to perform an inference task with the `cohere` service. + * + * When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + * After creating the endpoint, wait for the model deployment to complete before using it. + * To verify the deployment status, use the get trained model statistics API. + * Look for `"state": "fully_allocated"` in the response and ensure that the `"allocation_count"` matches the `"target_allocation_count"`. + * Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + * @rest_spec_name inference.put_cohere + * @availability stack since=8.13.0 stability=stable visibility=public + * @availability serverless stability=stable visibility=public + * @cluster_privileges manage_inference + * @doc_id inference-api-put-cohere + */ +export interface Request extends RequestBase { + urls: [ + { + path: '/_inference/{task_type}/{cohere_inference_id}' + methods: ['PUT'] + } + ] + path_parts: { + /** + * The type of the inference task that the model will perform. + */ + task_type: CohereTaskType + /** + * The unique identifier of the inference endpoint. + */ + cohere_inference_id: Id + } + body: { + /** + * The chunking configuration object. + * @ext_doc_id inference-chunking + */ + chunking_settings?: InferenceChunkingSettings + /** + * The type of service supported for the specified task type. In this case, `cohere`. + */ + service: ServiceType + /** + * Settings used to install the inference model. + * These settings are specific to the `cohere` service. + */ + service_settings: CohereServiceSettings + /** + * Settings to configure the inference task. + * These settings are specific to the task type you specified. + */ + task_settings?: CohereTaskSettings + } +} + +export enum CohereTaskType { + completion, + rerank, + text_embedding +} + +export enum ServiceType { + cohere +} + +export enum EmbeddingType { + byte, + float, + int8 +} + +export enum InputType { + classification, + clustering, + ingest, + search +} + +export enum SimilarityType { + cosine, + dot_product, + l2_norm +} + +export enum TruncateType { + END, + NONE, + START +} + +export class CohereServiceSettings { + /** + * A valid API key for your Cohere account. + * You can find or create your Cohere API keys on the Cohere API key settings page. + * + * 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. + * @ext_doc_id cohere-api-keys + */ + api_key: string + /** + * For a `text_embedding` task, the types of embeddings you want to get back. + * Use `byte` for signed int8 embeddings (this is a synonym of `int8`). + * Use `float` for the default float embeddings. + * Use `int8` for signed int8 embeddings. + * @server_default float + */ + embedding_type?: EmbeddingType + /** + * For a `completion`, `rerank`, or `text_embedding` task, the name of the model to use for the inference task. + * + * * For the available `completion` models, refer to the [Cohere command docs](https://docs.cohere.com/docs/models#command). + * * For the available `rerank` models, refer to the [Cohere rerank docs](https://docs.cohere.com/reference/rerank-1). + * * For the available `text_embedding` models, refer to [Cohere embed docs](https://docs.cohere.com/reference/embed). + * + * The default value for a text embedding task is `embed-english-v2.0`. + */ + model_id?: string + /** + * This setting helps to minimize the number of rate limit errors returned from Cohere. + * By default, the `cohere` service sets the number of requests allowed per minute to 10000. + */ + rate_limit?: RateLimitSetting + /** + * The similarity measure. + * If the `embedding_type` is `float`, the default value is `dot_product`. + * If the `embedding_type` is `int8` or `byte`, the default value is `cosine`. + */ + similarity?: SimilarityType +} + +export class CohereTaskSettings { + /** + * For a `text_embedding` task, the type of input passed to the model. + * Valid values are: + * + * * `classification`: Use it for embeddings passed through a text classifier. + * * `clustering`: Use it for the embeddings run through a clustering algorithm. + * * `ingest`: Use it for storing document embeddings in a vector database. + * * `search`: Use it for storing embeddings of search queries run against a vector database to find relevant documents. + * + * IMPORTANT: The `input_type` field is required when using embedding models `v3` and higher. + */ + input_type?: InputType + /** + * For a `rerank` task, return doc text within the results. + */ + return_documents?: boolean + /** + * For a `rerank` task, the number of most relevant documents to return. + * It defaults to the number of the documents. + * If this inference endpoint is used in a `text_similarity_reranker` retriever query and `top_n` is set, it must be greater than or equal to `rank_window_size` in the query. + */ + top_n?: integer + /** + * For a `text_embedding` task, the method to handle inputs longer than the maximum token length. + * Valid values are: + * + * * `END`: When the input exceeds the maximum input token length, the end of the input is discarded. + * * `NONE`: When the input exceeds the maximum input token length, an error is returned. + * * `START`: When the input exceeds the maximum input token length, the start of the input is discarded. + */ + truncate?: TruncateType +} diff --git a/specification/inference/put_cohere/PutCohereResponse.ts b/specification/inference/put_cohere/PutCohereResponse.ts new file mode 100644 index 0000000000..d40639b031 --- /dev/null +++ b/specification/inference/put_cohere/PutCohereResponse.ts @@ -0,0 +1,24 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { InferenceEndpointInfo } from '@inference/_types/Services' + +export class Response { + body: InferenceEndpointInfo +} diff --git a/specification/inference/put_cohere/examples/request/PutCohereRequestExample1.yaml b/specification/inference/put_cohere/examples/request/PutCohereRequestExample1.yaml new file mode 100644 index 0000000000..c2cf0070a0 --- /dev/null +++ b/specification/inference/put_cohere/examples/request/PutCohereRequestExample1.yaml @@ -0,0 +1,13 @@ +summary: A text embedding task +description: Run `PUT _inference/text_embedding/cohere-embeddings` to create an inference endpoint that performs a text embedding task. +# method_request: "PUT _inference/text_embedding/cohere-embeddings" +# type: "request" +value: |- + { + "service": "cohere", + "service_settings": { + "api_key": "Cohere-Api-key", + "model_id": "embed-english-light-v3.0", + "embedding_type": "byte" + } + } diff --git a/specification/inference/put_cohere/examples/request/PutCohereRequestExample2.yaml b/specification/inference/put_cohere/examples/request/PutCohereRequestExample2.yaml new file mode 100644 index 0000000000..f758cf6a1d --- /dev/null +++ b/specification/inference/put_cohere/examples/request/PutCohereRequestExample2.yaml @@ -0,0 +1,16 @@ +summary: A rerank task +description: Run `PUT _inference/rerank/cohere-rerank` to create an inference endpoint that performs a rerank task. +# method_request: "PUT _inference/rerank/cohere-rerank" +# type: "request" +value: |- + { + "service": "cohere", + "service_settings": { + "api_key": "Cohere-API-key", + "model_id": "rerank-english-v3.0" + }, + "task_settings": { + "top_n": 10, + "return_documents": true + } + }