Various checkstyle fixes
This commit is contained in:
@@ -298,12 +298,14 @@ public class AnthropicApi {
|
||||
/**
|
||||
* The user role.
|
||||
*/
|
||||
@JsonProperty("user") USER,
|
||||
@JsonProperty("user")
|
||||
USER,
|
||||
|
||||
/**
|
||||
* The assistant role.
|
||||
*/
|
||||
@JsonProperty("assistant") ASSISTANT
|
||||
@JsonProperty("assistant")
|
||||
ASSISTANT
|
||||
// @formatter:on
|
||||
|
||||
}
|
||||
@@ -824,7 +826,7 @@ public class AnthropicApi {
|
||||
|
||||
/**
|
||||
* Chat completion response object.
|
||||
*
|
||||
*
|
||||
* @param id Unique object identifier. The format and length of IDs may change over
|
||||
* time.
|
||||
* @param type Object type. For Messages, this is always "message".
|
||||
|
||||
@@ -28,8 +28,9 @@ import org.springframework.ai.anthropic.api.AnthropicApi.ChatCompletionResponse;
|
||||
import org.springframework.ai.anthropic.api.AnthropicApi.ContentBlock;
|
||||
import org.springframework.ai.anthropic.api.AnthropicApi.Role;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
/**
|
||||
* @author Christian Tzolov
|
||||
|
||||
@@ -124,7 +124,7 @@ class AnthropicChatClientMethodInvokingFunctionCallbackIT {
|
||||
.user("What's the weather like in San Francisco, Tokyo, and Paris? Use Celsius.")
|
||||
.functions(FunctionCallback.builder()
|
||||
.description("Get the weather in location")
|
||||
.method("getWeatherNonStatic",String.class, Unit.class)
|
||||
.method("getWeatherNonStatic", String.class, Unit.class)
|
||||
.targetObject(targetObject)
|
||||
.build())
|
||||
.call()
|
||||
@@ -148,7 +148,7 @@ class AnthropicChatClientMethodInvokingFunctionCallbackIT {
|
||||
.description("Get the weather in location")
|
||||
.method("getWeatherWithContext", String.class, Unit.class, ToolContext.class)
|
||||
.targetObject(targetObject)
|
||||
.build())
|
||||
.build())
|
||||
.toolContext(Map.of("tool", "value"))
|
||||
.call()
|
||||
.content();
|
||||
|
||||
@@ -257,7 +257,7 @@ class BedrockConverseChatClientIT {
|
||||
.description("Get the weather in location")
|
||||
.function("getCurrentWeather", new MockWeatherService())
|
||||
.inputType(MockWeatherService.Request.class)
|
||||
.build())
|
||||
.build())
|
||||
.defaultUser(u -> u.text("What's the weather like in San Francisco, Tokyo, and Paris? Return the temperature in Celsius."))
|
||||
.build()
|
||||
.prompt()
|
||||
@@ -280,7 +280,7 @@ class BedrockConverseChatClientIT {
|
||||
.description("Get the weather in location")
|
||||
.function("getCurrentWeather", new MockWeatherService())
|
||||
.inputType(MockWeatherService.Request.class)
|
||||
.build())
|
||||
.build())
|
||||
.stream()
|
||||
.content();
|
||||
// @formatter:on
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Anthropic Chat API.
|
||||
*
|
||||
*
|
||||
* @author Christian Tzolov
|
||||
* @author Thomas Vitale
|
||||
* @author Wei Jiang
|
||||
|
||||
@@ -244,7 +244,7 @@ public class Anthropic3ChatOptions implements ChatOptions {
|
||||
/**
|
||||
* Builder for {@link Anthropic3ChatOptions}.
|
||||
*/
|
||||
public static class Builder {
|
||||
public static final class Builder {
|
||||
|
||||
private final Anthropic3ChatOptions options = new Anthropic3ChatOptions();
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ public class Anthropic3ChatBedrockApi extends
|
||||
private Double topP;
|
||||
private List<String> stopSequences;
|
||||
private String anthropicVersion;
|
||||
|
||||
|
||||
private Builder(List<ChatCompletionMessage> messages) {
|
||||
this.messages = messages;
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ public class Ai21Jurassic2ChatBedrockApi extends
|
||||
/**
|
||||
* Builder for {@link Ai21Jurassic2ChatRequest}.
|
||||
*/
|
||||
public static class Builder {
|
||||
public static final class Builder {
|
||||
private String prompt;
|
||||
private Double temperature;
|
||||
private Double topP;
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import org.springframework.ai.chat.messages.AssistantMessage;
|
||||
import org.springframework.ai.chat.metadata.ChatGenerationMetadata;
|
||||
import org.springframework.ai.chat.model.ChatModel;
|
||||
import org.springframework.ai.chat.model.ChatResponse;
|
||||
import org.springframework.ai.chat.model.Generation;
|
||||
|
||||
@@ -229,7 +229,7 @@ class MistralAiChatClientIT {
|
||||
.description("Get the weather in location")
|
||||
.function("getCurrentWeather", new MockWeatherService())
|
||||
.inputType(MockWeatherService.Request.class)
|
||||
.build())
|
||||
.build())
|
||||
.call()
|
||||
.content();
|
||||
// @formatter:on
|
||||
@@ -275,7 +275,7 @@ class MistralAiChatClientIT {
|
||||
.description("Get the weather in location")
|
||||
.function("getCurrentWeather", new MockWeatherService())
|
||||
.inputType(MockWeatherService.Request.class)
|
||||
.build())
|
||||
.build())
|
||||
.stream()
|
||||
.content();
|
||||
// @formatter:on
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import org.springframework.ai.chat.messages.UserMessage;
|
||||
import org.springframework.ai.ollama.BaseOllamaIT;
|
||||
import org.springframework.ai.ollama.api.OllamaApi.ChatRequest;
|
||||
import org.springframework.ai.ollama.api.OllamaApi.ChatResponse;
|
||||
|
||||
@@ -142,6 +142,15 @@ public class OpenAiUsage implements Usage {
|
||||
valueOrZero(details.rejectedPredictionTokens()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getUsage().toString();
|
||||
}
|
||||
|
||||
private int valueOrZero(Integer value) {
|
||||
return value != null ? value : 0;
|
||||
}
|
||||
|
||||
public record PromptTokensDetails(// @formatter:off
|
||||
Integer audioTokens,
|
||||
Integer cachedTokens) {
|
||||
@@ -154,13 +163,4 @@ public class OpenAiUsage implements Usage {
|
||||
Integer rejectedPredictionTokens) { // @formatter:on
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getUsage().toString();
|
||||
}
|
||||
|
||||
private int valueOrZero(Integer value) {
|
||||
return value != null ? value : 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -105,11 +105,10 @@ class OpenAiSpeechModelIT extends AbstractIT {
|
||||
assertThat(responseFlux).isNotNull();
|
||||
List<SpeechResponse> responses = responseFlux.collectList().block();
|
||||
assertThat(responses).isNotNull();
|
||||
responses.forEach(response -> {
|
||||
// System.out.println("Audio data chunk size: " +
|
||||
// response.getResult().getOutput().length);
|
||||
assertThat(response.getResult().getOutput()).isNotEmpty();
|
||||
});
|
||||
responses.forEach(response ->
|
||||
// System.out.println("Audio data chunk size: " +
|
||||
// response.getResult().getOutput().length);
|
||||
assertThat(response.getResult().getOutput()).isNotEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class OpenAiChatClientMethodInvokingFunctionCallbackIT {
|
||||
.user("What's the weather like in San Francisco, Tokyo, and Paris? Use Celsius.")
|
||||
.functions(FunctionCallback.builder()
|
||||
.description("Get the weather in location")
|
||||
.method("getWeatherStatic",String.class, Unit.class)
|
||||
.method("getWeatherStatic", String.class, Unit.class)
|
||||
.targetClass(TestFunctionClass.class)
|
||||
.build())
|
||||
.call()
|
||||
@@ -107,7 +107,7 @@ class OpenAiChatClientMethodInvokingFunctionCallbackIT {
|
||||
.user("What's the weather like in San Francisco, Tokyo, and Paris? Use Celsius.")
|
||||
.functions(FunctionCallback.builder()
|
||||
.description("Get the weather in location")
|
||||
.method("getWeatherNonStatic",String.class, Unit.class)
|
||||
.method("getWeatherNonStatic", String.class, Unit.class)
|
||||
.targetObject(targetObject)
|
||||
.build())
|
||||
.call()
|
||||
@@ -129,7 +129,7 @@ class OpenAiChatClientMethodInvokingFunctionCallbackIT {
|
||||
.user("What's the weather like in San Francisco, Tokyo, and Paris? Use Celsius.")
|
||||
.functions(FunctionCallback.builder()
|
||||
.description("Get the weather in location")
|
||||
.method("getWeatherWithContext", String.class, Unit.class, ToolContext.class)
|
||||
.method("getWeatherWithContext", String.class, Unit.class, ToolContext.class)
|
||||
.targetObject(targetObject)
|
||||
.build())
|
||||
.toolContext(Map.of("tool", "value"))
|
||||
@@ -176,7 +176,7 @@ class OpenAiChatClientMethodInvokingFunctionCallbackIT {
|
||||
.description("Can turn lights on in the Living Room")
|
||||
.method("turnLivingRoomLightOn")
|
||||
.targetObject(targetObject)
|
||||
.build())
|
||||
.build())
|
||||
.call()
|
||||
.content();
|
||||
// @formatter:on
|
||||
|
||||
@@ -88,7 +88,7 @@ class OpenAiChatClientMultipleFunctionCallsIT extends AbstractIT {
|
||||
.description("Get the weather in location")
|
||||
.function("getCurrentWeather", new MockWeatherService())
|
||||
.inputType(MockWeatherService.Request.class)
|
||||
.build())
|
||||
.build())
|
||||
.call()
|
||||
.content();
|
||||
// @formatter:on
|
||||
@@ -229,7 +229,7 @@ class OpenAiChatClientMultipleFunctionCallsIT extends AbstractIT {
|
||||
.description("Get the weather in location")
|
||||
.function("getCurrentWeather", new MockWeatherService())
|
||||
.inputType(MockWeatherService.Request.class)
|
||||
.build())
|
||||
.build())
|
||||
.stream()
|
||||
.content();
|
||||
// @formatter:on
|
||||
|
||||
@@ -25,7 +25,6 @@ import java.util.Map;
|
||||
|
||||
import org.springframework.ai.chat.metadata.EmptyUsage;
|
||||
import org.springframework.ai.document.Document;
|
||||
import org.springframework.ai.document.MetadataMode;
|
||||
import org.springframework.ai.embedding.AbstractEmbeddingModel;
|
||||
import org.springframework.ai.embedding.Embedding;
|
||||
import org.springframework.ai.embedding.EmbeddingOptions;
|
||||
|
||||
@@ -168,7 +168,7 @@ public class VertexAiEmbeddingConnectionDetails {
|
||||
if (this.predictionServiceSettings == null) {
|
||||
try {
|
||||
this.predictionServiceSettings = PredictionServiceSettings.newBuilder()
|
||||
.setEndpoint(endpoint)
|
||||
.setEndpoint(this.endpoint)
|
||||
.build();
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.ai.vertexai.embedding.multimodal;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
|
||||
|
||||
@@ -948,7 +948,7 @@ public class ZhiPuAiApi {
|
||||
|
||||
/**
|
||||
* Creates an embedding vector representing the input text.
|
||||
*
|
||||
*
|
||||
* @param <T> Type of the input.
|
||||
* @param input Input text to embed, encoded as a string or array of tokens.
|
||||
* @param model ID of the model to use.
|
||||
|
||||
Reference in New Issue
Block a user