Class PutCustomRequest
- All Implemented Interfaces:
JsonpSerializable
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 theinput
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 thetop_n
field available when performing rerank requests.${return_documents}
refers to thereturn_documents
field available when performing rerank requests.
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class co.elastic.clients.elasticsearch._types.RequestBase
RequestBase.AbstractBuilder<BuilderT extends RequestBase.AbstractBuilder<BuilderT>>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final JsonpDeserializer<PutCustomRequest>
Json deserializer forPutCustomRequest
static final Endpoint<PutCustomRequest,
PutCustomResponse, ErrorResponse> Endpoint "inference.put_custom
". -
Method Summary
Modifier and TypeMethodDescriptionThe chunking configuration object.final String
Required - The unique identifier of the inference endpoint.static PutCustomRequest
void
serialize
(jakarta.json.stream.JsonGenerator generator, JsonpMapper mapper) Serialize this object to JSON.protected void
serializeInternal
(jakarta.json.stream.JsonGenerator generator, JsonpMapper mapper) final CustomServiceType
service()
Required - The type of service supported for the specified task type.final CustomServiceSettings
Required - Settings used to install the inference model.protected static void
final CustomTaskSettings
Settings to configure the inference task.final CustomTaskType
taskType()
Required - The type of the inference task that the model will perform.Methods inherited from class co.elastic.clients.elasticsearch._types.RequestBase
toString
-
Field Details
-
_DESERIALIZER
Json deserializer forPutCustomRequest
-
_ENDPOINT
Endpoint "inference.put_custom
".
-
-
Method Details
-
of
public static PutCustomRequest of(Function<PutCustomRequest.Builder, ObjectBuilder<PutCustomRequest>> fn) -
chunkingSettings
The chunking configuration object.API name:
chunking_settings
-
customInferenceId
Required - The unique identifier of the inference endpoint.API name:
custom_inference_id
-
service
Required - The type of service supported for the specified task type. In this case,custom
.API name:
service
-
serviceSettings
Required - Settings used to install the inference model. These settings are specific to thecustom
service.API name:
service_settings
-
taskSettings
Settings to configure the inference task. These settings are specific to the task type you specified.API name:
task_settings
-
taskType
Required - The type of the inference task that the model will perform.API name:
task_type
-
serialize
Serialize this object to JSON.- Specified by:
serialize
in interfaceJsonpSerializable
-
serializeInternal
-
setupPutCustomRequestDeserializer
protected static void setupPutCustomRequestDeserializer(ObjectDeserializer<PutCustomRequest.Builder> op)
-