Skip to content

Commit 9ebc6d2

Browse files
committed
Code cleanup
- Fix javadoc for Qdrant vector store - Fix checkstyle errors
1 parent 23a3d13 commit 9ebc6d2

File tree

13 files changed

+84
-68
lines changed

13 files changed

+84
-68
lines changed

models/spring-ai-openai/src/main/java/org/springframework/ai/openai/api/OpenAiApi.java

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -698,8 +698,10 @@ public void setJsonSchema(String jsonSchema) {
698698
public enum OutputModality {
699699

700700
// @formatter:off
701-
@JsonProperty("audio") AUDIO,
702-
@JsonProperty("text") TEXT;
701+
@JsonProperty("audio")
702+
AUDIO,
703+
@JsonProperty("text")
704+
TEXT
703705
// @formatter:on
704706

705707
}
@@ -936,23 +938,34 @@ public record AudioParameters(
936938
* Specifies the voice type.
937939
*/
938940
public enum Voice {
939-
@JsonProperty("alloy") ALLOY,
940-
@JsonProperty("echo") ECHO,
941-
@JsonProperty("fable") FABLE,
942-
@JsonProperty("onyx") ONYX,
943-
@JsonProperty("nova") NOVA,
944-
@JsonProperty("shimmer") SHIMMER;
941+
@JsonProperty("alloy")
942+
ALLOY,
943+
@JsonProperty("echo")
944+
ECHO,
945+
@JsonProperty("fable")
946+
FABLE,
947+
@JsonProperty("onyx")
948+
ONYX,
949+
@JsonProperty("nova")
950+
NOVA,
951+
@JsonProperty("shimmer")
952+
SHIMMER
945953
}
946954

947955
/**
948956
* Specifies the output audio format.
949957
*/
950958
public enum AudioResponseFormat {
951-
@JsonProperty("mp3") MP3,
952-
@JsonProperty("flac") FLAC,
953-
@JsonProperty("opus") OPUS,
954-
@JsonProperty("pcm16") PCM16,
955-
@JsonProperty("wav") WAV;
959+
@JsonProperty("mp3")
960+
MP3,
961+
@JsonProperty("flac")
962+
FLAC,
963+
@JsonProperty("opus")
964+
OPUS,
965+
@JsonProperty("pcm16")
966+
PCM16,
967+
@JsonProperty("wav")
968+
WAV
956969
}
957970
}
958971

@@ -1069,23 +1082,7 @@ public record MediaContent(// @formatter:off
10691082
@JsonProperty("type") String type,
10701083
@JsonProperty("text") String text,
10711084
@JsonProperty("image_url") ImageUrl imageUrl,
1072-
@JsonProperty("input_audio") InputAudio inputAudio) {// @formatter:on
1073-
1074-
/**
1075-
* @param data Base64 encoded audio data.
1076-
* @param format The format of the encoded audio data. Currently supports
1077-
* "wav" and "mp3".
1078-
*/
1079-
@JsonInclude(Include.NON_NULL)
1080-
public record InputAudio(// @formatter:off
1081-
@JsonProperty("data") String data,
1082-
@JsonProperty("format") Format format) {
1083-
1084-
public enum Format {
1085-
@JsonProperty("mp3") MP3,
1086-
@JsonProperty("wav") WAV;
1087-
}// @formatter:on
1088-
}
1085+
@JsonProperty("input_audio") InputAudio inputAudio) { // @formatter:on
10891086

10901087
/**
10911088
* Shortcut constructor for a text content.
@@ -1111,6 +1108,24 @@ public MediaContent(InputAudio inputAudio) {
11111108
this("input_audio", null, null, inputAudio);
11121109
}
11131110

1111+
/**
1112+
* @param data Base64 encoded audio data.
1113+
* @param format The format of the encoded audio data. Currently supports
1114+
* "wav" and "mp3".
1115+
*/
1116+
@JsonInclude(Include.NON_NULL)
1117+
public record InputAudio(// @formatter:off
1118+
@JsonProperty("data") String data,
1119+
@JsonProperty("format") Format format) {
1120+
1121+
public enum Format {
1122+
@JsonProperty("mp3")
1123+
MP3,
1124+
@JsonProperty("wav")
1125+
WAV
1126+
} // @formatter:on
1127+
}
1128+
11141129
/**
11151130
* Shortcut constructor for an image content.
11161131
*
@@ -1182,7 +1197,7 @@ public record AudioOutput(// @formatter:off
11821197
@JsonProperty("data") String data,
11831198
@JsonProperty("expires_at") Long expiresAt,
11841199
@JsonProperty("transcript") String transcript
1185-
) {// @formatter:on
1200+
) { // @formatter:on
11861201
}
11871202
}
11881203

@@ -1214,7 +1229,7 @@ public record ChatCompletion(// @formatter:off
12141229
@JsonProperty("system_fingerprint") String systemFingerprint,
12151230
@JsonProperty("object") String object,
12161231
@JsonProperty("usage") Usage usage
1217-
) {// @formatter:on
1232+
) { // @formatter:on
12181233

12191234
/**
12201235
* Chat completion choice.
@@ -1229,7 +1244,7 @@ public record Choice(// @formatter:off
12291244
@JsonProperty("finish_reason") ChatCompletionFinishReason finishReason,
12301245
@JsonProperty("index") Integer index,
12311246
@JsonProperty("message") ChatCompletionMessage message,
1232-
@JsonProperty("logprobs") LogProbs logprobs) {// @formatter:on
1247+
@JsonProperty("logprobs") LogProbs logprobs) { // @formatter:on
12331248
}
12341249

12351250
}
@@ -1373,7 +1388,7 @@ public record ChatCompletionChunk(// @formatter:off
13731388
@JsonProperty("service_tier") String serviceTier,
13741389
@JsonProperty("system_fingerprint") String systemFingerprint,
13751390
@JsonProperty("object") String object,
1376-
@JsonProperty("usage") Usage usage) {// @formatter:on
1391+
@JsonProperty("usage") Usage usage) { // @formatter:on
13771392

13781393
/**
13791394
* Chat completion choice.

models/spring-ai-openai/src/test/java/org/springframework/ai/openai/api/OpenAiApiIT.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@
1616

1717
package org.springframework.ai.openai.api;
1818

19+
import java.io.IOException;
20+
import java.util.Base64;
21+
import java.util.List;
22+
1923
import org.junit.jupiter.api.Test;
2024
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
25+
import reactor.core.publisher.Flux;
26+
2127
import org.springframework.ai.openai.api.OpenAiApi.ChatCompletion;
2228
import org.springframework.ai.openai.api.OpenAiApi.ChatCompletionChunk;
2329
import org.springframework.ai.openai.api.OpenAiApi.ChatCompletionMessage;
@@ -27,11 +33,6 @@
2733
import org.springframework.ai.openai.api.OpenAiApi.EmbeddingList;
2834
import org.springframework.core.io.ClassPathResource;
2935
import org.springframework.http.ResponseEntity;
30-
import reactor.core.publisher.Flux;
31-
32-
import java.io.IOException;
33-
import java.util.Base64;
34-
import java.util.List;
3536

3637
import static org.assertj.core.api.Assertions.assertThat;
3738

@@ -85,7 +86,7 @@ void inputAudio() throws IOException {
8586
ChatCompletionMessage chatCompletionMessage = new ChatCompletionMessage(content, Role.USER);
8687
ChatCompletionRequest chatCompletionRequest = new ChatCompletionRequest(List.of(chatCompletionMessage),
8788
OpenAiApi.ChatModel.GPT_4_O_AUDIO_PREVIEW.getValue(), 0.0);
88-
ResponseEntity<ChatCompletion> response = openAiApi.chatCompletionEntity(chatCompletionRequest);
89+
ResponseEntity<ChatCompletion> response = this.openAiApi.chatCompletionEntity(chatCompletionRequest);
8990

9091
assertThat(response).isNotNull();
9192
assertThat(response.getBody()).isNotNull();
@@ -105,7 +106,7 @@ void outputAudio() {
105106
ChatCompletionRequest.AudioParameters.AudioResponseFormat.MP3);
106107
ChatCompletionRequest chatCompletionRequest = new ChatCompletionRequest(List.of(chatCompletionMessage),
107108
OpenAiApi.ChatModel.GPT_4_O_AUDIO_PREVIEW.getValue(), audioParameters);
108-
ResponseEntity<ChatCompletion> response = openAiApi.chatCompletionEntity(chatCompletionRequest);
109+
ResponseEntity<ChatCompletion> response = this.openAiApi.chatCompletionEntity(chatCompletionRequest);
109110

110111
assertThat(response).isNotNull();
111112
assertThat(response.getBody()).isNotNull();

models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/MessageTypeContentTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class MessageTypeContentTests {
6666
ArgumentCaptor<MultiValueMap<String, String>> headersCaptor;
6767

6868
Flux<ChatCompletionChunk> fluxResponse = Flux.generate(
69-
() -> new ChatCompletionChunk("id", List.of(), 0l, "model", null, "fp", "object", null), (state, sink) -> {
69+
() -> new ChatCompletionChunk("id", List.of(), 0L, "model", null, "fp", "object", null), (state, sink) -> {
7070
sink.next(state);
7171
sink.complete();
7272
return state;

models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiRetryTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public void openAiChatTransientError() {
129129

130130
var choice = new ChatCompletion.Choice(ChatCompletionFinishReason.STOP, 0,
131131
new ChatCompletionMessage("Response", Role.ASSISTANT), null);
132-
ChatCompletion expectedChatCompletion = new ChatCompletion("id", List.of(choice), 666l, "model", null, null,
132+
ChatCompletion expectedChatCompletion = new ChatCompletion("id", List.of(choice), 666L, "model", null, null,
133133
null, new OpenAiApi.Usage(10, 10, 10));
134134

135135
given(this.openAiApi.chatCompletionEntity(isA(ChatCompletionRequest.class), any()))
@@ -158,7 +158,7 @@ public void openAiChatStreamTransientError() {
158158

159159
var choice = new ChatCompletionChunk.ChunkChoice(ChatCompletionFinishReason.STOP, 0,
160160
new ChatCompletionMessage("Response", Role.ASSISTANT), null);
161-
ChatCompletionChunk expectedChatCompletion = new ChatCompletionChunk("id", List.of(choice), 666l, "model", null,
161+
ChatCompletionChunk expectedChatCompletion = new ChatCompletionChunk("id", List.of(choice), 666L, "model", null,
162162
null, null, null);
163163

164164
given(this.openAiApi.chatCompletionStream(isA(ChatCompletionRequest.class), any()))

models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/function/VertexAiGeminiPaymentTransactionIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
import org.springframework.ai.chat.client.advisor.api.CallAroundAdvisor;
3737
import org.springframework.ai.chat.client.advisor.api.CallAroundAdvisorChain;
3838
import org.springframework.ai.model.function.DefaultFunctionCallbackResolver;
39-
import org.springframework.ai.model.function.FunctionCallbackResolver;
4039
import org.springframework.ai.model.function.FunctionCallback.SchemaType;
40+
import org.springframework.ai.model.function.FunctionCallbackResolver;
4141
import org.springframework.ai.vertexai.gemini.VertexAiGeminiChatModel;
4242
import org.springframework.ai.vertexai.gemini.VertexAiGeminiChatOptions;
4343
import org.springframework.beans.factory.annotation.Autowired;

spring-ai-core/src/main/java/org/springframework/ai/aot/SpringAiCoreRuntimeHints.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
import org.springframework.ai.chat.messages.SystemMessage;
2727
import org.springframework.ai.chat.messages.ToolResponseMessage;
2828
import org.springframework.ai.chat.messages.UserMessage;
29-
import org.springframework.ai.model.function.FunctionCallback;
3029
import org.springframework.ai.model.function.DefaultFunctionCallbackResolver;
30+
import org.springframework.ai.model.function.FunctionCallback;
3131
import org.springframework.ai.model.function.FunctionCallbackWrapper;
3232
import org.springframework.aot.hint.ExecutableMode;
3333
import org.springframework.aot.hint.RuntimeHints;

spring-ai-core/src/main/java/org/springframework/ai/model/function/DefaultFunctionCallbackResolver.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import org.springframework.core.ParameterizedTypeReference;
3838
import org.springframework.core.ResolvableType;
3939
import org.springframework.lang.NonNull;
40-
import org.springframework.lang.Nullable;
4140
import org.springframework.util.StringUtils;
4241

4342
/**

spring-ai-core/src/main/java/org/springframework/ai/model/function/FunctionCallback.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static FunctionCallback.Builder builder() {
9494
* Describes the type of the schema used to describe the input parameters of the
9595
* function.
9696
*/
97-
public enum SchemaType {
97+
enum SchemaType {
9898

9999
/**
100100
* JSON schema

spring-ai-core/src/main/java/org/springframework/ai/model/function/FunctionCallbackResolver.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
/*
2-
* Copyright 2024 - 2024 the original author or authors.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* https://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
2+
* Copyright 2024-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
1617
package org.springframework.ai.model.function;
1718

1819
import org.springframework.lang.NonNull;

spring-ai-core/src/test/java/org/springframework/ai/vectorstore/filter/FilterExpressionTextParserTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public void testIdentifiers() {
194194

195195
@Test
196196
public void testUnescapedIdentifierWithUnderscores() {
197-
Expression exp = parser.parse("file_name == 'medicaid-wa-faqs.pdf'");
197+
Expression exp = this.parser.parse("file_name == 'medicaid-wa-faqs.pdf'");
198198
assertThat(exp).isEqualTo(new Expression(EQ, new Key("file_name"), new Value("medicaid-wa-faqs.pdf")));
199199
}
200200

0 commit comments

Comments
 (0)