Skip to content

Commit

Permalink
Fix checkstyle errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ilayaperumalg committed Jan 2, 2025
1 parent 1c156e9 commit 7fe3b38
Show file tree
Hide file tree
Showing 78 changed files with 562 additions and 429 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
import io.micrometer.observation.contextpropagation.ObservationThreadLocalAccessor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ai.model.Media;
import org.springframework.util.MimeType;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

Expand Down Expand Up @@ -62,6 +60,7 @@
import org.springframework.ai.mistralai.api.MistralAiApi.ChatCompletionMessage.ToolCall;
import org.springframework.ai.mistralai.api.MistralAiApi.ChatCompletionRequest;
import org.springframework.ai.mistralai.metadata.MistralAiUsage;
import org.springframework.ai.model.Media;
import org.springframework.ai.model.ModelOptionsUtils;
import org.springframework.ai.model.function.FunctionCallback;
import org.springframework.ai.model.function.FunctionCallbackResolver;
Expand All @@ -71,6 +70,7 @@
import org.springframework.retry.support.RetryTemplate;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.MimeType;

/**
* Represents a Mistral AI Chat Model.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,22 @@

package org.springframework.ai.mistralai;

import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.publisher.Flux;

import org.springframework.ai.chat.messages.AssistantMessage;
import org.springframework.ai.chat.messages.Message;
import org.springframework.ai.chat.messages.UserMessage;
Expand All @@ -46,15 +56,6 @@
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.util.MimeTypeUtils;
import reactor.core.publisher.Flux;

import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import org.slf4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,15 +672,15 @@ public record ChatResponse(
}

public Duration getTotalDuration() {
return (this.totalDuration() != null)? Duration.ofNanos(this.totalDuration()) : null;
return (this.totalDuration() != null) ? Duration.ofNanos(this.totalDuration()) : null;
}

public Duration getLoadDuration() {
return (this.loadDuration() != null)? Duration.ofNanos(this.loadDuration()) : null;
return (this.loadDuration() != null) ? Duration.ofNanos(this.loadDuration()) : null;
}

public Duration getPromptEvalDuration() {
return (this.promptEvalDuration() != null)? Duration.ofNanos(this.promptEvalDuration()) : null;
return (this.promptEvalDuration() != null) ? Duration.ofNanos(this.promptEvalDuration()) : null;
}

public Duration getEvalDuration() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
/*
* Copyright 2024 - 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.
*/
* Copyright 2024-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.
*/

package org.springframework.ai.ollama.api;

import java.time.Instant;
Expand All @@ -28,6 +29,10 @@
*/
public final class OllamaApiHelper {

private OllamaApiHelper() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}

/**
* @param ollamaChatResponse the Ollama chat response chunk to check
* @return true if the chunk is a streaming tool call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void pullModel(String modelName, PullModelStrategy pullModelStrategy) {
logger.info("Pulling the '{}' model - Status: {}", modelName, progressResponses.get(progressResponses.size() - 1).status());
}
})
.takeUntil(progressResponses ->
.takeUntil(progressResponses ->
progressResponses.get(0) != null && "success".equals(progressResponses.get(0).status()))
.timeout(this.options.timeout())
.retryWhen(Retry.backoff(this.options.maxRetries(), Duration.ofSeconds(5)))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
/*
* Copyright 2024 - 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.
*/
* Copyright 2024-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.
*/

package org.springframework.ai.ollama.api;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,15 @@ public void setN(Integer n) {
}

public List<String> getOutputModalities() {
return outputModalities;
return this.outputModalities;
}

public void setOutputModalities(List<String> modalities) {
this.outputModalities = modalities;
}

public AudioParameters getOutputAudio() {
return outputAudio;
return this.outputAudio;
}

public void setOutputAudio(AudioParameters audio) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@

package org.springframework.ai.openai;

import java.util.Objects;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.ai.image.ImageOptions;

import java.util.Objects;
import org.springframework.ai.image.ImageOptions;

/**
* OpenAI Image API options. OpenAiImageOptions.java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ public enum AudioResponseFormat {
@JsonProperty("mp3") MP3,
/** FLAC format */
@JsonProperty("flac") FLAC,
/** OPUS format */
/** OPUS format */
@JsonProperty("opus") OPUS,
/** PCM16 format */
@JsonProperty("pcm16") PCM16,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 the original author or authors.
* Copyright 2024-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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import io.micrometer.observation.Observation;
import io.micrometer.observation.ObservationRegistry;
import io.micrometer.observation.contextpropagation.ObservationThreadLocalAccessor;
import org.springframework.ai.vertexai.gemini.common.VertexAiGeminiSafetySetting;
import reactor.core.publisher.Flux;

import org.springframework.ai.chat.messages.AssistantMessage;
Expand Down Expand Up @@ -77,6 +76,7 @@
import org.springframework.ai.model.function.FunctionCallingOptions;
import org.springframework.ai.retry.RetryUtils;
import org.springframework.ai.vertexai.gemini.common.VertexAiGeminiConstants;
import org.springframework.ai.vertexai.gemini.common.VertexAiGeminiSafetySetting;
import org.springframework.ai.vertexai.gemini.metadata.VertexAiUsage;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.lang.NonNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public void setGoogleSearchRetrieval(boolean googleSearchRetrieval) {
}

public List<VertexAiGeminiSafetySetting> getSafetySettings() {
return safetySettings;
return this.safetySettings;
}

public void setSafetySettings(List<VertexAiGeminiSafetySetting> safetySettings) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2024-2025 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.
*/

package org.springframework.ai.vertexai.gemini.common;

public class VertexAiGeminiSafetySetting {
Expand All @@ -17,7 +33,7 @@ public enum HarmBlockThreshold {
}

public int getValue() {
return value;
return this.value;
}

}
Expand All @@ -36,7 +52,7 @@ public enum HarmBlockMethod {
}

public int getValue() {
return value;
return this.value;
}

}
Expand All @@ -56,7 +72,7 @@ public enum HarmCategory {
}

public int getValue() {
return value;
return this.value;
}

}
Expand All @@ -83,23 +99,23 @@ public VertexAiGeminiSafetySetting(HarmCategory category, HarmBlockThreshold thr

// Getters and setters
public HarmCategory getCategory() {
return category;
return this.category;
}

public void setCategory(HarmCategory category) {
this.category = category;
}

public HarmBlockThreshold getThreshold() {
return threshold;
return this.threshold;
}

public void setThreshold(HarmBlockThreshold threshold) {
this.threshold = threshold;
}

public HarmBlockMethod getMethod() {
return method;
return this.method;
}

public void setMethod(HarmBlockMethod method) {
Expand All @@ -108,30 +124,35 @@ public void setMethod(HarmBlockMethod method) {

@Override
public String toString() {
return "SafetySetting{" + "category=" + category + ", threshold=" + threshold + ", method=" + method + '}';
return "SafetySetting{" + "category=" + this.category + ", threshold=" + this.threshold + ", method="
+ this.method + '}';
}

@Override
public boolean equals(Object o) {
if (this == o)
if (this == o) {
return true;
if (o == null || getClass() != o.getClass())
}
if (o == null || getClass() != o.getClass()) {
return false;
}

VertexAiGeminiSafetySetting that = (VertexAiGeminiSafetySetting) o;

if (category != that.category)
if (this.category != that.category) {
return false;
if (threshold != that.threshold)
}
if (this.threshold != that.threshold) {
return false;
return method == that.method;
}
return this.method == that.method;
}

@Override
public int hashCode() {
int result = category != null ? category.hashCode() : 0;
result = 31 * result + (threshold != null ? threshold.hashCode() : 0);
result = 31 * result + (method != null ? method.hashCode() : 0);
int result = this.category != null ? this.category.hashCode() : 0;
result = 31 * result + (this.threshold != null ? this.threshold.hashCode() : 0);
result = 31 * result + (this.method != null ? this.method.hashCode() : 0);
return result;
}

Expand Down Expand Up @@ -159,7 +180,7 @@ public Builder withMethod(HarmBlockMethod method) {
}

public VertexAiGeminiSafetySetting build() {
return new VertexAiGeminiSafetySetting(category, threshold, method);
return new VertexAiGeminiSafetySetting(this.category, this.threshold, this.method);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import org.junit.jupiter.api.Test;

import org.springframework.ai.embedding.EmbeddingOptions;
import org.springframework.ai.embedding.EmbeddingOptionsBuilder;
import org.springframework.ai.embedding.EmbeddingResponse;
import org.springframework.ai.watsonx.api.WatsonxAiApi;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public AdvisedRequest before(AdvisedRequest request) {
* documents.
*/
private Map.Entry<Query, List<Document>> getDocumentsForQuery(Query query) {
List<Document> documents = documentRetriever.retrieve(query);
List<Document> documents = this.documentRetriever.retrieve(query);
return Map.entry(query, documents);
}

Expand Down
Loading

0 comments on commit 7fe3b38

Please sign in to comment.