Code cleanup
- Fix javadoc for Qdrant vector store - Fix checkstyle errors
This commit is contained in:
@@ -698,8 +698,10 @@ public class OpenAiApi {
|
||||
public enum OutputModality {
|
||||
|
||||
// @formatter:off
|
||||
@JsonProperty("audio") AUDIO,
|
||||
@JsonProperty("text") TEXT;
|
||||
@JsonProperty("audio")
|
||||
AUDIO,
|
||||
@JsonProperty("text")
|
||||
TEXT
|
||||
// @formatter:on
|
||||
|
||||
}
|
||||
@@ -936,23 +938,34 @@ public class OpenAiApi {
|
||||
* Specifies the voice type.
|
||||
*/
|
||||
public enum Voice {
|
||||
@JsonProperty("alloy") ALLOY,
|
||||
@JsonProperty("echo") ECHO,
|
||||
@JsonProperty("fable") FABLE,
|
||||
@JsonProperty("onyx") ONYX,
|
||||
@JsonProperty("nova") NOVA,
|
||||
@JsonProperty("shimmer") SHIMMER;
|
||||
@JsonProperty("alloy")
|
||||
ALLOY,
|
||||
@JsonProperty("echo")
|
||||
ECHO,
|
||||
@JsonProperty("fable")
|
||||
FABLE,
|
||||
@JsonProperty("onyx")
|
||||
ONYX,
|
||||
@JsonProperty("nova")
|
||||
NOVA,
|
||||
@JsonProperty("shimmer")
|
||||
SHIMMER
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the output audio format.
|
||||
*/
|
||||
public enum AudioResponseFormat {
|
||||
@JsonProperty("mp3") MP3,
|
||||
@JsonProperty("flac") FLAC,
|
||||
@JsonProperty("opus") OPUS,
|
||||
@JsonProperty("pcm16") PCM16,
|
||||
@JsonProperty("wav") WAV;
|
||||
@JsonProperty("mp3")
|
||||
MP3,
|
||||
@JsonProperty("flac")
|
||||
FLAC,
|
||||
@JsonProperty("opus")
|
||||
OPUS,
|
||||
@JsonProperty("pcm16")
|
||||
PCM16,
|
||||
@JsonProperty("wav")
|
||||
WAV
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1069,23 +1082,7 @@ public class OpenAiApi {
|
||||
@JsonProperty("type") String type,
|
||||
@JsonProperty("text") String text,
|
||||
@JsonProperty("image_url") ImageUrl imageUrl,
|
||||
@JsonProperty("input_audio") InputAudio inputAudio) {// @formatter:on
|
||||
|
||||
/**
|
||||
* @param data Base64 encoded audio data.
|
||||
* @param format The format of the encoded audio data. Currently supports
|
||||
* "wav" and "mp3".
|
||||
*/
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
public record InputAudio(// @formatter:off
|
||||
@JsonProperty("data") String data,
|
||||
@JsonProperty("format") Format format) {
|
||||
|
||||
public enum Format {
|
||||
@JsonProperty("mp3") MP3,
|
||||
@JsonProperty("wav") WAV;
|
||||
}// @formatter:on
|
||||
}
|
||||
@JsonProperty("input_audio") InputAudio inputAudio) { // @formatter:on
|
||||
|
||||
/**
|
||||
* Shortcut constructor for a text content.
|
||||
@@ -1111,6 +1108,24 @@ public class OpenAiApi {
|
||||
this("input_audio", null, null, inputAudio);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param data Base64 encoded audio data.
|
||||
* @param format The format of the encoded audio data. Currently supports
|
||||
* "wav" and "mp3".
|
||||
*/
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
public record InputAudio(// @formatter:off
|
||||
@JsonProperty("data") String data,
|
||||
@JsonProperty("format") Format format) {
|
||||
|
||||
public enum Format {
|
||||
@JsonProperty("mp3")
|
||||
MP3,
|
||||
@JsonProperty("wav")
|
||||
WAV
|
||||
} // @formatter:on
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut constructor for an image content.
|
||||
*
|
||||
@@ -1182,7 +1197,7 @@ public class OpenAiApi {
|
||||
@JsonProperty("data") String data,
|
||||
@JsonProperty("expires_at") Long expiresAt,
|
||||
@JsonProperty("transcript") String transcript
|
||||
) {// @formatter:on
|
||||
) { // @formatter:on
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1214,7 +1229,7 @@ public class OpenAiApi {
|
||||
@JsonProperty("system_fingerprint") String systemFingerprint,
|
||||
@JsonProperty("object") String object,
|
||||
@JsonProperty("usage") Usage usage
|
||||
) {// @formatter:on
|
||||
) { // @formatter:on
|
||||
|
||||
/**
|
||||
* Chat completion choice.
|
||||
@@ -1229,7 +1244,7 @@ public class OpenAiApi {
|
||||
@JsonProperty("finish_reason") ChatCompletionFinishReason finishReason,
|
||||
@JsonProperty("index") Integer index,
|
||||
@JsonProperty("message") ChatCompletionMessage message,
|
||||
@JsonProperty("logprobs") LogProbs logprobs) {// @formatter:on
|
||||
@JsonProperty("logprobs") LogProbs logprobs) { // @formatter:on
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1373,7 +1388,7 @@ public class OpenAiApi {
|
||||
@JsonProperty("service_tier") String serviceTier,
|
||||
@JsonProperty("system_fingerprint") String systemFingerprint,
|
||||
@JsonProperty("object") String object,
|
||||
@JsonProperty("usage") Usage usage) {// @formatter:on
|
||||
@JsonProperty("usage") Usage usage) { // @formatter:on
|
||||
|
||||
/**
|
||||
* Chat completion choice.
|
||||
|
||||
@@ -16,8 +16,14 @@
|
||||
|
||||
package org.springframework.ai.openai.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import org.springframework.ai.openai.api.OpenAiApi.ChatCompletion;
|
||||
import org.springframework.ai.openai.api.OpenAiApi.ChatCompletionChunk;
|
||||
import org.springframework.ai.openai.api.OpenAiApi.ChatCompletionMessage;
|
||||
@@ -27,11 +33,6 @@ import org.springframework.ai.openai.api.OpenAiApi.Embedding;
|
||||
import org.springframework.ai.openai.api.OpenAiApi.EmbeddingList;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -85,7 +86,7 @@ public class OpenAiApiIT {
|
||||
ChatCompletionMessage chatCompletionMessage = new ChatCompletionMessage(content, Role.USER);
|
||||
ChatCompletionRequest chatCompletionRequest = new ChatCompletionRequest(List.of(chatCompletionMessage),
|
||||
OpenAiApi.ChatModel.GPT_4_O_AUDIO_PREVIEW.getValue(), 0.0);
|
||||
ResponseEntity<ChatCompletion> response = openAiApi.chatCompletionEntity(chatCompletionRequest);
|
||||
ResponseEntity<ChatCompletion> response = this.openAiApi.chatCompletionEntity(chatCompletionRequest);
|
||||
|
||||
assertThat(response).isNotNull();
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
@@ -105,7 +106,7 @@ public class OpenAiApiIT {
|
||||
ChatCompletionRequest.AudioParameters.AudioResponseFormat.MP3);
|
||||
ChatCompletionRequest chatCompletionRequest = new ChatCompletionRequest(List.of(chatCompletionMessage),
|
||||
OpenAiApi.ChatModel.GPT_4_O_AUDIO_PREVIEW.getValue(), audioParameters);
|
||||
ResponseEntity<ChatCompletion> response = openAiApi.chatCompletionEntity(chatCompletionRequest);
|
||||
ResponseEntity<ChatCompletion> response = this.openAiApi.chatCompletionEntity(chatCompletionRequest);
|
||||
|
||||
assertThat(response).isNotNull();
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
|
||||
@@ -66,7 +66,7 @@ public class MessageTypeContentTests {
|
||||
ArgumentCaptor<MultiValueMap<String, String>> headersCaptor;
|
||||
|
||||
Flux<ChatCompletionChunk> fluxResponse = Flux.generate(
|
||||
() -> new ChatCompletionChunk("id", List.of(), 0l, "model", null, "fp", "object", null), (state, sink) -> {
|
||||
() -> new ChatCompletionChunk("id", List.of(), 0L, "model", null, "fp", "object", null), (state, sink) -> {
|
||||
sink.next(state);
|
||||
sink.complete();
|
||||
return state;
|
||||
|
||||
@@ -129,7 +129,7 @@ public class OpenAiRetryTests {
|
||||
|
||||
var choice = new ChatCompletion.Choice(ChatCompletionFinishReason.STOP, 0,
|
||||
new ChatCompletionMessage("Response", Role.ASSISTANT), null);
|
||||
ChatCompletion expectedChatCompletion = new ChatCompletion("id", List.of(choice), 666l, "model", null, null,
|
||||
ChatCompletion expectedChatCompletion = new ChatCompletion("id", List.of(choice), 666L, "model", null, null,
|
||||
null, new OpenAiApi.Usage(10, 10, 10));
|
||||
|
||||
given(this.openAiApi.chatCompletionEntity(isA(ChatCompletionRequest.class), any()))
|
||||
@@ -158,7 +158,7 @@ public class OpenAiRetryTests {
|
||||
|
||||
var choice = new ChatCompletionChunk.ChunkChoice(ChatCompletionFinishReason.STOP, 0,
|
||||
new ChatCompletionMessage("Response", Role.ASSISTANT), null);
|
||||
ChatCompletionChunk expectedChatCompletion = new ChatCompletionChunk("id", List.of(choice), 666l, "model", null,
|
||||
ChatCompletionChunk expectedChatCompletion = new ChatCompletionChunk("id", List.of(choice), 666L, "model", null,
|
||||
null, null, null);
|
||||
|
||||
given(this.openAiApi.chatCompletionStream(isA(ChatCompletionRequest.class), any()))
|
||||
|
||||
@@ -36,8 +36,8 @@ import org.springframework.ai.chat.client.advisor.api.AdvisedResponse;
|
||||
import org.springframework.ai.chat.client.advisor.api.CallAroundAdvisor;
|
||||
import org.springframework.ai.chat.client.advisor.api.CallAroundAdvisorChain;
|
||||
import org.springframework.ai.model.function.DefaultFunctionCallbackResolver;
|
||||
import org.springframework.ai.model.function.FunctionCallbackResolver;
|
||||
import org.springframework.ai.model.function.FunctionCallback.SchemaType;
|
||||
import org.springframework.ai.model.function.FunctionCallbackResolver;
|
||||
import org.springframework.ai.vertexai.gemini.VertexAiGeminiChatModel;
|
||||
import org.springframework.ai.vertexai.gemini.VertexAiGeminiChatOptions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
Reference in New Issue
Block a user