Class CustomResponseParams.Builder
java.lang.Object
co.elastic.clients.util.ObjectBuilderBase
co.elastic.clients.util.WithJsonObjectBuilderBase<CustomResponseParams.Builder>
co.elastic.clients.elasticsearch.inference.CustomResponseParams.Builder
- All Implemented Interfaces:
WithJson<CustomResponseParams.Builder>
,ObjectBuilder<CustomResponseParams>
- Enclosing class:
- CustomResponseParams
public static class CustomResponseParams.Builder
extends WithJsonObjectBuilderBase<CustomResponseParams.Builder>
implements ObjectBuilder<CustomResponseParams>
Builder for
CustomResponseParams
.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds aCustomResponseParams
.jsonParser
(JsonData value) Required - Specifies the JSON parser that is used to parse the response from the custom service.protected CustomResponseParams.Builder
self()
Methods inherited from class co.elastic.clients.util.WithJsonObjectBuilderBase
withJson
Methods inherited from class co.elastic.clients.util.ObjectBuilderBase
_checkSingleUse, _listAdd, _listAddAll, _mapPut, _mapPutAll
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
jsonParser
Required - Specifies the JSON parser that is used to parse the response from the custom service. Different task types require different json_parser parameters. For example:# text_embedding # For a response like this: { "object": "list", "data": [ { "object": "embedding", "index": 0, "embedding": [ 0.014539449, -0.015288644 ] } ], "model": "text-embedding-ada-002-v2", "usage": { "prompt_tokens": 8, "total_tokens": 8 } } # the json_parser definition should look like this: "response":{ "json_parser":{ "text_embeddings":"$.data[*].embedding[*]" } } # sparse_embedding # For a response like this: { "request_id": "75C50B5B-E79E-4930-****-F48DBB392231", "latency": 22, "usage": { "token_count": 11 }, "result": { "sparse_embeddings": [ { "index": 0, "embedding": [ { "token_id": 6, "weight": 0.101 }, { "token_id": 163040, "weight": 0.28417 } ] } ] } } # the json_parser definition should look like this: "response":{ "json_parser":{ "token_path":"$.result.sparse_embeddings[*].embedding[*].token_id", "weight_path":"$.result.sparse_embeddings[*].embedding[*].weight" } } # rerank # For a response like this: { "results": [ { "index": 3, "relevance_score": 0.999071, "document": "abc" }, { "index": 4, "relevance_score": 0.7867867, "document": "123" }, { "index": 0, "relevance_score": 0.32713068, "document": "super" } ], } # the json_parser definition should look like this: "response":{ "json_parser":{ "reranked_index":"$.result.scores[*].index", // optional "relevance_score":"$.result.scores[*].score", "document_text":"xxx" // optional } } # completion # For a response like this: { "id": "chatcmpl-B9MBs8CjcvOU2jLn4n570S5qMJKcT", "object": "chat.completion", "created": 1741569952, "model": "gpt-4.1-2025-04-14", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Hello! How can I assist you today?", "refusal": null, "annotations": [] }, "logprobs": null, "finish_reason": "stop" } ] } # the json_parser definition should look like this: "response":{ "json_parser":{ "completion_result":"$.choices[*].message.content" } } API name:
json_parser
-
self
- Specified by:
self
in classWithJsonObjectBuilderBase<CustomResponseParams.Builder>
-
build
Builds aCustomResponseParams
.- Specified by:
build
in interfaceObjectBuilder<CustomResponseParams>
- Throws:
NullPointerException
- if some of the required fields are null.
-