-
Notifications
You must be signed in to change notification settings - Fork 115
Adds custom inference service API docs #4852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
65cb119
ac77396
389ce57
a9a560e
3c4eb3f
3d90b42
bc66328
1b3fe33
fab50c4
e185149
859713d
8051083
61c6a98
e0963ae
bd8ec2b
d568234
b4c99e6
9dfe0ef
3961f12
a0baab6
d63c4d7
294a143
52c19aa
f45f46f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -768,6 +768,38 @@ export class CustomServiceSettings { | |
| * ``` | ||
| */ | ||
| headers?: UserDefinedValue | ||
| /** | ||
| * Specifies the input type translation values that are used to replace the `${input_type}` template in the request body. | ||
| * For example: | ||
| * ``` | ||
| * "input_type": { | ||
| * "translation": { | ||
| * "ingest": "do_ingest", | ||
| * "search": "do_search" | ||
| * }, | ||
| * "default": "a_default" | ||
| * }, | ||
| * ``` | ||
| * If the subsequent inference requests come from a search context, the `search` key will be used and the template will be replaced with `do_search`. | ||
| * If it comes from the ingest context `do_ingest` is used. If it's a different context that is not specified, the default value will be used. If no default is specified an empty string is used. | ||
| * `transition` can be: | ||
| * * `classification` | ||
| * * `clustering` | ||
| * * `ingest` | ||
| * * `search` | ||
| */ | ||
| input_type?: UserDefinedValue | ||
| /** | ||
| * Specifies the query parameters as a list of tuples. The arrays inside the `query_parameters` must have two items, a key and a value. | ||
| * For example: | ||
| * ``` | ||
szabosteve marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * "query_parameters":[ | ||
| * ["param_key", "some_value"], | ||
| * ["param_key", "another_value"] | ||
| * ] | ||
| * ``` | ||
| */ | ||
| query_parameters?: UserDefinedValue | ||
| /** | ||
| * The request configuration object. | ||
| */ | ||
|
|
@@ -797,9 +829,7 @@ export class CustomRequestParams { | |
| * The body structure of the request. It requires passing in the string-escaped result of the JSON format HTTP request body. | ||
| * For example: | ||
| * ``` | ||
| * "request":{ | ||
| * "content":"{\"input\":${input}}" | ||
| * } | ||
| * "request": "{\"input\":${input}}" | ||
| * ``` | ||
| * > info | ||
| * > The content string needs to be a single line except using the Kibana console. | ||
szabosteve marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
@@ -808,39 +838,103 @@ export class CustomRequestParams { | |
| } | ||
|
|
||
| export class CustomResponseParams { | ||
| /** | ||
| * Specifies the path to the error message in the response from the custom service. | ||
| * For example: | ||
| * ``` | ||
| * "response": { | ||
| * "error_parser": { | ||
| * "path": "$.error.message" | ||
| * } | ||
| * } | ||
| * ``` | ||
| */ | ||
| error_parser: UserDefinedValue | ||
| /** | ||
| * 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: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jonathan-buttner Do you think we should specify a JsonParser class for each task type, or is this list sufficient?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm I think it might be better if we give an example of the response structure for each task type and explain how to create the parser from that. We should also say that the format is a less featured version of JSONPath: https://en.wikipedia.org/wiki/JSONPath Here are some examples: Text EmbeddingsFor a response that looks like: We'd need this definition: RerankFor a response that looks like: We'd need this definition:
CompletionFor a response that looks like: We'd need this definition: Sparse embeddingFor a response that looks like: We'd need this definition: If the |
||
| * ``` | ||
| * # 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":"$.result.embeddings[*].embedding" | ||
| * "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[*].embeddings[*].token", | ||
| * "weight_path":"$.result[*].embeddings[*].weight" | ||
| * "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 | ||
|
|
@@ -850,9 +944,33 @@ export class CustomResponseParams { | |
| * } | ||
| * | ||
| * # 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":"$.result.text" | ||
| * "completion_result":"$.choices[*].message.content" | ||
| * } | ||
| * } | ||
| */ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.