Skip to content

Commit 2a026e0

Browse files
committed
[ML] Add DeepSeek
Create put request types, objects, and examples for DeepSeek. Verified with `make validate api=inference.put`.
1 parent 94d24c5 commit 2a026e0

File tree

11 files changed

+671
-76
lines changed

11 files changed

+671
-76
lines changed

output/schema/schema.json

Lines changed: 333 additions & 76 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/typescript/types.ts

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specification/_doc_ids/table.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ inference-api-put-anthropic,https://www.elastic.co/docs/api/doc/elasticsearch/op
354354
inference-api-put-azureaistudio,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-azureaistudio,https://www.elastic.co/guide/en/elasticsearch/reference/8.18/infer-service-azure-ai-studio.html
355355
inference-api-put-azureopenai,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-azureopenai,https://www.elastic.co/guide/en/elasticsearch/reference/8.18/infer-service-azure-openai.html
356356
inference-api-put-cohere,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-cohere,https://www.elastic.co/guide/en/elasticsearch/reference/8.18/infer-service-cohere.html
357+
inference-api-put-deepseek,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-deepseek,https://www.elastic.co/guide/en/elasticsearch/reference/8.18/infer-service-deepseek.html
357358
inference-api-put-eis,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-eis,
358359
inference-api-put-elasticsearch,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-elasticsearch,https://www.elastic.co/guide/en/elasticsearch/reference/8.18/infer-service-elasticsearch.html
359360
inference-api-put-elser,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-elser,https://www.elastic.co/guide/en/elasticsearch/reference/8.18/infer-service-elser.html

specification/inference/_types/CommonTypes.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,39 @@ export class EisServiceSettings {
770770
rate_limit?: RateLimitSetting
771771
}
772772

773+
export class DeepSeekServiceSettings {
774+
/**
775+
* A valid API key for your DeepSeek account.
776+
* You can find or create your DeepSeek API keys on the DeepSeek API key page.
777+
*
778+
* IMPORTANT: You need to provide the API key only once, during the inference model creation.
779+
* The get inference endpoint API does not retrieve your API key.
780+
* After creating the inference model, you cannot change the associated API key.
781+
* 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.
782+
* @ext_doc_id deepseek-api-keys
783+
*/
784+
api_key: string
785+
/**
786+
* For a `completion` or `chat_completion` task, the name of the model to use for the inference task.
787+
*
788+
* * For the available `completion` and `chat_completion` models, refer to the [DeepSeek Models & Pricing docs](https://api-docs.deepseek.com/quick_start/pricing).
789+
*/
790+
model_id: string
791+
/**
792+
* The URL endpoint to use for the requests. Defaults to `https://api.deepseek.com/chat/completions`.
793+
*/
794+
url?: string
795+
}
796+
797+
export enum DeepSeekTaskType {
798+
completion,
799+
chat_completion
800+
}
801+
802+
export enum DeepSeekServiceType {
803+
deepseek
804+
}
805+
773806
export enum EisTaskType {
774807
chat_completion
775808
}

specification/inference/_types/Services.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
TaskTypeAzureAIStudio,
2828
TaskTypeAzureOpenAI,
2929
TaskTypeCohere,
30+
TaskTypeDeepSeek,
3031
TaskTypeElasticsearch,
3132
TaskTypeELSER,
3233
TaskTypeGoogleAIStudio,
@@ -152,6 +153,17 @@ export class InferenceEndpointInfoCohere extends InferenceEndpoint {
152153
task_type: TaskTypeCohere
153154
}
154155

156+
export class InferenceEndpointInfoDeepSeek extends InferenceEndpoint {
157+
/**
158+
* The inference Id
159+
*/
160+
inference_id: string
161+
/**
162+
* The task type
163+
*/
164+
task_type: TaskTypeDeepSeek
165+
}
166+
155167
export class InferenceEndpointInfoElasticsearch extends InferenceEndpoint {
156168
/**
157169
* The inference Id

specification/inference/_types/TaskType.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ export enum TaskTypeCohere {
6565
completion
6666
}
6767

68+
export enum TaskTypeDeepSeek {
69+
completion,
70+
chat_completion
71+
}
72+
6873
export enum TaskTypeElasticsearch {
6974
sparse_embedding,
7075
text_embedding,

specification/inference/put/PutRequest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { TaskType } from '@inference/_types/TaskType'
3636
* * Azure AI Studio (`completion`, `text_embedding`)
3737
* * Azure OpenAI (`completion`, `text_embedding`)
3838
* * Cohere (`completion`, `rerank`, `text_embedding`)
39+
* * DeepSeek (`completion`, `chat_completion`)
3940
* * Elasticsearch (`rerank`, `sparse_embedding`, `text_embedding` - this service is for built-in models and models uploaded through Eland)
4041
* * ELSER (`sparse_embedding`)
4142
* * Google AI Studio (`completion`, `text_embedding`)
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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 {
23+
DeepSeekServiceSettings,
24+
DeepSeekServiceType,
25+
DeepSeekTaskType
26+
} from '@inference/_types/CommonTypes'
27+
import { InferenceChunkingSettings } from '@inference/_types/Services'
28+
29+
/**
30+
* Create a DeepSeek inference endpoint.
31+
*
32+
* Create an inference endpoint to perform an inference task with the `deepseek` service.
33+
* @rest_spec_name inference.put_deepseek
34+
* @availability stack since=9.1.0 stability=stable visibility=public
35+
* @availability serverless stability=stable visibility=public
36+
* @cluster_privileges manage_inference
37+
* @doc_id inference-api-put-deepseek
38+
*/
39+
export interface Request extends RequestBase {
40+
urls: [
41+
{
42+
path: '/_inference/{task_type}/{deepseek_inference_id}'
43+
methods: ['PUT']
44+
}
45+
]
46+
path_parts: {
47+
/**
48+
* The type of the inference task that the model will perform.
49+
*/
50+
task_type: DeepSeekTaskType
51+
/**
52+
* The unique identifier of the inference endpoint.
53+
*/
54+
deepseek_inference_id: Id
55+
}
56+
body: {
57+
/**
58+
* The chunking configuration object.
59+
* @ext_doc_id inference-chunking
60+
*/
61+
chunking_settings?: InferenceChunkingSettings
62+
/**
63+
* The type of service supported for the specified task type. In this case, `deepseek`.
64+
*/
65+
service: DeepSeekServiceType
66+
/**
67+
* Settings used to install the inference model.
68+
* These settings are specific to the `deepseek` service.
69+
*/
70+
service_settings: DeepSeekServiceSettings
71+
}
72+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 { InferenceEndpointInfoDeepSeek } from '@inference/_types/Services'
21+
22+
export class Response {
23+
/** @codegen_name endpoint_info */
24+
body: InferenceEndpointInfoDeepSeek
25+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
summary: A completion task
2+
description: Run `PUT _inference/completion/deepseek-completion` to create an inference endpoint that performs a completion task.
3+
method_request: 'PUT _inference/completion/deepseek-completion'
4+
# type: "request"
5+
value: |-
6+
{
7+
"service": "deepseek",
8+
"service_settings": {
9+
"api_key": "DeepSeek-Api-key",
10+
"model_id": "deepseek-chat"
11+
}
12+
}
13+
alternatives:
14+
- language: Python
15+
code: |-
16+
resp = client.inference.put(
17+
task_type="completion",
18+
inference_id="deepseek-completion",
19+
inference_config={
20+
"service": "deepseek",
21+
"service_settings": {
22+
"api_key": "DeepSeek-Api-key",
23+
"model_id": "deepseek-chat"
24+
}
25+
},
26+
)
27+
- language: JavaScript
28+
code: |-
29+
const response = await client.inference.put({
30+
task_type: "completion",
31+
inference_id: "deepseek-completion",
32+
inference_config: {
33+
service: "deepseek",
34+
service_settings: {
35+
api_key: "DeepSeek-Api-key",
36+
model_id: "deepseek-chat"
37+
},
38+
},
39+
});
40+
- language: Ruby
41+
code: |-
42+
response = client.inference.put(
43+
task_type: "completion",
44+
inference_id: "deepseek-completion",
45+
body: {
46+
"service": "deepseek",
47+
"service_settings": {
48+
"api_key": "DeepSeek-Api-key",
49+
"model_id": "deepseek-chat"
50+
}
51+
}
52+
)
53+
- language: PHP
54+
code: |-
55+
$resp = $client->inference()->put([
56+
"task_type" => "completion",
57+
"inference_id" => "deepseek-completion",
58+
"body" => [
59+
"service" => "deepseek",
60+
"service_settings" => [
61+
"api_key" => "DeepSeek-Api-key",
62+
"model_id" => "deepseek-chat"
63+
],
64+
],
65+
]);
66+
- language: curl
67+
code:
68+
"curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d
69+
'{\"service\":\"deepseek\",\"service_settings\":{\"api_key\":\"DeepSeek-Api-key\",\"model_id\":\"deepseek-chat\"
70+
}' \"$ELASTICSEARCH_URL/_inference/completion/deepseek-completion\""
71+
- language: Java
72+
code: >
73+
client.inference().put(p -> p
74+
.inferenceId("deepseek-completion")
75+
.taskType(TaskType.Completion)
76+
.inferenceConfig(i -> i
77+
.service("deepseek")
78+
.serviceSettings(JsonData.fromJson("{\"api_key\":\"DeepSeek-Api-key\",\"model_id\":\"deepseek-chat\"}"))
79+
)
80+
);

0 commit comments

Comments
 (0)