Skip to content

Commit 389ce57

Browse files
committed
Adds request params docs.
1 parent ac77396 commit 389ce57

File tree

2 files changed

+208
-0
lines changed

2 files changed

+208
-0
lines changed

specification/inference/_types/CommonTypes.ts

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,136 @@ export class CohereTaskSettings {
758758
truncate?: CohereTruncateType
759759
}
760760

761+
export class CustomServiceSettings {
762+
/**
763+
* Specifies the HTTPS header parameters – such as `Authentication` or `Contet-Type` – that are required to access the custom service.
764+
* For example:
765+
* ```
766+
* "headers":{
767+
* "Authorization": "Bearer ${api_key}",
768+
* "Content-Type": "application/json;charset=utf-8"
769+
* }
770+
* ```
771+
*/
772+
headers?: object
773+
/**
774+
* The request configuration object.
775+
*/
776+
request: CustomRequestParams
777+
/**
778+
* The response configuration object.
779+
*/
780+
response: CustomResponseParams
781+
/**
782+
* Specifies secret parameters, like `api_key` or `api_token`, that are required to access the custom service.
783+
* For example:
784+
* ```
785+
* "secret_parameters":{
786+
* "api_key":"<api_key>"
787+
* }
788+
* ```
789+
*/
790+
secret_parameters: object
791+
/**
792+
* The URL endpoint to use for the requests.
793+
*/
794+
url?: string
795+
}
796+
797+
export class CustomRequestParams {
798+
/**
799+
* The body structure of the request. It requires passing in the string-escaped result of the JSON format HTTP request body.
800+
* For example:
801+
* ```
802+
* "request":{
803+
* "content":"{\"input\":${input}}"
804+
* }
805+
* ```
806+
* > info
807+
* > The content string needs to be a single line except using the Kibana console.
808+
*/
809+
content: string
810+
}
811+
812+
export class CustomResponseParams {
813+
/**
814+
* Specifies the path to the error message in the response from the custom service.
815+
* For example:
816+
* ```
817+
* "response": {
818+
* "error_parser": {
819+
* "path": "$.error.message"
820+
* }
821+
* }
822+
* ```
823+
*/
824+
error_parser: object
825+
/**
826+
* Specifies the JSON parser that is used to parse the response from the custom service.
827+
* Different task types require different json_parser parameters.
828+
* For example:
829+
* ```
830+
* # text_embedding
831+
* "response":{
832+
* "json_parser":{
833+
* "text_embeddings":"$.result.embeddings[*].embedding"
834+
* }
835+
* }
836+
*
837+
* # sparse_embedding
838+
* "response":{
839+
* "json_parser":{
840+
* "token_path":"$.result[*].embeddings[*].token",
841+
* "weight_path":"$.result[*].embeddings[*].weight"
842+
* }
843+
* }
844+
*
845+
* # rerank
846+
* "response":{
847+
* "json_parser":{
848+
* "reranked_index":"$.result.scores[*].index", // optional
849+
* "relevance_score":"$.result.scores[*].score",
850+
* "document_text":"xxx" // optional
851+
* }
852+
* }
853+
*
854+
* # completion
855+
* "response":{
856+
* "json_parser":{
857+
* "completion_result":"$.result.text"
858+
* }
859+
* }
860+
*/
861+
json_parser: object
862+
}
863+
864+
export enum CustomTaskType {
865+
text_embedding,
866+
sparse_embedding,
867+
rerank,
868+
completion
869+
}
870+
871+
export enum CustomServiceType {
872+
custom
873+
}
874+
875+
export class CustomTaskSettings {
876+
/**
877+
* Specifies parameters that are required to run the custom service. The parameters depend on the model your custom service uses.
878+
* For example:
879+
* ```
880+
* "task_settings":{
881+
* "parameters":{
882+
* "input_type":"query",
883+
* "return_token":true
884+
* }
885+
* }
886+
* ```
887+
*/
888+
parameters?: object
889+
}
890+
761891
export class EisServiceSettings {
762892
/**
763893
* The name of the model to use for the inference task.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
CustomServiceSettings,
24+
CustomServiceType,
25+
CustomTaskSettings,
26+
CustomTaskType
27+
} from '@inference/_types/CommonTypes'
28+
import { InferenceChunkingSettings } from '@inference/_types/Services'
29+
30+
/**
31+
* Create a custom inference endpoint.
32+
*
33+
* You can create an inference endpoint to perform an inference task with a custom model that supports the HTTP format.
34+
* @rest_spec_name inference.put_custom
35+
* @availability stack since=8.13.0 stability=stable visibility=public
36+
* @availability serverless stability=stable visibility=public
37+
* @cluster_privileges manage_inference
38+
* @doc_id inference-api-put-custom
39+
*/
40+
export interface Request extends RequestBase {
41+
urls: [
42+
{
43+
path: '/_inference/{task_type}/{custom_inference_id}'
44+
methods: ['PUT']
45+
}
46+
]
47+
path_parts: {
48+
/**
49+
* The type of the inference task that the model will perform.
50+
*/
51+
task_type: CustomTaskType
52+
/**
53+
* The unique identifier of the inference endpoint.
54+
*/
55+
custom_inference_id: Id
56+
}
57+
body: {
58+
/**
59+
* The chunking configuration object.
60+
* @ext_doc_id inference-chunking
61+
*/
62+
chunking_settings?: InferenceChunkingSettings
63+
/**
64+
* The type of service supported for the specified task type. In this case, `custom`.
65+
*/
66+
service: CustomServiceType
67+
/**
68+
* Settings used to install the inference model.
69+
* These settings are specific to the `custom` service.
70+
*/
71+
service_settings: CustomServiceSettings
72+
/**
73+
* Settings to configure the inference task.
74+
* These settings are specific to the task type you specified.
75+
*/
76+
task_settings?: CustomTaskSettings
77+
}
78+
}

0 commit comments

Comments
 (0)