Skip to content

Commit fc173ff

Browse files
Merge branch 'ml-inference-unified-api-elastic' of github.com:elastic/elasticsearch into ml-inference-unified-api-elastic
2 parents a9b44b5 + e2ed5cc commit fc173ff

File tree

2 files changed

+2
-79
lines changed

2 files changed

+2
-79
lines changed

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/inference/results/StreamingUnifiedChatCompletionResultsTests.java

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -101,83 +101,6 @@ public void testResults_toXContentChunked() throws IOException {
101101
assertEquals(expected.replaceAll("\\s+", ""), Strings.toString(builder.prettyPrint()).trim());
102102
}
103103

104-
public void testChatCompletionChunkToXContentChunked() throws IOException {
105-
String expected = """
106-
{
107-
"id": "chunk1",
108-
"choices": [
109-
{
110-
"delta": {
111-
"content": "example_content",
112-
"refusal": "example_refusal",
113-
"role": "assistant",
114-
"tool_calls": [
115-
{
116-
"index": 1,
117-
"id": "tool1",
118-
"function": {
119-
"arguments": "example_arguments",
120-
"name": "example_function"
121-
},
122-
"type": "function"
123-
}
124-
]
125-
},
126-
"finish_reason": "example_reason",
127-
"index": 0
128-
}
129-
],
130-
"model": "example_model",
131-
"object": "example_object",
132-
"usage": {
133-
"completion_tokens": 10,
134-
"prompt_tokens": 5,
135-
"total_tokens": 15
136-
}
137-
}
138-
""";
139-
140-
StreamingUnifiedChatCompletionResults.ChatCompletionChunk chunk = new StreamingUnifiedChatCompletionResults.ChatCompletionChunk(
141-
"chunk1",
142-
List.of(
143-
new StreamingUnifiedChatCompletionResults.ChatCompletionChunk.Choice(
144-
new StreamingUnifiedChatCompletionResults.ChatCompletionChunk.Choice.Delta(
145-
"example_content",
146-
"example_refusal",
147-
"assistant",
148-
List.of(
149-
new StreamingUnifiedChatCompletionResults.ChatCompletionChunk.Choice.Delta.ToolCall(
150-
1,
151-
"tool1",
152-
new StreamingUnifiedChatCompletionResults.ChatCompletionChunk.Choice.Delta.ToolCall.Function(
153-
"example_arguments",
154-
"example_function"
155-
),
156-
"function"
157-
)
158-
)
159-
),
160-
"example_reason",
161-
0
162-
)
163-
),
164-
"example_model",
165-
"example_object",
166-
new StreamingUnifiedChatCompletionResults.ChatCompletionChunk.Usage(10, 5, 15)
167-
);
168-
169-
XContentBuilder builder = JsonXContent.contentBuilder();
170-
chunk.toXContentChunked(null).forEachRemaining(xContent -> {
171-
try {
172-
xContent.toXContent(builder, null);
173-
} catch (IOException e) {
174-
throw new RuntimeException(e);
175-
}
176-
});
177-
178-
assertEquals(expected.replaceAll("\\s+", ""), Strings.toString(builder.prettyPrint()).trim());
179-
}
180-
181104
public void testChoiceToXContentChunked() throws IOException {
182105
String expected = """
183106
{

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/openai/OpenAiUnifiedChatCompletionRequestEntityTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,10 @@ public void testSerializationWithEmptyLists() throws IOException {
269269
messageList,
270270
null, // model
271271
null, // maxCompletionTokens
272-
Collections.emptyList(), // empty stop list TODO when passing an empty stop-list, should it be converted to null?
272+
Collections.emptyList(), // empty stop list
273273
null, // temperature
274274
null, // toolChoice
275-
Collections.emptyList(), // empty tools list TODO when passing an empty tools-list, should it be converted to null?
275+
Collections.emptyList(), // empty tools list
276276
null // topP
277277
);
278278

0 commit comments

Comments
 (0)