Fix checkstyle errors

This commit is contained in:
Ilayaperumal Gopinathan
2024-11-19 23:20:08 +00:00
parent 3812d2e6d8
commit 3b95dfd87f
11 changed files with 85 additions and 47 deletions

View File

@@ -261,7 +261,8 @@ public class AnthropicApi {
/**
* The CLAUDE_INSTANT_1_2
*/
@Deprecated CLAUDE_INSTANT_1_2("claude-instant-1.2");
@Deprecated
CLAUDE_INSTANT_1_2("claude-instant-1.2");
// @formatter:on
private final String value;

View File

@@ -24,13 +24,34 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import com.azure.ai.openai.OpenAIAsyncClient;
import com.azure.ai.openai.OpenAIClient;
import com.azure.ai.openai.OpenAIClientBuilder;
import com.azure.ai.openai.models.*;
import com.azure.ai.openai.models.ChatChoice;
import com.azure.ai.openai.models.ChatCompletions;
import com.azure.ai.openai.models.ChatCompletionsFunctionToolCall;
import com.azure.ai.openai.models.ChatCompletionsFunctionToolDefinition;
import com.azure.ai.openai.models.ChatCompletionsFunctionToolDefinitionFunction;
import com.azure.ai.openai.models.ChatCompletionsJsonResponseFormat;
import com.azure.ai.openai.models.ChatCompletionsOptions;
import com.azure.ai.openai.models.ChatCompletionsResponseFormat;
import com.azure.ai.openai.models.ChatCompletionsTextResponseFormat;
import com.azure.ai.openai.models.ChatCompletionsToolCall;
import com.azure.ai.openai.models.ChatCompletionsToolDefinition;
import com.azure.ai.openai.models.ChatMessageContentItem;
import com.azure.ai.openai.models.ChatMessageImageContentItem;
import com.azure.ai.openai.models.ChatMessageImageUrl;
import com.azure.ai.openai.models.ChatMessageTextContentItem;
import com.azure.ai.openai.models.ChatRequestAssistantMessage;
import com.azure.ai.openai.models.ChatRequestMessage;
import com.azure.ai.openai.models.ChatRequestSystemMessage;
import com.azure.ai.openai.models.ChatRequestToolMessage;
import com.azure.ai.openai.models.ChatRequestUserMessage;
import com.azure.ai.openai.models.CompletionsFinishReason;
import com.azure.ai.openai.models.ContentFilterResultsForPrompt;
import com.azure.ai.openai.models.FunctionCall;
import com.azure.core.util.BinaryData;
import io.micrometer.observation.Observation;
import io.micrometer.observation.ObservationRegistry;

View File

@@ -1,9 +1,24 @@
package org.springframework.ai.azure.openai;
/*
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import com.azure.ai.openai.OpenAIClientBuilder;
package org.springframework.ai.azure.openai;
import java.util.List;
import com.azure.ai.openai.OpenAIClientBuilder;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
@@ -35,8 +50,8 @@ public class AzureOpenAiChatModelTests {
List<FunctionCallback> functionCallbacks = List.of(new TestFunctionCallback(callbackFromConstructorParam));
AzureOpenAiChatModel openAiChatModel = new AzureOpenAiChatModel(mockClient, chatOptions,
functionCallbackContext, functionCallbacks);
AzureOpenAiChatModel openAiChatModel = new AzureOpenAiChatModel(this.mockClient, chatOptions,
this.functionCallbackContext, functionCallbacks);
assert 2 == openAiChatModel.getFunctionCallbackRegister().size();
@@ -53,13 +68,13 @@ public class AzureOpenAiChatModelTests {
private final String name;
public TestFunctionCallback(String name) {
TestFunctionCallback(String name) {
this.name = name;
}
@Override
public String getName() {
return name;
return this.name;
}
@Override
@@ -79,4 +94,4 @@ public class AzureOpenAiChatModelTests {
}
}
}

View File

@@ -24,7 +24,6 @@ import com.azure.core.credential.AzureKeyCredential;
import io.micrometer.observation.tck.TestObservationRegistry;
import io.micrometer.observation.tck.TestObservationRegistryAssert;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import org.springframework.ai.document.MetadataMode;
import org.springframework.ai.embedding.EmbeddingRequest;

View File

@@ -16,10 +16,6 @@
package org.springframework.ai.ollama;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.BDDMockito.given;
import java.time.Duration;
import org.junit.jupiter.api.Test;
@@ -32,6 +28,10 @@ import org.springframework.ai.ollama.api.OllamaApi;
import org.springframework.ai.ollama.api.OllamaModel;
import org.springframework.ai.ollama.api.OllamaOptions;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.BDDMockito.given;
/**
* @author Jihoon Kim
* @since 1.0.0
@@ -49,7 +49,7 @@ public class OllamaChatModelTests {
public void buildOllamaChatModel() {
Exception exception = assertThrows(IllegalArgumentException.class,
() -> OllamaChatModel.builder()
.withOllamaApi(ollamaApi)
.withOllamaApi(this.ollamaApi)
.withDefaultOptions(OllamaOptions.create().withModel(OllamaModel.LLAMA2))
.withModelManagementOptions(null)
.build());
@@ -64,12 +64,12 @@ public class OllamaChatModelTests {
Duration promptEvalDuration = Duration.ofSeconds(8);
Integer promptEvalCount = 808;
given(response.evalDuration()).willReturn(evalDuration);
given(response.evalCount()).willReturn(evalCount);
given(response.promptEvalDuration()).willReturn(promptEvalDuration);
given(response.promptEvalCount()).willReturn(promptEvalCount);
given(this.response.evalDuration()).willReturn(evalDuration);
given(this.response.evalCount()).willReturn(evalCount);
given(this.response.promptEvalDuration()).willReturn(promptEvalDuration);
given(this.response.promptEvalCount()).willReturn(promptEvalCount);
ChatResponseMetadata metadata = OllamaChatModel.from(response);
ChatResponseMetadata metadata = OllamaChatModel.from(this.response);
assertEquals(evalDuration, metadata.get("eval-duration"));
assertEquals(evalCount, metadata.get("eval-count"));