Commit 69c5ff6
authored
[Inference API] Support multimodal inputs for chat completion (#142736)
This commit allows "image_url" and "file" to be specified as types of
"content" in chat completion requests for ElasticInferenceService. The
specification matches the OpenAI specification for multimodal chat
completion inputs.
Other services will throw an UnsupportedOperationException if they
receive a chat completion request with multimodal inputs.
Content objects with the type "image_url" are specified as:
{
"type": "image_url",
"image_url": {
"url": "base64 encoded image data or URL (if supported)",
"detail": "optional detail value"
}
}
Content objects with the type "file" are specified as:
{
"type": "file",
"file": {
"file_data": "base64 encoded file data",
"filename": "file name"
}
}
Support for the "file_id" field in the "file" object is not added in
this commit.
When sending the chat completion request to the Elastic Inference
Service, the same OpenAI-compatible schema is used as when sending the
request to the inference API, so no additional translation logic between
the two is needed.
Other changes in this commit:
- Convert ContentObject class to an abstract class which is extended by
ContentObjectText, ContentObjectImage and ContentObjectFile
- Modify serialization for ContentObject to throw an exception if
attempting to send non-text content to an older version node
- Add backward compatibility tests for the above serialization change
- Require that "type" is one of "text", "image_url" or "file" for
"content" objects. Previously any arbitrary value was allowed.
- Update existing tests to use ContentObjectText
- Add tests for default behaviour of embedding task and unified chat
completion with multimodal inputs to SenderServiceTests1 parent 8492b41 commit 69c5ff6
File tree
19 files changed
+1144
-117
lines changed- docs/changelog
- server/src/main
- java/org/elasticsearch/inference
- resources/transport
- definitions/referable
- upper_bounds
- x-pack/plugin
- core/src/test/java/org/elasticsearch/xpack/core/inference/action
- inference/src
- main/java/org/elasticsearch/xpack/inference/services
- amazonbedrock/request/completion
- elastic
- googlevertexai/request/completion
- sagemaker
- test/java/org/elasticsearch/xpack/inference
- action
- external/unified
- services
- amazonbedrock/request/completion
- elastic
- googlevertexai/request/completion
- sagemaker
19 files changed
+1144
-117
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 427 additions & 22 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
Lines changed: 50 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| 22 | + | |
20 | 23 | | |
| 24 | + | |
21 | 25 | | |
| 26 | + | |
| 27 | + | |
22 | 28 | | |
23 | 29 | | |
24 | 30 | | |
| |||
70 | 76 | | |
71 | 77 | | |
72 | 78 | | |
| 79 | + | |
73 | 80 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
| 81 | + | |
81 | 82 | | |
82 | 83 | | |
83 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
84 | 126 | | |
85 | 127 | | |
86 | 128 | | |
| |||
0 commit comments