Skip to content

Commit 3efe64f

Browse files
maxhniebergallMax Hniebergall
authored andcommitted
[Inference API] Add unified api for chat completions (elastic#117589)
* Adding some shell classes * modeling the request objects * Writeable changes to schema * Working parsing tests * Creating a new action * Add outbound request writing (WIP) * Improvements to request serialization * Adding separate transport classes * separate out unified request and combine inputs * Reworking unified inputs * Adding unsupported operation calls * Fixing parsing logic * get the build working * Update docs/changelog/117589.yaml * Fixing injection issue * Allowing model to be overridden but not working yet * Fixing issues * Switch field name for tool * Add suport for toolCalls and refusal in streaming completion * Working tool call response * Separate unified and legacy code paths * Updated the parser, but there are some class cast exceptions to fix * Refactoring tests and request entities * Parse response from OpenAI * Removing unused request classes * precommit * Adding tests for UnifiedCompletionAction Request * Refactoring stop to be a list of strings * Testing for OpenAI response parsing * Refactoring transport action tests to test unified validation code * Fixing various tests * Fixing license header * Reformat streaming results * Finalize response format * remove debug logs * remove changes for debugging * Task type and base inference action tests * Adding openai service tests * Adding model tests * tests for StreamingUnifiedChatCompletionResultsTests toXContentChunked * Fixing change log and removing commented out code * Switch usage to accept null * Adding test for TestStreamingCompletionServiceExtension * Avoid serializing empty lists + request entity tests * Register named writeables from UnifiedCompletionRequest * Removing commented code * Clean up and add more of an explination * remove duplicate test * remove old todos * Refactoring some duplication * Adding javadoc * Addressing feedback --------- Co-authored-by: Jonathan Buttner <[email protected]> Co-authored-by: Jonathan Buttner <[email protected]> (cherry picked from commit 467fdb8) # Conflicts: # x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferenceCrudIT.java # x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportInferenceAction.java # x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/common/DelegatingProcessor.java # x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/TransportInferenceActionTests.java
1 parent cc061c3 commit 3efe64f

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
package org.elasticsearch.xpack.inference.action;
9+
10+
import org.elasticsearch.action.support.ActionFilters;
11+
import org.elasticsearch.inference.InferenceServiceRegistry;
12+
import org.elasticsearch.transport.TransportService;
13+
import org.elasticsearch.xpack.core.inference.action.InferenceAction;
14+
import org.elasticsearch.xpack.inference.action.task.StreamingTaskManager;
15+
import org.elasticsearch.xpack.inference.registry.ModelRegistry;
16+
import org.elasticsearch.xpack.inference.telemetry.InferenceStats;
17+
18+
import static org.mockito.Mockito.mock;
19+
20+
public class TransportInferenceActionTests extends BaseTransportInferenceActionTestCase<InferenceAction.Request> {
21+
22+
@Override
23+
protected BaseTransportInferenceAction<InferenceAction.Request> createAction(
24+
TransportService transportService,
25+
ActionFilters actionFilters,
26+
ModelRegistry modelRegistry,
27+
InferenceServiceRegistry serviceRegistry,
28+
InferenceStats inferenceStats,
29+
StreamingTaskManager streamingTaskManager
30+
) {
31+
return new TransportInferenceAction(
32+
transportService,
33+
actionFilters,
34+
modelRegistry,
35+
serviceRegistry,
36+
inferenceStats,
37+
streamingTaskManager
38+
);
39+
}
40+
41+
@Override
42+
protected InferenceAction.Request createRequest() {
43+
return mock();
44+
}
45+
}

0 commit comments

Comments
 (0)