From 3cf3eff9a0a409fde55fbc610881c8bfcca79737 Mon Sep 17 00:00:00 2001 From: Christian Tzolov Date: Mon, 20 May 2024 18:44:52 +0200 Subject: [PATCH] Fix ChatClient structured output flow. Add OpenAiChatClientIT. Rename Call to Caller --- ...delCall.java => AnthropicModelCaller.java} | 26 +- ...allIT.java => AnthropicModelCallerIT.java} | 8 +- .../anthropic/AnthropicTestConfiguration.java | 4 +- .../anthropic/ChatCompletionRequestTests.java | 2 +- ...lCall.java => AzureOpenAiModelCaller.java} | 18 +- .../AzureChatCompletionsOptionsTests.java | 2 +- ...lIT.java => AzureOpenAiModelCallIerT.java} | 10 +- .../MockAzureOpenAiTestConfiguration.java | 4 +- .../AzureOpenAiModelCallFunctionCallIT.java | 8 +- .../AzureOpenAiModelCallMetadataTests.java | 6 +- ....java => BedrockAnthropicModelCaller.java} | 10 +- ...java => BedrockAnthropic3ModelCaller.java} | 10 +- ...all.java => BedrockCohereModelCaller.java} | 8 +- ...a => BedrockAi21Jurassic2ModelCaller.java} | 15 +- ...Call.java => BedrockLlamaModelCaller.java} | 10 +- ...Call.java => BedrockTitanModelCaller.java} | 8 +- .../BedrockAnthropicCreateRequestTests.java | 2 +- ...ava => BedrockAnthropicModelCallerIT.java} | 10 +- .../BedrockAnthropic3CreateRequestTests.java | 2 +- ...va => BedrockAnthropic3ModelCallerIT.java} | 10 +- .../BedrockCohereChatCreateRequestTests.java | 2 +- ...T.java => BedrockCohereModelCallerIT.java} | 8 +- ...=> BedrockAi21Jurassic2ModelCallerIT.java} | 8 +- .../llama/BedrockLlamaCreateRequestTests.java | 2 +- ...IT.java => BedrockLlamaModelCallerIT.java} | 8 +- .../BedrockTitanChatCreateRequestTests.java | 2 +- ...IT.java => BedrockTitanModelCalerlIT.java} | 8 +- ...lCall.java => HuggingfaceModelCaller.java} | 8 +- .../HuggingfaceTestConfiguration.java | 4 +- .../ai/huggingface/client/ClientIT.java | 4 +- ...delCall.java => MistralAiModelCaller.java} | 12 +- .../MistralAiChatCompletionRequestTest.java | 2 +- ...allIT.java => MistralAiModelCallerIT.java} | 8 +- .../ai/mistralai/MistralAiRetryTests.java | 4 +- .../mistralai/MistralAiTestConfiguration.java | 4 +- ...aModelCall.java => OllamaModelCaller.java} | 14 +- .../ai/ollama/OllamaChatRequestTests.java | 4 +- ...elCallIT.java => OllamaModelCallerIT.java} | 10 +- ...ava => OllamaModelCallerMultimodalIT.java} | 10 +- ...iModelCall.java => OpenAiModelCaller.java} | 18 +- .../ai/openai/ChatCompletionRequestTests.java | 6 +- .../ai/openai/OpenAiTestConfiguration.java | 4 +- .../ai/openai/acme/AcmeIT.java | 4 +- .../ai/openai/chat/OpenAiChatClientIT.java | 388 ++++++++++++++++++ ...atClientWithChatResponseMetadataTests.java | 8 +- ...Call2IT.java => OpenAiModelCaller2IT.java} | 12 +- ...elCallIT.java => OpenAiModelCallerIT.java} | 21 +- ...erTypeReferenceBeanOutputConverterIT.java} | 6 +- .../ai/openai/chat/OpenAiRetryTests.java | 6 +- .../ChatMemoryLongTermSystemPromptIT.java | 12 +- .../ChatMemoryShortTermMessageListIT.java | 12 +- .../ChatMemoryShortTermSystemPromptIT.java | 12 +- .../LongShortTermChatMemoryWithRagIT.java | 10 +- ...OpenAiPromptTransformingChatServiceIT.java | 14 +- .../ai/openai/testutils/AbstractIT.java | 8 +- .../transformer/MetadataTransformerIT.java | 10 +- .../gemini/VertexAiGeminiChatOptions.java | 2 +- ...ll.java => VertexAiGeminiModelCaller.java} | 14 +- .../aot/VertexAiGeminiRuntimeHints.java | 4 +- ....java => VertexAiGeminiModelCallerIT.java} | 10 +- .../aot/VertexAiGeminiRuntimeHintsTests.java | 4 +- ...texAiGeminiModelCallFunctionCallingIT.java | 16 +- ...all.java => VertexAiPaLm2ModelCaller.java} | 8 +- .../VertexAiPaLm2ChatGenerationClientIT.java | 6 +- .../palm2/VertexAiPaLm2ChatRequestTests.java | 2 +- ...delCall.java => WatsonxAiModelCaller.java} | 10 +- ...est.java => WatsonxAiModelCallerTest.java} | 8 +- .../chat/{ModelCall.java => ChatCaller.java} | 2 +- .../springframework/ai/chat/ChatClient.java | 65 ++- .../ai/chat/DefaultChatClient.java | 4 +- .../PromptTransformingChatService.java | 12 +- .../ai/evaluation/RelevancyEvaluator.java | 8 +- .../transformer/KeywordMetadataEnricher.java | 6 +- .../transformer/SummaryMetadataEnricher.java | 8 +- .../org/springframework/ai/chat/Main.java | 59 +++ .../ai/chat/ModelCallTests.java | 4 +- .../ai/chat/memory/ChatMemoryTests.java | 4 +- .../anthropic/AnthropicAutoConfiguration.java | 6 +- .../anthropic/AnthropicChatProperties.java | 8 +- .../openai/AzureOpenAiAutoConfiguration.java | 10 +- ...BedrockAnthropicChatAutoConfiguration.java | 6 +- ...edrockAnthropic3ChatAutoConfiguration.java | 6 +- .../BedrockCohereChatAutoConfiguration.java | 6 +- ...ockAi21Jurassic2ChatAutoConfiguration.java | 6 +- .../BedrockLlamaChatAutoConfiguration.java | 7 +- .../BedrockTitanChatAutoConfiguration.java | 6 +- .../HuggingfaceChatAutoConfiguration.java | 8 +- .../mistralai/MistralAiAutoConfiguration.java | 6 +- .../ollama/OllamaAutoConfiguration.java | 6 +- .../openai/OpenAiAutoConfiguration.java | 6 +- .../VertexAiGeminiAutoConfiguration.java | 8 +- .../gemini/VertexAiGeminiChatProperties.java | 4 +- .../palm2/VertexAiPalm2AutoConfiguration.java | 6 +- .../watsonxai/WatsonxAiAutoConfiguration.java | 6 +- .../AnthropicAutoConfigurationIT.java | 6 +- .../anthropic/AnthropicPropertiesTests.java | 8 +- .../tool/FunctionCallWithFunctionBeanIT.java | 4 +- .../FunctionCallWithPromptFunctionIT.java | 4 +- .../azure/AzureOpenAiAutoConfigurationIT.java | 12 +- .../tool/FunctionCallWithFunctionBeanIT.java | 6 +- .../FunctionCallWithFunctionWrapperIT.java | 4 +- .../FunctionCallWithPromptFunctionIT.java | 4 +- ...drockAnthropicChatAutoConfigurationIT.java | 12 +- ...rockAnthropic3ChatAutoConfigurationIT.java | 12 +- .../BedrockCohereChatAutoConfigurationIT.java | 12 +- ...kAi21Jurassic2ChatAutoConfigurationIT.java | 12 +- .../BedrockLlamaChatAutoConfigurationIT.java | 12 +- .../BedrockTitanChatAutoConfigurationIT.java | 12 +- .../MistralAiAutoConfigurationIT.java | 6 +- .../mistralai/tool/PaymentStatusBeanIT.java | 4 +- .../tool/PaymentStatusBeanOpenAiIT.java | 6 +- .../mistralai/tool/PaymentStatusPromptIT.java | 4 +- .../tool/WeatherServicePromptIT.java | 4 +- .../ollama/OllamaChatAutoConfigurationIT.java | 12 +- .../openai/OpenAiAutoConfigurationIT.java | 6 +- .../openai/OpenAiPropertiesTests.java | 8 +- .../tool/FunctionCallbackInPromptIT.java | 6 +- ...nctionCallbackWithPlainFunctionBeanIT.java | 8 +- .../tool/FunctionCallbackWrapperIT.java | 6 +- .../VertexAiGeminiAutoConfigurationIT.java | 6 +- .../tool/FunctionCallWithFunctionBeanIT.java | 6 +- .../FunctionCallWithFunctionWrapperIT.java | 6 +- .../FunctionCallWithPromptFunctionIT.java | 6 +- .../VertexAiPaLm2AutoConfigurationIT.java | 10 +- .../ai/evaluation/BasicEvaluationTest.java | 4 +- .../CricketWorldCupHanaController.java | 6 +- 126 files changed, 960 insertions(+), 487 deletions(-) rename models/spring-ai-anthropic/src/main/java/org/springframework/ai/anthropic/{AnthropicModelCall.java => AnthropicModelCaller.java} (95%) rename models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/{AnthropicModelCallIT.java => AnthropicModelCallerIT.java} (98%) rename models/spring-ai-azure-openai/src/main/java/org/springframework/ai/azure/openai/{AzureOpenAiModelCall.java => AzureOpenAiModelCaller.java} (97%) rename models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/{AzureOpenAiModelCallIT.java => AzureOpenAiModelCallIerT.java} (96%) rename models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic/{BedrockAnthropicModelCall.java => BedrockAnthropicModelCaller.java} (90%) rename models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic3/{BedrockAnthropic3ModelCall.java => BedrockAnthropic3ModelCaller.java} (94%) rename models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/{BedrockCohereModelCall.java => BedrockCohereModelCaller.java} (93%) rename models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/jurassic2/{BedrockAi21Jurassic2ModelCall.java => BedrockAi21Jurassic2ModelCaller.java} (88%) rename models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/llama/{BedrockLlamaModelCall.java => BedrockLlamaModelCaller.java} (91%) rename models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/titan/{BedrockTitanModelCall.java => BedrockTitanModelCaller.java} (94%) rename models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic/{BedrockAnthropicModelCallIT.java => BedrockAnthropicModelCallerIT.java} (96%) rename models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic3/{BedrockAnthropic3ModelCallIT.java => BedrockAnthropic3ModelCallerIT.java} (96%) rename models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/{BedrockCohereModelCallIT.java => BedrockCohereModelCallerIT.java} (97%) rename models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/jurassic2/{BedrockAi21Jurassic2ModelCallIT.java => BedrockAi21Jurassic2ModelCallerIT.java} (96%) rename models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/llama/{BedrockLlamaModelCallIT.java => BedrockLlamaModelCallerIT.java} (97%) rename models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/titan/{BedrockTitanModelCallIT.java => BedrockTitanModelCalerlIT.java} (97%) rename models/spring-ai-huggingface/src/main/java/org/springframework/ai/huggingface/{HuggingfaceModelCall.java => HuggingfaceModelCaller.java} (93%) rename models/spring-ai-mistral-ai/src/main/java/org/springframework/ai/mistralai/{MistralAiModelCall.java => MistralAiModelCaller.java} (96%) rename models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/{MistralAiModelCallIT.java => MistralAiModelCallerIT.java} (98%) rename models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/{OllamaModelCall.java => OllamaModelCaller.java} (93%) rename models/spring-ai-ollama/src/test/java/org/springframework/ai/ollama/{OllamaModelCallIT.java => OllamaModelCallerIT.java} (96%) rename models/spring-ai-ollama/src/test/java/org/springframework/ai/ollama/{OllamaModelCallMultimodalIT.java => OllamaModelCallerMultimodalIT.java} (92%) rename models/spring-ai-openai/src/main/java/org/springframework/ai/openai/{OpenAiModelCall.java => OpenAiModelCaller.java} (96%) create mode 100644 models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiChatClientIT.java rename models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/{OpenAiModelCall2IT.java => OpenAiModelCaller2IT.java} (91%) rename models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/{OpenAiModelCallIT.java => OpenAiModelCallerIT.java} (95%) rename models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/{OpenAiModelCallTypeReferenceBeanOutputConverterIT.java => OpenAiModelCallerTypeReferenceBeanOutputConverterIT.java} (94%) rename models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/{VertexAiGeminiModelCall.java => VertexAiGeminiModelCaller.java} (97%) rename models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/{VertexAiGeminiModelCallIT.java => VertexAiGeminiModelCallerIT.java} (96%) rename models/spring-ai-vertex-ai-palm2/src/main/java/org/springframework/ai/vertexai/palm2/{VertexAiPaLm2ModelCall.java => VertexAiPaLm2ModelCaller.java} (93%) rename models/spring-ai-watsonx-ai/src/main/java/org/springframework/ai/watsonx/{WatsonxAiModelCall.java => WatsonxAiModelCaller.java} (93%) rename models/spring-ai-watsonx-ai/src/test/java/org/springframework/ai/watsonx/{WatsonxAiModelCallTest.java => WatsonxAiModelCallerTest.java} (97%) rename spring-ai-core/src/main/java/org/springframework/ai/chat/{ModelCall.java => ChatCaller.java} (95%) create mode 100644 spring-ai-core/src/test/java/org/springframework/ai/chat/Main.java diff --git a/models/spring-ai-anthropic/src/main/java/org/springframework/ai/anthropic/AnthropicModelCall.java b/models/spring-ai-anthropic/src/main/java/org/springframework/ai/anthropic/AnthropicModelCaller.java similarity index 95% rename from models/spring-ai-anthropic/src/main/java/org/springframework/ai/anthropic/AnthropicModelCall.java rename to models/spring-ai-anthropic/src/main/java/org/springframework/ai/anthropic/AnthropicModelCaller.java index 02f48720a..bba71a1dc 100644 --- a/models/spring-ai-anthropic/src/main/java/org/springframework/ai/anthropic/AnthropicModelCall.java +++ b/models/spring-ai-anthropic/src/main/java/org/springframework/ai/anthropic/AnthropicModelCaller.java @@ -26,7 +26,7 @@ import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import reactor.core.publisher.Flux; import org.springframework.ai.anthropic.api.AnthropicApi; @@ -56,16 +56,16 @@ import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; /** - * The {@link ModelCall} implementation for the Anthropic service. + * The {@link ChatCaller} implementation for the Anthropic service. * * @author Christian Tzolov * @since 1.0.0 */ -public class AnthropicModelCall extends +public class AnthropicModelCaller extends AbstractFunctionCallSupport> - implements ModelCall, StreamingChatClient { + implements ChatCaller, StreamingChatClient { - private static final Logger logger = LoggerFactory.getLogger(AnthropicModelCall.class); + private static final Logger logger = LoggerFactory.getLogger(AnthropicModelCaller.class); public static final String DEFAULT_MODEL_NAME = AnthropicApi.ChatModel.CLAUDE_3_OPUS.getValue(); @@ -89,10 +89,10 @@ public class AnthropicModelCall extends public final RetryTemplate retryTemplate; /** - * Construct a new {@link AnthropicModelCall} instance. + * Construct a new {@link AnthropicModelCaller} instance. * @param anthropicApi the lower-level API for the Anthropic service. */ - public AnthropicModelCall(AnthropicApi anthropicApi) { + public AnthropicModelCaller(AnthropicApi anthropicApi) { this(anthropicApi, AnthropicChatOptions.builder() .withModel(DEFAULT_MODEL_NAME) @@ -102,34 +102,34 @@ public class AnthropicModelCall extends } /** - * Construct a new {@link AnthropicModelCall} instance. + * Construct a new {@link AnthropicModelCaller} instance. * @param anthropicApi the lower-level API for the Anthropic service. * @param defaultOptions the default options used for the chat completion requests. */ - public AnthropicModelCall(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions) { + public AnthropicModelCaller(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions) { this(anthropicApi, defaultOptions, RetryUtils.DEFAULT_RETRY_TEMPLATE); } /** - * Construct a new {@link AnthropicModelCall} instance. + * Construct a new {@link AnthropicModelCaller} instance. * @param anthropicApi the lower-level API for the Anthropic service. * @param defaultOptions the default options used for the chat completion requests. * @param retryTemplate the retry template used to retry the Anthropic API calls. */ - public AnthropicModelCall(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions, + public AnthropicModelCaller(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions, RetryTemplate retryTemplate) { this(anthropicApi, defaultOptions, retryTemplate, null); } /** - * Construct a new {@link AnthropicModelCall} instance. + * Construct a new {@link AnthropicModelCaller} instance. * @param anthropicApi the lower-level API for the Anthropic service. * @param defaultOptions the default options used for the chat completion requests. * @param retryTemplate the retry template used to retry the Anthropic API calls. * @param functionCallbackContext the function callback context used to store the * state of the function calls. */ - public AnthropicModelCall(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions, + public AnthropicModelCaller(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions, RetryTemplate retryTemplate, FunctionCallbackContext functionCallbackContext) { super(functionCallbackContext); diff --git a/models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/AnthropicModelCallIT.java b/models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/AnthropicModelCallerIT.java similarity index 98% rename from models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/AnthropicModelCallIT.java rename to models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/AnthropicModelCallerIT.java index 60e663143..dc586ff7a 100644 --- a/models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/AnthropicModelCallIT.java +++ b/models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/AnthropicModelCallerIT.java @@ -29,7 +29,7 @@ import org.slf4j.LoggerFactory; import org.springframework.ai.anthropic.api.AnthropicApi; import org.springframework.ai.anthropic.api.tool.MockWeatherService; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.Generation; import org.springframework.ai.chat.StreamingChatClient; @@ -56,12 +56,12 @@ import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest(classes = AnthropicTestConfiguration.class, properties = "spring.ai.retry.on-http-codes=429") @EnabledIfEnvironmentVariable(named = "ANTHROPIC_API_KEY", matches = ".+") -class AnthropicModelCallIT { +class AnthropicModelCallerIT { - private static final Logger logger = LoggerFactory.getLogger(AnthropicModelCallIT.class); + private static final Logger logger = LoggerFactory.getLogger(AnthropicModelCallerIT.class); @Autowired - protected ModelCall modelCall; + protected ChatCaller modelCall; @Autowired protected StreamingChatClient streamingChatClient; diff --git a/models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/AnthropicTestConfiguration.java b/models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/AnthropicTestConfiguration.java index 7b7923daf..4854ebaf9 100644 --- a/models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/AnthropicTestConfiguration.java +++ b/models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/AnthropicTestConfiguration.java @@ -38,8 +38,8 @@ public class AnthropicTestConfiguration { } @Bean - public AnthropicModelCall openAiChatClient(AnthropicApi api) { - AnthropicModelCall anthropicChatClient = new AnthropicModelCall(api); + public AnthropicModelCaller openAiChatClient(AnthropicApi api) { + AnthropicModelCaller anthropicChatClient = new AnthropicModelCaller(api); return anthropicChatClient; } diff --git a/models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/ChatCompletionRequestTests.java b/models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/ChatCompletionRequestTests.java index 3bf6eaae3..f940608b3 100644 --- a/models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/ChatCompletionRequestTests.java +++ b/models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/ChatCompletionRequestTests.java @@ -30,7 +30,7 @@ public class ChatCompletionRequestTests { @Test public void createRequestWithChatOptions() { - var client = new AnthropicModelCall(new AnthropicApi("TEST"), + var client = new AnthropicModelCaller(new AnthropicApi("TEST"), AnthropicChatOptions.builder().withModel("DEFAULT_MODEL").withTemperature(66.6f).build()); var request = client.createRequest(new Prompt("Test message content"), false); diff --git a/models/spring-ai-azure-openai/src/main/java/org/springframework/ai/azure/openai/AzureOpenAiModelCall.java b/models/spring-ai-azure-openai/src/main/java/org/springframework/ai/azure/openai/AzureOpenAiModelCaller.java similarity index 97% rename from models/spring-ai-azure-openai/src/main/java/org/springframework/ai/azure/openai/AzureOpenAiModelCall.java rename to models/spring-ai-azure-openai/src/main/java/org/springframework/ai/azure/openai/AzureOpenAiModelCaller.java index 5eb8ed2de..2b99aada9 100644 --- a/models/spring-ai-azure-openai/src/main/java/org/springframework/ai/azure/openai/AzureOpenAiModelCall.java +++ b/models/spring-ai-azure-openai/src/main/java/org/springframework/ai/azure/openai/AzureOpenAiModelCaller.java @@ -38,7 +38,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.ai.azure.openai.metadata.AzureOpenAiChatResponseMetadata; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.Generation; import org.springframework.ai.chat.StreamingChatClient; @@ -63,7 +63,7 @@ import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; /** - * {@link ModelCall} implementation for {@literal Microsoft Azure AI} backed by + * {@link ChatCaller} implementation for {@literal Microsoft Azure AI} backed by * {@link OpenAIClient}. * * @author Mark Pollack @@ -71,12 +71,12 @@ import java.util.concurrent.atomic.AtomicBoolean; * @author John Blum * @author Christian Tzolov * @author Grogdunn - * @see ModelCall + * @see ChatCaller * @see com.azure.ai.openai.OpenAIClient */ -public class AzureOpenAiModelCall +public class AzureOpenAiModelCaller extends AbstractFunctionCallSupport - implements ModelCall, StreamingChatClient { + implements ChatCaller, StreamingChatClient { private static final String DEFAULT_DEPLOYMENT_NAME = "gpt-35-turbo"; @@ -94,7 +94,7 @@ public class AzureOpenAiModelCall */ private final OpenAIClient openAIClient; - public AzureOpenAiModelCall(OpenAIClient microsoftOpenAiClient) { + public AzureOpenAiModelCaller(OpenAIClient microsoftOpenAiClient) { this(microsoftOpenAiClient, AzureOpenAiChatOptions.builder() .withDeploymentName(DEFAULT_DEPLOYMENT_NAME) @@ -102,11 +102,11 @@ public class AzureOpenAiModelCall .build()); } - public AzureOpenAiModelCall(OpenAIClient microsoftOpenAiClient, AzureOpenAiChatOptions options) { + public AzureOpenAiModelCaller(OpenAIClient microsoftOpenAiClient, AzureOpenAiChatOptions options) { this(microsoftOpenAiClient, options, null); } - public AzureOpenAiModelCall(OpenAIClient microsoftOpenAiClient, AzureOpenAiChatOptions options, + public AzureOpenAiModelCaller(OpenAIClient microsoftOpenAiClient, AzureOpenAiChatOptions options, FunctionCallbackContext functionCallbackContext) { super(functionCallbackContext); Assert.notNull(microsoftOpenAiClient, "com.azure.ai.openai.OpenAIClient must not be null"); @@ -120,7 +120,7 @@ public class AzureOpenAiModelCall * {@link #AzureOpenAiModelCall(OpenAIClient, AzureOpenAiChatOptions)} instead. */ @Deprecated(forRemoval = true, since = "0.8.0") - public AzureOpenAiModelCall withDefaultOptions(AzureOpenAiChatOptions defaultOptions) { + public AzureOpenAiModelCaller withDefaultOptions(AzureOpenAiChatOptions defaultOptions) { Assert.notNull(defaultOptions, "DefaultOptions must not be null"); this.defaultOptions = defaultOptions; return this; diff --git a/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/AzureChatCompletionsOptionsTests.java b/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/AzureChatCompletionsOptionsTests.java index abe5c81c5..fd74126aa 100644 --- a/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/AzureChatCompletionsOptionsTests.java +++ b/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/AzureChatCompletionsOptionsTests.java @@ -53,7 +53,7 @@ public class AzureChatCompletionsOptionsTests { .withUser("user") .build(); - var client = new AzureOpenAiModelCall(mockClient, defaultOptions); + var client = new AzureOpenAiModelCaller(mockClient, defaultOptions); var requestOptions = client.toAzureChatCompletionsOptions(new Prompt("Test message content")); diff --git a/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/AzureOpenAiModelCallIT.java b/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/AzureOpenAiModelCallIerT.java similarity index 96% rename from models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/AzureOpenAiModelCallIT.java rename to models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/AzureOpenAiModelCallIerT.java index aa66a3266..d9fe83ee3 100644 --- a/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/AzureOpenAiModelCallIT.java +++ b/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/AzureOpenAiModelCallIerT.java @@ -46,13 +46,13 @@ import org.springframework.core.convert.support.DefaultConversionService; import static org.assertj.core.api.Assertions.assertThat; -@SpringBootTest(classes = AzureOpenAiModelCallIT.TestConfiguration.class) +@SpringBootTest(classes = AzureOpenAiModelCallIerT.TestConfiguration.class) @EnabledIfEnvironmentVariable(named = "AZURE_OPENAI_API_KEY", matches = ".+") @EnabledIfEnvironmentVariable(named = "AZURE_OPENAI_ENDPOINT", matches = ".+") -class AzureOpenAiModelCallIT { +class AzureOpenAiModelCallIerT { @Autowired - private AzureOpenAiModelCall chatClient; + private AzureOpenAiModelCaller chatClient; record ActorsFilms(String actor, List movies) { } @@ -194,8 +194,8 @@ class AzureOpenAiModelCallIT { } @Bean - public AzureOpenAiModelCall azureOpenAiChatClient(OpenAIClient openAIClient) { - return new AzureOpenAiModelCall(openAIClient, + public AzureOpenAiModelCaller azureOpenAiChatClient(OpenAIClient openAIClient) { + return new AzureOpenAiModelCaller(openAIClient, AzureOpenAiChatOptions.builder().withDeploymentName("gpt-35-turbo").withMaxTokens(200).build()); } diff --git a/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/MockAzureOpenAiTestConfiguration.java b/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/MockAzureOpenAiTestConfiguration.java index 3f848c095..5a5a3e176 100644 --- a/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/MockAzureOpenAiTestConfiguration.java +++ b/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/MockAzureOpenAiTestConfiguration.java @@ -59,8 +59,8 @@ public class MockAzureOpenAiTestConfiguration { } @Bean - AzureOpenAiModelCall azureOpenAiChatClient(OpenAIClient microsoftAzureOpenAiClient) { - return new AzureOpenAiModelCall(microsoftAzureOpenAiClient); + AzureOpenAiModelCaller azureOpenAiChatClient(OpenAIClient microsoftAzureOpenAiClient) { + return new AzureOpenAiModelCaller(microsoftAzureOpenAiClient); } } diff --git a/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/function/AzureOpenAiModelCallFunctionCallIT.java b/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/function/AzureOpenAiModelCallFunctionCallIT.java index a5f81ee31..7c31871db 100644 --- a/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/function/AzureOpenAiModelCallFunctionCallIT.java +++ b/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/function/AzureOpenAiModelCallFunctionCallIT.java @@ -29,7 +29,7 @@ import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.ai.azure.openai.AzureOpenAiModelCall; +import org.springframework.ai.azure.openai.AzureOpenAiModelCaller; import org.springframework.ai.azure.openai.AzureOpenAiChatOptions; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.Generation; @@ -57,7 +57,7 @@ class AzureOpenAiModelCallFunctionCallIT { private String selectedModel; @Autowired - private AzureOpenAiModelCall chatClient; + private AzureOpenAiModelCaller chatClient; @Test void functionCallTest() { @@ -129,8 +129,8 @@ class AzureOpenAiModelCallFunctionCallIT { } @Bean - public AzureOpenAiModelCall azureOpenAiChatClient(OpenAIClient openAIClient, String selectedModel) { - return new AzureOpenAiModelCall(openAIClient, + public AzureOpenAiModelCaller azureOpenAiChatClient(OpenAIClient openAIClient, String selectedModel) { + return new AzureOpenAiModelCaller(openAIClient, AzureOpenAiChatOptions.builder().withDeploymentName(selectedModel).withMaxTokens(500).build()); } diff --git a/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/metadata/AzureOpenAiModelCallMetadataTests.java b/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/metadata/AzureOpenAiModelCallMetadataTests.java index 821c33a62..7f1adba15 100644 --- a/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/metadata/AzureOpenAiModelCallMetadataTests.java +++ b/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/metadata/AzureOpenAiModelCallMetadataTests.java @@ -23,7 +23,7 @@ import com.azure.ai.openai.models.ContentFilterResultsForChoice; import com.azure.ai.openai.models.ContentFilterSeverity; import org.junit.jupiter.api.Test; -import org.springframework.ai.azure.openai.AzureOpenAiModelCall; +import org.springframework.ai.azure.openai.AzureOpenAiModelCaller; import org.springframework.ai.azure.openai.MockAzureOpenAiTestConfiguration; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.Generation; @@ -55,7 +55,7 @@ import org.springframework.web.context.request.WebRequest; import static org.assertj.core.api.Assertions.assertThat; /** - * Unit Tests for {@link AzureOpenAiModelCall} asserting AI metadata. + * Unit Tests for {@link AzureOpenAiModelCaller} asserting AI metadata. * * @author John Blum * @author Christian Tzolov @@ -68,7 +68,7 @@ import static org.assertj.core.api.Assertions.assertThat; class AzureOpenAiModelCallMetadataTests { @Autowired - private AzureOpenAiModelCall aiClient; + private AzureOpenAiModelCaller aiClient; @Test void azureOpenAiMetadataCapturedDuringGeneration() { diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic/BedrockAnthropicModelCall.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic/BedrockAnthropicModelCaller.java similarity index 90% rename from models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic/BedrockAnthropicModelCall.java rename to models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic/BedrockAnthropicModelCaller.java index 6623bf53e..410cf2a10 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic/BedrockAnthropicModelCall.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic/BedrockAnthropicModelCaller.java @@ -17,7 +17,7 @@ package org.springframework.ai.bedrock.anthropic; import java.util.List; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.chat.prompt.ChatOptions; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.metadata.ChatGenerationMetadata; @@ -33,19 +33,19 @@ import org.springframework.ai.chat.prompt.Prompt; import org.springframework.ai.model.ModelOptionsUtils; /** - * Java {@link ModelCall} and {@link StreamingChatClient} for the Bedrock Anthropic chat + * Java {@link ChatCaller} and {@link StreamingChatClient} for the Bedrock Anthropic chat * generative. * * @author Christian Tzolov * @since 0.8.0 */ -public class BedrockAnthropicModelCall implements ModelCall, StreamingChatClient { +public class BedrockAnthropicModelCaller implements ChatCaller, StreamingChatClient { private final AnthropicChatBedrockApi anthropicChatApi; private final AnthropicChatOptions defaultOptions; - public BedrockAnthropicModelCall(AnthropicChatBedrockApi chatApi) { + public BedrockAnthropicModelCaller(AnthropicChatBedrockApi chatApi) { this(chatApi, AnthropicChatOptions.builder() .withTemperature(0.8f) @@ -55,7 +55,7 @@ public class BedrockAnthropicModelCall implements ModelCall, StreamingChatClient .build()); } - public BedrockAnthropicModelCall(AnthropicChatBedrockApi chatApi, AnthropicChatOptions options) { + public BedrockAnthropicModelCaller(AnthropicChatBedrockApi chatApi, AnthropicChatOptions options) { this.anthropicChatApi = chatApi; this.defaultOptions = options; } diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3ModelCall.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3ModelCaller.java similarity index 94% rename from models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3ModelCall.java rename to models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3ModelCaller.java index 0a3eada5c..d24177c73 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3ModelCall.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3ModelCaller.java @@ -22,7 +22,7 @@ import org.springframework.ai.bedrock.anthropic3.api.Anthropic3ChatBedrockApi.An import org.springframework.ai.bedrock.anthropic3.api.Anthropic3ChatBedrockApi.MediaContent; import org.springframework.ai.bedrock.anthropic3.api.Anthropic3ChatBedrockApi.ChatCompletionMessage; import org.springframework.ai.bedrock.anthropic3.api.Anthropic3ChatBedrockApi.ChatCompletionMessage.Role; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.Generation; import org.springframework.ai.chat.StreamingChatClient; @@ -43,20 +43,20 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; /** - * Java {@link ModelCall} and {@link StreamingChatClient} for the Bedrock Anthropic chat + * Java {@link ChatCaller} and {@link StreamingChatClient} for the Bedrock Anthropic chat * generative. * * @author Ben Middleton * @author Christian Tzolov * @since 1.0.0 */ -public class BedrockAnthropic3ModelCall implements ModelCall, StreamingChatClient { +public class BedrockAnthropic3ModelCaller implements ChatCaller, StreamingChatClient { private final Anthropic3ChatBedrockApi anthropicChatApi; private final Anthropic3ChatOptions defaultOptions; - public BedrockAnthropic3ModelCall(Anthropic3ChatBedrockApi chatApi) { + public BedrockAnthropic3ModelCaller(Anthropic3ChatBedrockApi chatApi) { this(chatApi, Anthropic3ChatOptions.builder() .withTemperature(0.8f) @@ -66,7 +66,7 @@ public class BedrockAnthropic3ModelCall implements ModelCall, StreamingChatClien .build()); } - public BedrockAnthropic3ModelCall(Anthropic3ChatBedrockApi chatApi, Anthropic3ChatOptions options) { + public BedrockAnthropic3ModelCaller(Anthropic3ChatBedrockApi chatApi, Anthropic3ChatOptions options) { this.anthropicChatApi = chatApi; this.defaultOptions = options; } diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/BedrockCohereModelCall.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/BedrockCohereModelCaller.java similarity index 93% rename from models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/BedrockCohereModelCall.java rename to models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/BedrockCohereModelCaller.java index f5190a6b7..b7592f5ac 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/BedrockCohereModelCall.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/cohere/BedrockCohereModelCaller.java @@ -24,7 +24,7 @@ import org.springframework.ai.bedrock.MessageToPromptConverter; import org.springframework.ai.bedrock.cohere.api.CohereChatBedrockApi; import org.springframework.ai.bedrock.cohere.api.CohereChatBedrockApi.CohereChatRequest; import org.springframework.ai.bedrock.cohere.api.CohereChatBedrockApi.CohereChatResponse; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.chat.prompt.ChatOptions; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.Generation; @@ -39,17 +39,17 @@ import org.springframework.util.Assert; * @author Christian Tzolov * @since 0.8.0 */ -public class BedrockCohereModelCall implements ModelCall, StreamingChatClient { +public class BedrockCohereModelCaller implements ChatCaller, StreamingChatClient { private final CohereChatBedrockApi chatApi; private final BedrockCohereChatOptions defaultOptions; - public BedrockCohereModelCall(CohereChatBedrockApi chatApi) { + public BedrockCohereModelCaller(CohereChatBedrockApi chatApi) { this(chatApi, BedrockCohereChatOptions.builder().build()); } - public BedrockCohereModelCall(CohereChatBedrockApi chatApi, BedrockCohereChatOptions options) { + public BedrockCohereModelCaller(CohereChatBedrockApi chatApi, BedrockCohereChatOptions options) { Assert.notNull(chatApi, "CohereChatBedrockApi must not be null"); Assert.notNull(options, "BedrockCohereChatOptions must not be null"); diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ModelCall.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ModelCaller.java similarity index 88% rename from models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ModelCall.java rename to models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ModelCaller.java index ee86bad89..e75f8616d 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ModelCall.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ModelCaller.java @@ -19,7 +19,7 @@ package org.springframework.ai.bedrock.jurassic2; import org.springframework.ai.bedrock.MessageToPromptConverter; import org.springframework.ai.bedrock.jurassic2.api.Ai21Jurassic2ChatBedrockApi; import org.springframework.ai.bedrock.jurassic2.api.Ai21Jurassic2ChatBedrockApi.Ai21Jurassic2ChatRequest; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.Generation; import org.springframework.ai.chat.metadata.ChatGenerationMetadata; @@ -29,18 +29,19 @@ import org.springframework.ai.model.ModelOptionsUtils; import org.springframework.util.Assert; /** - * Java {@link ModelCall} for the Bedrock Jurassic2 chat generative model. + * Java {@link ChatCaller} for the Bedrock Jurassic2 chat generative model. * * @author Ahmed Yousri * @since 1.0.0 */ -public class BedrockAi21Jurassic2ModelCall implements ModelCall { +public class BedrockAi21Jurassic2ModelCaller implements ChatCaller { private final Ai21Jurassic2ChatBedrockApi chatApi; private final BedrockAi21Jurassic2ChatOptions defaultOptions; - public BedrockAi21Jurassic2ModelCall(Ai21Jurassic2ChatBedrockApi chatApi, BedrockAi21Jurassic2ChatOptions options) { + public BedrockAi21Jurassic2ModelCaller(Ai21Jurassic2ChatBedrockApi chatApi, + BedrockAi21Jurassic2ChatOptions options) { Assert.notNull(chatApi, "Ai21Jurassic2ChatBedrockApi must not be null"); Assert.notNull(options, "BedrockAi21Jurassic2ChatOptions must not be null"); @@ -48,7 +49,7 @@ public class BedrockAi21Jurassic2ModelCall implements ModelCall { this.defaultOptions = options; } - public BedrockAi21Jurassic2ModelCall(Ai21Jurassic2ChatBedrockApi chatApi) { + public BedrockAi21Jurassic2ModelCaller(Ai21Jurassic2ChatBedrockApi chatApi) { this(chatApi, BedrockAi21Jurassic2ChatOptions.builder() .withTemperature(0.8f) @@ -113,8 +114,8 @@ public class BedrockAi21Jurassic2ModelCall implements ModelCall { return this; } - public BedrockAi21Jurassic2ModelCall build() { - return new BedrockAi21Jurassic2ModelCall(chatApi, + public BedrockAi21Jurassic2ModelCaller build() { + return new BedrockAi21Jurassic2ModelCaller(chatApi, options != null ? options : BedrockAi21Jurassic2ChatOptions.builder().build()); } diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/llama/BedrockLlamaModelCall.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/llama/BedrockLlamaModelCaller.java similarity index 91% rename from models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/llama/BedrockLlamaModelCall.java rename to models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/llama/BedrockLlamaModelCaller.java index b1780f4ed..441de3556 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/llama/BedrockLlamaModelCall.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/llama/BedrockLlamaModelCaller.java @@ -23,7 +23,7 @@ import org.springframework.ai.bedrock.MessageToPromptConverter; import org.springframework.ai.bedrock.llama.api.LlamaChatBedrockApi; import org.springframework.ai.bedrock.llama.api.LlamaChatBedrockApi.LlamaChatRequest; import org.springframework.ai.bedrock.llama.api.LlamaChatBedrockApi.LlamaChatResponse; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.chat.prompt.ChatOptions; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.Generation; @@ -35,25 +35,25 @@ import org.springframework.ai.model.ModelOptionsUtils; import org.springframework.util.Assert; /** - * Java {@link ModelCall} and {@link StreamingChatClient} for the Bedrock Llama chat + * Java {@link ChatCaller} and {@link StreamingChatClient} for the Bedrock Llama chat * generative. * * @author Christian Tzolov * @author Wei Jiang * @since 0.8.0 */ -public class BedrockLlamaModelCall implements ModelCall, StreamingChatClient { +public class BedrockLlamaModelCaller implements ChatCaller, StreamingChatClient { private final LlamaChatBedrockApi chatApi; private final BedrockLlamaChatOptions defaultOptions; - public BedrockLlamaModelCall(LlamaChatBedrockApi chatApi) { + public BedrockLlamaModelCaller(LlamaChatBedrockApi chatApi) { this(chatApi, BedrockLlamaChatOptions.builder().withTemperature(0.8f).withTopP(0.9f).withMaxGenLen(100).build()); } - public BedrockLlamaModelCall(LlamaChatBedrockApi chatApi, BedrockLlamaChatOptions options) { + public BedrockLlamaModelCaller(LlamaChatBedrockApi chatApi, BedrockLlamaChatOptions options) { Assert.notNull(chatApi, "LlamaChatBedrockApi must not be null"); Assert.notNull(options, "BedrockLlamaChatOptions must not be null"); diff --git a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/titan/BedrockTitanModelCall.java b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/titan/BedrockTitanModelCaller.java similarity index 94% rename from models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/titan/BedrockTitanModelCall.java rename to models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/titan/BedrockTitanModelCaller.java index 0ce4c27e4..9e70a9d1e 100644 --- a/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/titan/BedrockTitanModelCall.java +++ b/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/titan/BedrockTitanModelCaller.java @@ -24,7 +24,7 @@ import org.springframework.ai.bedrock.titan.api.TitanChatBedrockApi; import org.springframework.ai.bedrock.titan.api.TitanChatBedrockApi.TitanChatRequest; import org.springframework.ai.bedrock.titan.api.TitanChatBedrockApi.TitanChatResponse; import org.springframework.ai.bedrock.titan.api.TitanChatBedrockApi.TitanChatResponseChunk; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.chat.prompt.ChatOptions; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.Generation; @@ -39,17 +39,17 @@ import org.springframework.util.Assert; * @author Christian Tzolov * @since 0.8.0 */ -public class BedrockTitanModelCall implements ModelCall, StreamingChatClient { +public class BedrockTitanModelCaller implements ChatCaller, StreamingChatClient { private final TitanChatBedrockApi chatApi; private final BedrockTitanChatOptions defaultOptions; - public BedrockTitanModelCall(TitanChatBedrockApi chatApi) { + public BedrockTitanModelCaller(TitanChatBedrockApi chatApi) { this(chatApi, BedrockTitanChatOptions.builder().withTemperature(0.8f).build()); } - public BedrockTitanModelCall(TitanChatBedrockApi chatApi, BedrockTitanChatOptions defaultOptions) { + public BedrockTitanModelCaller(TitanChatBedrockApi chatApi, BedrockTitanChatOptions defaultOptions) { Assert.notNull(chatApi, "ChatApi must not be null"); Assert.notNull(defaultOptions, "DefaultOptions must not be null"); this.chatApi = chatApi; diff --git a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic/BedrockAnthropicCreateRequestTests.java b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic/BedrockAnthropicCreateRequestTests.java index 82a0e0a98..829a50ddf 100644 --- a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic/BedrockAnthropicCreateRequestTests.java +++ b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic/BedrockAnthropicCreateRequestTests.java @@ -38,7 +38,7 @@ public class BedrockAnthropicCreateRequestTests { @Test public void createRequestWithChatOptions() { - var client = new BedrockAnthropicModelCall(anthropicChatApi, + var client = new BedrockAnthropicModelCaller(anthropicChatApi, AnthropicChatOptions.builder() .withTemperature(66.6f) .withTopK(66) diff --git a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic/BedrockAnthropicModelCallIT.java b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic/BedrockAnthropicModelCallerIT.java similarity index 96% rename from models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic/BedrockAnthropicModelCallIT.java rename to models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic/BedrockAnthropicModelCallerIT.java index 00f1aace1..b542c2b4f 100644 --- a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic/BedrockAnthropicModelCallIT.java +++ b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic/BedrockAnthropicModelCallerIT.java @@ -55,12 +55,12 @@ import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest @EnabledIfEnvironmentVariable(named = "AWS_ACCESS_KEY_ID", matches = ".*") @EnabledIfEnvironmentVariable(named = "AWS_SECRET_ACCESS_KEY", matches = ".*") -class BedrockAnthropicModelCallIT { +class BedrockAnthropicModelCallerIT { - private static final Logger logger = LoggerFactory.getLogger(BedrockAnthropicModelCallIT.class); + private static final Logger logger = LoggerFactory.getLogger(BedrockAnthropicModelCallerIT.class); @Autowired - private BedrockAnthropicModelCall client; + private BedrockAnthropicModelCaller client; @Value("classpath:/prompts/system-message.st") private Resource systemResource; @@ -209,8 +209,8 @@ class BedrockAnthropicModelCallIT { } @Bean - public BedrockAnthropicModelCall anthropicChatClient(AnthropicChatBedrockApi anthropicApi) { - return new BedrockAnthropicModelCall(anthropicApi); + public BedrockAnthropicModelCaller anthropicChatClient(AnthropicChatBedrockApi anthropicApi) { + return new BedrockAnthropicModelCaller(anthropicApi); } } diff --git a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3CreateRequestTests.java b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3CreateRequestTests.java index 038a63a59..e6820a465 100644 --- a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3CreateRequestTests.java +++ b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3CreateRequestTests.java @@ -37,7 +37,7 @@ public class BedrockAnthropic3CreateRequestTests { @Test public void createRequestWithChatOptions() { - var client = new BedrockAnthropic3ModelCall(anthropicChatApi, + var client = new BedrockAnthropic3ModelCaller(anthropicChatApi, Anthropic3ChatOptions.builder() .withTemperature(66.6f) .withTopK(66) diff --git a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3ModelCallIT.java b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3ModelCallerIT.java similarity index 96% rename from models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3ModelCallIT.java rename to models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3ModelCallerIT.java index 1ea86afb9..3c721d27a 100644 --- a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3ModelCallIT.java +++ b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic3/BedrockAnthropic3ModelCallerIT.java @@ -59,12 +59,12 @@ import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest @EnabledIfEnvironmentVariable(named = "AWS_ACCESS_KEY_ID", matches = ".*") @EnabledIfEnvironmentVariable(named = "AWS_SECRET_ACCESS_KEY", matches = ".*") -class BedrockAnthropic3ModelCallIT { +class BedrockAnthropic3ModelCallerIT { - private static final Logger logger = LoggerFactory.getLogger(BedrockAnthropic3ModelCallIT.class); + private static final Logger logger = LoggerFactory.getLogger(BedrockAnthropic3ModelCallerIT.class); @Autowired - private BedrockAnthropic3ModelCall client; + private BedrockAnthropic3ModelCaller client; @Value("classpath:/prompts/system-message.st") private Resource systemResource; @@ -228,8 +228,8 @@ class BedrockAnthropic3ModelCallIT { } @Bean - public BedrockAnthropic3ModelCall anthropicChatClient(Anthropic3ChatBedrockApi anthropicApi) { - return new BedrockAnthropic3ModelCall(anthropicApi); + public BedrockAnthropic3ModelCaller anthropicChatClient(Anthropic3ChatBedrockApi anthropicApi) { + return new BedrockAnthropic3ModelCaller(anthropicApi); } } diff --git a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/BedrockCohereChatCreateRequestTests.java b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/BedrockCohereChatCreateRequestTests.java index 8b0ef7293..85f2cf5b3 100644 --- a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/BedrockCohereChatCreateRequestTests.java +++ b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/BedrockCohereChatCreateRequestTests.java @@ -45,7 +45,7 @@ public class BedrockCohereChatCreateRequestTests { @Test public void createRequestWithChatOptions() { - var client = new BedrockCohereModelCall(chatApi, + var client = new BedrockCohereModelCaller(chatApi, BedrockCohereChatOptions.builder() .withTemperature(66.6f) .withTopK(66) diff --git a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/BedrockCohereModelCallIT.java b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/BedrockCohereModelCallerIT.java similarity index 97% rename from models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/BedrockCohereModelCallIT.java rename to models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/BedrockCohereModelCallerIT.java index f189b2769..406902437 100644 --- a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/BedrockCohereModelCallIT.java +++ b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/BedrockCohereModelCallerIT.java @@ -54,10 +54,10 @@ import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest @EnabledIfEnvironmentVariable(named = "AWS_ACCESS_KEY_ID", matches = ".*") @EnabledIfEnvironmentVariable(named = "AWS_SECRET_ACCESS_KEY", matches = ".*") -class BedrockCohereModelCallIT { +class BedrockCohereModelCallerIT { @Autowired - private BedrockCohereModelCall client; + private BedrockCohereModelCaller client; @Value("classpath:/prompts/system-message.st") private Resource systemResource; @@ -205,8 +205,8 @@ class BedrockCohereModelCallIT { } @Bean - public BedrockCohereModelCall cohereChatClient(CohereChatBedrockApi cohereApi) { - return new BedrockCohereModelCall(cohereApi); + public BedrockCohereModelCaller cohereChatClient(CohereChatBedrockApi cohereApi) { + return new BedrockCohereModelCaller(cohereApi); } } diff --git a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ModelCallIT.java b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ModelCallerIT.java similarity index 96% rename from models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ModelCallIT.java rename to models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ModelCallerIT.java index 27bdf75b2..36166e71e 100644 --- a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ModelCallIT.java +++ b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ModelCallerIT.java @@ -49,10 +49,10 @@ import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest @EnabledIfEnvironmentVariable(named = "AWS_ACCESS_KEY_ID", matches = ".*") @EnabledIfEnvironmentVariable(named = "AWS_SECRET_ACCESS_KEY", matches = ".*") -class BedrockAi21Jurassic2ModelCallIT { +class BedrockAi21Jurassic2ModelCallerIT { @Autowired - private BedrockAi21Jurassic2ModelCall client; + private BedrockAi21Jurassic2ModelCaller client; @Value("classpath:/prompts/system-message.st") private Resource systemResource; @@ -152,9 +152,9 @@ class BedrockAi21Jurassic2ModelCallIT { } @Bean - public BedrockAi21Jurassic2ModelCall bedrockAi21Jurassic2ChatClient( + public BedrockAi21Jurassic2ModelCaller bedrockAi21Jurassic2ChatClient( Ai21Jurassic2ChatBedrockApi jurassic2ChatBedrockApi) { - return new BedrockAi21Jurassic2ModelCall(jurassic2ChatBedrockApi, + return new BedrockAi21Jurassic2ModelCaller(jurassic2ChatBedrockApi, BedrockAi21Jurassic2ChatOptions.builder() .withTemperature(0.5f) .withMaxTokens(100) diff --git a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/llama/BedrockLlamaCreateRequestTests.java b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/llama/BedrockLlamaCreateRequestTests.java index 0bc14ab7d..353996442 100644 --- a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/llama/BedrockLlamaCreateRequestTests.java +++ b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/llama/BedrockLlamaCreateRequestTests.java @@ -45,7 +45,7 @@ public class BedrockLlamaCreateRequestTests { @Test public void createRequestWithChatOptions() { - var client = new BedrockLlamaModelCall(api, + var client = new BedrockLlamaModelCaller(api, BedrockLlamaChatOptions.builder().withTemperature(66.6f).withMaxGenLen(666).withTopP(0.66f).build()); var request = client.createRequest(new Prompt("Test message content")); diff --git a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/llama/BedrockLlamaModelCallIT.java b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/llama/BedrockLlamaModelCallerIT.java similarity index 97% rename from models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/llama/BedrockLlamaModelCallIT.java rename to models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/llama/BedrockLlamaModelCallerIT.java index 95bafb7a7..651e0f1a3 100644 --- a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/llama/BedrockLlamaModelCallIT.java +++ b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/llama/BedrockLlamaModelCallerIT.java @@ -54,10 +54,10 @@ import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest @EnabledIfEnvironmentVariable(named = "AWS_ACCESS_KEY_ID", matches = ".*") @EnabledIfEnvironmentVariable(named = "AWS_SECRET_ACCESS_KEY", matches = ".*") -class BedrockLlamaModelCallIT { +class BedrockLlamaModelCallerIT { @Autowired - private BedrockLlamaModelCall client; + private BedrockLlamaModelCaller client; @Value("classpath:/prompts/system-message.st") private Resource systemResource; @@ -206,8 +206,8 @@ class BedrockLlamaModelCallIT { } @Bean - public BedrockLlamaModelCall llamaChatClient(LlamaChatBedrockApi llamaApi) { - return new BedrockLlamaModelCall(llamaApi, + public BedrockLlamaModelCaller llamaChatClient(LlamaChatBedrockApi llamaApi) { + return new BedrockLlamaModelCaller(llamaApi, BedrockLlamaChatOptions.builder().withTemperature(0.5f).withMaxGenLen(100).withTopP(0.9f).build()); } diff --git a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/titan/BedrockTitanChatCreateRequestTests.java b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/titan/BedrockTitanChatCreateRequestTests.java index d488d124a..d08ee8817 100644 --- a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/titan/BedrockTitanChatCreateRequestTests.java +++ b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/titan/BedrockTitanChatCreateRequestTests.java @@ -41,7 +41,7 @@ public class BedrockTitanChatCreateRequestTests { @Test public void createRequestWithChatOptions() { - var client = new BedrockTitanModelCall(api, + var client = new BedrockTitanModelCaller(api, BedrockTitanChatOptions.builder() .withTemperature(66.6f) .withTopP(0.66f) diff --git a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/titan/BedrockTitanModelCallIT.java b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/titan/BedrockTitanModelCalerlIT.java similarity index 97% rename from models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/titan/BedrockTitanModelCallIT.java rename to models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/titan/BedrockTitanModelCalerlIT.java index 0351de783..5ce5d4ef6 100644 --- a/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/titan/BedrockTitanModelCallIT.java +++ b/models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/titan/BedrockTitanModelCalerlIT.java @@ -55,10 +55,10 @@ import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest @EnabledIfEnvironmentVariable(named = "AWS_ACCESS_KEY_ID", matches = ".*") @EnabledIfEnvironmentVariable(named = "AWS_SECRET_ACCESS_KEY", matches = ".*") -class BedrockTitanModelCallIT { +class BedrockTitanModelCalerlIT { @Autowired - private BedrockTitanModelCall client; + private BedrockTitanModelCaller client; @Value("classpath:/prompts/system-message.st") private Resource systemResource; @@ -211,8 +211,8 @@ class BedrockTitanModelCallIT { } @Bean - public BedrockTitanModelCall titanChatClient(TitanChatBedrockApi titanApi) { - return new BedrockTitanModelCall(titanApi); + public BedrockTitanModelCaller titanChatClient(TitanChatBedrockApi titanApi) { + return new BedrockTitanModelCaller(titanApi); } } diff --git a/models/spring-ai-huggingface/src/main/java/org/springframework/ai/huggingface/HuggingfaceModelCall.java b/models/spring-ai-huggingface/src/main/java/org/springframework/ai/huggingface/HuggingfaceModelCaller.java similarity index 93% rename from models/spring-ai-huggingface/src/main/java/org/springframework/ai/huggingface/HuggingfaceModelCall.java rename to models/spring-ai-huggingface/src/main/java/org/springframework/ai/huggingface/HuggingfaceModelCaller.java index ef68dd604..d0c603e9f 100644 --- a/models/spring-ai-huggingface/src/main/java/org/springframework/ai/huggingface/HuggingfaceModelCall.java +++ b/models/spring-ai-huggingface/src/main/java/org/springframework/ai/huggingface/HuggingfaceModelCaller.java @@ -22,7 +22,7 @@ import java.util.Map; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.Generation; import org.springframework.ai.huggingface.api.TextGenerationInferenceApi; @@ -34,12 +34,12 @@ import org.springframework.ai.huggingface.model.GenerateResponse; import org.springframework.ai.chat.prompt.Prompt; /** - * An implementation of {@link ModelCall} that interfaces with HuggingFace Inference + * An implementation of {@link ChatCaller} that interfaces with HuggingFace Inference * Endpoints for text generation. * * @author Mark Pollack */ -public class HuggingfaceModelCall implements ModelCall { +public class HuggingfaceModelCaller implements ChatCaller { /** * Token required for authenticating with the HuggingFace Inference API. @@ -72,7 +72,7 @@ public class HuggingfaceModelCall implements ModelCall { * @param apiToken The API token for HuggingFace. * @param basePath The base path for API requests. */ - public HuggingfaceModelCall(final String apiToken, String basePath) { + public HuggingfaceModelCaller(final String apiToken, String basePath) { this.apiToken = apiToken; this.apiClient.setBasePath(basePath); this.apiClient.addDefaultHeader("Authorization", "Bearer " + this.apiToken); diff --git a/models/spring-ai-huggingface/src/test/java/org/springframework/ai/huggingface/HuggingfaceTestConfiguration.java b/models/spring-ai-huggingface/src/test/java/org/springframework/ai/huggingface/HuggingfaceTestConfiguration.java index 8ceee3d74..60eaa772f 100644 --- a/models/spring-ai-huggingface/src/test/java/org/springframework/ai/huggingface/HuggingfaceTestConfiguration.java +++ b/models/spring-ai-huggingface/src/test/java/org/springframework/ai/huggingface/HuggingfaceTestConfiguration.java @@ -23,7 +23,7 @@ import org.springframework.util.StringUtils; public class HuggingfaceTestConfiguration { @Bean - public HuggingfaceModelCall huggingfaceChatClient() { + public HuggingfaceModelCaller huggingfaceChatClient() { String apiKey = System.getenv("HUGGINGFACE_API_KEY"); if (!StringUtils.hasText(apiKey)) { throw new IllegalArgumentException( @@ -31,7 +31,7 @@ public class HuggingfaceTestConfiguration { } // Created aws-mistral-7b-instruct-v0-1-805 via // https://ui.endpoints.huggingface.co/ - HuggingfaceModelCall huggingfaceChatClient = new HuggingfaceModelCall(apiKey, + HuggingfaceModelCaller huggingfaceChatClient = new HuggingfaceModelCaller(apiKey, "https://f6hg7b3cvlmntp5i.us-east-1.aws.endpoints.huggingface.cloud"); return huggingfaceChatClient; } diff --git a/models/spring-ai-huggingface/src/test/java/org/springframework/ai/huggingface/client/ClientIT.java b/models/spring-ai-huggingface/src/test/java/org/springframework/ai/huggingface/client/ClientIT.java index 24d528056..b55f4c22e 100644 --- a/models/spring-ai-huggingface/src/test/java/org/springframework/ai/huggingface/client/ClientIT.java +++ b/models/spring-ai-huggingface/src/test/java/org/springframework/ai/huggingface/client/ClientIT.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.springframework.ai.chat.ChatResponse; -import org.springframework.ai.huggingface.HuggingfaceModelCall; +import org.springframework.ai.huggingface.HuggingfaceModelCaller; import org.springframework.ai.chat.prompt.Prompt; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class ClientIT { @Autowired - protected HuggingfaceModelCall huggingfaceChatClient; + protected HuggingfaceModelCaller huggingfaceChatClient; @Test void helloWorldCompletion() { diff --git a/models/spring-ai-mistral-ai/src/main/java/org/springframework/ai/mistralai/MistralAiModelCall.java b/models/spring-ai-mistral-ai/src/main/java/org/springframework/ai/mistralai/MistralAiModelCaller.java similarity index 96% rename from models/spring-ai-mistral-ai/src/main/java/org/springframework/ai/mistralai/MistralAiModelCall.java rename to models/spring-ai-mistral-ai/src/main/java/org/springframework/ai/mistralai/MistralAiModelCaller.java index 12c03b5df..6267fd5e0 100644 --- a/models/spring-ai-mistral-ai/src/main/java/org/springframework/ai/mistralai/MistralAiModelCall.java +++ b/models/spring-ai-mistral-ai/src/main/java/org/springframework/ai/mistralai/MistralAiModelCaller.java @@ -17,7 +17,7 @@ package org.springframework.ai.mistralai; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.Generation; import org.springframework.ai.chat.StreamingChatClient; @@ -55,9 +55,9 @@ import java.util.concurrent.ConcurrentHashMap; * @author Grogdunn * @since 0.8.1 */ -public class MistralAiModelCall extends +public class MistralAiModelCaller extends AbstractFunctionCallSupport> - implements ModelCall, StreamingChatClient { + implements ChatCaller, StreamingChatClient { private final Logger log = LoggerFactory.getLogger(getClass()); @@ -73,7 +73,7 @@ public class MistralAiModelCall extends private final RetryTemplate retryTemplate; - public MistralAiModelCall(MistralAiApi mistralAiApi) { + public MistralAiModelCaller(MistralAiApi mistralAiApi) { this(mistralAiApi, MistralAiChatOptions.builder() .withTemperature(0.7f) @@ -83,11 +83,11 @@ public class MistralAiModelCall extends .build()); } - public MistralAiModelCall(MistralAiApi mistralAiApi, MistralAiChatOptions options) { + public MistralAiModelCaller(MistralAiApi mistralAiApi, MistralAiChatOptions options) { this(mistralAiApi, options, null, RetryUtils.DEFAULT_RETRY_TEMPLATE); } - public MistralAiModelCall(MistralAiApi mistralAiApi, MistralAiChatOptions options, + public MistralAiModelCaller(MistralAiApi mistralAiApi, MistralAiChatOptions options, FunctionCallbackContext functionCallbackContext, RetryTemplate retryTemplate) { super(functionCallbackContext); Assert.notNull(mistralAiApi, "MistralAiApi must not be null"); diff --git a/models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiChatCompletionRequestTest.java b/models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiChatCompletionRequestTest.java index dcb23bf5b..6726afb4a 100644 --- a/models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiChatCompletionRequestTest.java +++ b/models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiChatCompletionRequestTest.java @@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat; @EnabledIfEnvironmentVariable(named = "MISTRAL_AI_API_KEY", matches = ".+") public class MistralAiChatCompletionRequestTest { - MistralAiModelCall chatClient = new MistralAiModelCall(new MistralAiApi("test")); + MistralAiModelCaller chatClient = new MistralAiModelCaller(new MistralAiApi("test")); @Test void chatCompletionDefaultRequestTest() { diff --git a/models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiModelCallIT.java b/models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiModelCallerIT.java similarity index 98% rename from models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiModelCallIT.java rename to models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiModelCallerIT.java index 6918ad211..5c902e71d 100644 --- a/models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiModelCallIT.java +++ b/models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiModelCallerIT.java @@ -27,7 +27,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import reactor.core.publisher.Flux; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.Generation; import org.springframework.ai.chat.StreamingChatClient; @@ -56,12 +56,12 @@ import static org.assertj.core.api.Assertions.assertThat; */ @SpringBootTest(classes = MistralAiTestConfiguration.class) @EnabledIfEnvironmentVariable(named = "MISTRAL_AI_API_KEY", matches = ".+") -class MistralAiModelCallIT { +class MistralAiModelCallerIT { - private static final Logger logger = LoggerFactory.getLogger(MistralAiModelCallIT.class); + private static final Logger logger = LoggerFactory.getLogger(MistralAiModelCallerIT.class); @Autowired - protected ModelCall modelCall; + protected ChatCaller modelCall; @Autowired protected StreamingChatClient streamingChatClient; diff --git a/models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiRetryTests.java b/models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiRetryTests.java index bf5338fa2..9679ac909 100644 --- a/models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiRetryTests.java +++ b/models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiRetryTests.java @@ -82,7 +82,7 @@ public class MistralAiRetryTests { private @Mock MistralAiApi mistralAiApi; - private MistralAiModelCall chatClient; + private MistralAiModelCaller chatClient; private MistralAiEmbeddingClient embeddingClient; @@ -92,7 +92,7 @@ public class MistralAiRetryTests { retryListener = new TestRetryListener(); retryTemplate.registerListener(retryListener); - chatClient = new MistralAiModelCall(mistralAiApi, + chatClient = new MistralAiModelCaller(mistralAiApi, MistralAiChatOptions.builder() .withTemperature(0.7f) .withTopP(1f) diff --git a/models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiTestConfiguration.java b/models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiTestConfiguration.java index 0f1da4cc2..d667b1fab 100644 --- a/models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiTestConfiguration.java +++ b/models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiTestConfiguration.java @@ -41,8 +41,8 @@ public class MistralAiTestConfiguration { } @Bean - public MistralAiModelCall mistralAiChatClient(MistralAiApi mistralAiApi) { - return new MistralAiModelCall(mistralAiApi, + public MistralAiModelCaller mistralAiChatClient(MistralAiApi mistralAiApi) { + return new MistralAiModelCaller(mistralAiApi, MistralAiChatOptions.builder().withModel(MistralAiApi.ChatModel.MIXTRAL.getValue()).build()); } diff --git a/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/OllamaModelCall.java b/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/OllamaModelCaller.java similarity index 93% rename from models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/OllamaModelCall.java rename to models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/OllamaModelCaller.java index 68af0f7a6..133ba8151 100644 --- a/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/OllamaModelCall.java +++ b/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/OllamaModelCaller.java @@ -18,7 +18,7 @@ package org.springframework.ai.ollama; import java.util.Base64; import java.util.List; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.ollama.metadata.OllamaChatResponseMetadata; import reactor.core.publisher.Flux; @@ -39,7 +39,7 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; /** - * {@link ModelCall} implementation for {@literal Ollama}. + * {@link ChatCaller} implementation for {@literal Ollama}. * * Ollama allows developers to run large language models and generate embeddings locally. * It supports open-source models available on [Ollama AI @@ -52,7 +52,7 @@ import org.springframework.util.StringUtils; * @author Christian Tzolov * @since 0.8.0 */ -public class OllamaModelCall implements ModelCall, StreamingChatClient { +public class OllamaModelCaller implements ChatCaller, StreamingChatClient { /** * Low-level Ollama API library. @@ -64,11 +64,11 @@ public class OllamaModelCall implements ModelCall, StreamingChatClient { */ private OllamaOptions defaultOptions; - public OllamaModelCall(OllamaApi chatApi) { + public OllamaModelCaller(OllamaApi chatApi) { this(chatApi, OllamaOptions.create().withModel(OllamaOptions.DEFAULT_MODEL)); } - public OllamaModelCall(OllamaApi chatApi, OllamaOptions defaultOptions) { + public OllamaModelCaller(OllamaApi chatApi, OllamaOptions defaultOptions) { Assert.notNull(chatApi, "OllamaApi must not be null"); Assert.notNull(defaultOptions, "DefaultOptions must not be null"); this.chatApi = chatApi; @@ -79,7 +79,7 @@ public class OllamaModelCall implements ModelCall, StreamingChatClient { * @deprecated Use {@link OllamaOptions#setModel} instead. */ @Deprecated - public OllamaModelCall withModel(String model) { + public OllamaModelCaller withModel(String model) { this.defaultOptions.setModel(model); return this; } @@ -88,7 +88,7 @@ public class OllamaModelCall implements ModelCall, StreamingChatClient { * @deprecated Use {@link OllamaOptions} constructor instead. */ @Deprecated - public OllamaModelCall withDefaultOptions(OllamaOptions options) { + public OllamaModelCaller withDefaultOptions(OllamaOptions options) { this.defaultOptions = options; return this; } diff --git a/models/spring-ai-ollama/src/test/java/org/springframework/ai/ollama/OllamaChatRequestTests.java b/models/spring-ai-ollama/src/test/java/org/springframework/ai/ollama/OllamaChatRequestTests.java index 31ee6f9b2..7c525bc77 100644 --- a/models/spring-ai-ollama/src/test/java/org/springframework/ai/ollama/OllamaChatRequestTests.java +++ b/models/spring-ai-ollama/src/test/java/org/springframework/ai/ollama/OllamaChatRequestTests.java @@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat; */ public class OllamaChatRequestTests { - OllamaModelCall client = new OllamaModelCall(new OllamaApi(), + OllamaModelCaller client = new OllamaModelCaller(new OllamaApi(), new OllamaOptions().withModel("MODEL_NAME").withTopK(99).withTemperature(66.6f).withNumGPU(1)); @Test @@ -105,7 +105,7 @@ public class OllamaChatRequestTests { @Test public void createRequestWithDefaultOptionsModelOverride() { - OllamaModelCall client2 = new OllamaModelCall(new OllamaApi(), + OllamaModelCaller client2 = new OllamaModelCaller(new OllamaApi(), new OllamaOptions().withModel("DEFAULT_OPTIONS_MODEL")); var request = client2.ollamaChatRequest(new Prompt("Test message content"), true); diff --git a/models/spring-ai-ollama/src/test/java/org/springframework/ai/ollama/OllamaModelCallIT.java b/models/spring-ai-ollama/src/test/java/org/springframework/ai/ollama/OllamaModelCallerIT.java similarity index 96% rename from models/spring-ai-ollama/src/test/java/org/springframework/ai/ollama/OllamaModelCallIT.java rename to models/spring-ai-ollama/src/test/java/org/springframework/ai/ollama/OllamaModelCallerIT.java index c7bc4702e..2b4967557 100644 --- a/models/spring-ai-ollama/src/test/java/org/springframework/ai/ollama/OllamaModelCallIT.java +++ b/models/spring-ai-ollama/src/test/java/org/springframework/ai/ollama/OllamaModelCallerIT.java @@ -56,11 +56,11 @@ import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest @Testcontainers @Disabled("For manual smoke testing only.") -class OllamaModelCallIT { +class OllamaModelCallerIT { private static String MODEL = "mistral"; - private static final Log logger = LogFactory.getLog(OllamaModelCallIT.class); + private static final Log logger = LogFactory.getLog(OllamaModelCallerIT.class); @Container static OllamaContainer ollamaContainer = new OllamaContainer("ollama/ollama:0.1.32"); @@ -77,7 +77,7 @@ class OllamaModelCallIT { } @Autowired - private OllamaModelCall client; + private OllamaModelCaller client; @Test void roleTest() { @@ -219,8 +219,8 @@ class OllamaModelCallIT { } @Bean - public OllamaModelCall ollamaChat(OllamaApi ollamaApi) { - return new OllamaModelCall(ollamaApi, OllamaOptions.create().withModel(MODEL).withTemperature(0.9f)); + public OllamaModelCaller ollamaChat(OllamaApi ollamaApi) { + return new OllamaModelCaller(ollamaApi, OllamaOptions.create().withModel(MODEL).withTemperature(0.9f)); } } diff --git a/models/spring-ai-ollama/src/test/java/org/springframework/ai/ollama/OllamaModelCallMultimodalIT.java b/models/spring-ai-ollama/src/test/java/org/springframework/ai/ollama/OllamaModelCallerMultimodalIT.java similarity index 92% rename from models/spring-ai-ollama/src/test/java/org/springframework/ai/ollama/OllamaModelCallMultimodalIT.java rename to models/spring-ai-ollama/src/test/java/org/springframework/ai/ollama/OllamaModelCallerMultimodalIT.java index 7ba575eae..effc56f45 100644 --- a/models/spring-ai-ollama/src/test/java/org/springframework/ai/ollama/OllamaModelCallMultimodalIT.java +++ b/models/spring-ai-ollama/src/test/java/org/springframework/ai/ollama/OllamaModelCallerMultimodalIT.java @@ -44,11 +44,11 @@ import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest @Testcontainers @Disabled("For manual smoke testing only.") -class OllamaModelCallMultimodalIT { +class OllamaModelCallerMultimodalIT { private static String MODEL = "llava"; - private static final Log logger = LogFactory.getLog(OllamaModelCallIT.class); + private static final Log logger = LogFactory.getLog(OllamaModelCallerIT.class); @Container static OllamaContainer ollamaContainer = new OllamaContainer("ollama/ollama:0.1.32"); @@ -65,7 +65,7 @@ class OllamaModelCallMultimodalIT { } @Autowired - private OllamaModelCall client; + private OllamaModelCaller client; @Test void multiModalityTest() throws IOException { @@ -90,8 +90,8 @@ class OllamaModelCallMultimodalIT { } @Bean - public OllamaModelCall ollamaChat(OllamaApi ollamaApi) { - return new OllamaModelCall(ollamaApi, OllamaOptions.create().withModel(MODEL).withTemperature(0.9f)); + public OllamaModelCaller ollamaChat(OllamaApi ollamaApi) { + return new OllamaModelCaller(ollamaApi, OllamaOptions.create().withModel(MODEL).withTemperature(0.9f)); } } diff --git a/models/spring-ai-openai/src/main/java/org/springframework/ai/openai/OpenAiModelCall.java b/models/spring-ai-openai/src/main/java/org/springframework/ai/openai/OpenAiModelCaller.java similarity index 96% rename from models/spring-ai-openai/src/main/java/org/springframework/ai/openai/OpenAiModelCall.java rename to models/spring-ai-openai/src/main/java/org/springframework/ai/openai/OpenAiModelCaller.java index d290b2c8a..057d9a359 100644 --- a/models/spring-ai-openai/src/main/java/org/springframework/ai/openai/OpenAiModelCall.java +++ b/models/spring-ai-openai/src/main/java/org/springframework/ai/openai/OpenAiModelCaller.java @@ -17,7 +17,7 @@ package org.springframework.ai.openai; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.Generation; import org.springframework.ai.chat.StreamingChatClient; @@ -58,7 +58,7 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; /** - * {@link ModelCall} and {@link StreamingChatClient} implementation for {@literal OpenAI} + * {@link ChatCaller} and {@link StreamingChatClient} implementation for {@literal OpenAI} * backed by {@link OpenAiApi}. * * @author Mark Pollack @@ -68,15 +68,15 @@ import java.util.concurrent.ConcurrentHashMap; * @author Josh Long * @author Jemin Huh * @author Grogdunn - * @see ModelCall + * @see ChatCaller * @see StreamingChatClient * @see OpenAiApi */ -public class OpenAiModelCall extends +public class OpenAiModelCaller extends AbstractFunctionCallSupport> - implements ModelCall, StreamingChatClient { + implements ChatCaller, StreamingChatClient { - private static final Logger logger = LoggerFactory.getLogger(OpenAiModelCall.class); + private static final Logger logger = LoggerFactory.getLogger(OpenAiModelCaller.class); /** * The default options used for the chat completion requests. @@ -99,7 +99,7 @@ public class OpenAiModelCall extends * Chat API. * @throws IllegalArgumentException if openAiApi is null */ - public OpenAiModelCall(OpenAiApi openAiApi) { + public OpenAiModelCaller(OpenAiApi openAiApi) { this(openAiApi, OpenAiChatOptions.builder().withModel(OpenAiApi.DEFAULT_CHAT_MODEL).withTemperature(0.7f).build()); } @@ -110,7 +110,7 @@ public class OpenAiModelCall extends * Chat API. * @param options The OpenAiChatOptions to configure the chat client. */ - public OpenAiModelCall(OpenAiApi openAiApi, OpenAiChatOptions options) { + public OpenAiModelCaller(OpenAiApi openAiApi, OpenAiChatOptions options) { this(openAiApi, options, null, RetryUtils.DEFAULT_RETRY_TEMPLATE); } @@ -122,7 +122,7 @@ public class OpenAiModelCall extends * @param functionCallbackContext The function callback context. * @param retryTemplate The retry template. */ - public OpenAiModelCall(OpenAiApi openAiApi, OpenAiChatOptions options, + public OpenAiModelCaller(OpenAiApi openAiApi, OpenAiChatOptions options, FunctionCallbackContext functionCallbackContext, RetryTemplate retryTemplate) { super(functionCallbackContext); Assert.notNull(openAiApi, "OpenAiApi must not be null"); diff --git a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/ChatCompletionRequestTests.java b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/ChatCompletionRequestTests.java index 9ec6ed08f..da3f22b2d 100644 --- a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/ChatCompletionRequestTests.java +++ b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/ChatCompletionRequestTests.java @@ -34,7 +34,7 @@ public class ChatCompletionRequestTests { @Test public void createRequestWithChatOptions() { - var client = new OpenAiModelCall(new OpenAiApi("TEST"), + var client = new OpenAiModelCaller(new OpenAiApi("TEST"), OpenAiChatOptions.builder().withModel("DEFAULT_MODEL").withTemperature(66.6f).build()); var request = client.createRequest(new Prompt("Test message content"), false); @@ -60,7 +60,7 @@ public class ChatCompletionRequestTests { final String TOOL_FUNCTION_NAME = "CurrentWeather"; - var client = new OpenAiModelCall(new OpenAiApi("TEST"), + var client = new OpenAiModelCaller(new OpenAiApi("TEST"), OpenAiChatOptions.builder().withModel("DEFAULT_MODEL").build()); var request = client.createRequest(new Prompt("Test message content", @@ -90,7 +90,7 @@ public class ChatCompletionRequestTests { final String TOOL_FUNCTION_NAME = "CurrentWeather"; - var client = new OpenAiModelCall(new OpenAiApi("TEST"), + var client = new OpenAiModelCaller(new OpenAiApi("TEST"), OpenAiChatOptions.builder() .withModel("DEFAULT_MODEL") .withFunctionCallbacks(List.of(FunctionCallbackWrapper.builder(new MockWeatherService()) diff --git a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/OpenAiTestConfiguration.java b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/OpenAiTestConfiguration.java index a5df19a45..e9c2fbf67 100644 --- a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/OpenAiTestConfiguration.java +++ b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/OpenAiTestConfiguration.java @@ -51,8 +51,8 @@ public class OpenAiTestConfiguration { } @Bean - public OpenAiModelCall openAiChatClient(OpenAiApi api) { - OpenAiModelCall openAiChatClient = new OpenAiModelCall(api); + public OpenAiModelCaller openAiChatClient(OpenAiApi api) { + OpenAiModelCaller openAiChatClient = new OpenAiModelCaller(api); return openAiChatClient; } diff --git a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/acme/AcmeIT.java b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/acme/AcmeIT.java index 51bdbf08f..544649f11 100644 --- a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/acme/AcmeIT.java +++ b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/acme/AcmeIT.java @@ -26,7 +26,7 @@ import org.slf4j.LoggerFactory; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.document.Document; -import org.springframework.ai.openai.OpenAiModelCall; +import org.springframework.ai.openai.OpenAiModelCaller; import org.springframework.ai.openai.OpenAiTestConfiguration; import org.springframework.ai.openai.OpenAiEmbeddingClient; import org.springframework.ai.openai.testutils.AbstractIT; @@ -61,7 +61,7 @@ public class AcmeIT extends AbstractIT { private OpenAiEmbeddingClient embeddingClient; @Autowired - private OpenAiModelCall chatClient; + private OpenAiModelCaller chatClient; @Test void beanTest() { diff --git a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiChatClientIT.java b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiChatClientIT.java new file mode 100644 index 000000000..247b8994e --- /dev/null +++ b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiChatClientIT.java @@ -0,0 +1,388 @@ +/* + * 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. + */ +package org.springframework.ai.openai.chat; + +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +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.ChatClient; +import org.springframework.ai.chat.ChatResponse; +import org.springframework.ai.chat.Generation; +import org.springframework.ai.chat.messages.AssistantMessage; +import org.springframework.ai.chat.messages.Media; +import org.springframework.ai.chat.messages.Message; +import org.springframework.ai.chat.messages.UserMessage; +import org.springframework.ai.chat.prompt.Prompt; +import org.springframework.ai.chat.prompt.PromptTemplate; +import org.springframework.ai.converter.BeanOutputConverter; +import org.springframework.ai.model.function.FunctionCallbackWrapper; +import org.springframework.ai.openai.OpenAiChatOptions; +import org.springframework.ai.openai.OpenAiTestConfiguration; +import org.springframework.ai.openai.api.OpenAiApi; +import org.springframework.ai.openai.api.tool.MockWeatherService; +import org.springframework.ai.openai.testutils.AbstractIT; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; +import org.springframework.util.MimeTypeUtils; + +import static org.assertj.core.api.Assertions.assertThat; + +@SpringBootTest(classes = OpenAiTestConfiguration.class) +@EnabledIfEnvironmentVariable(named = "OPENAI_API_KEY", matches = ".+") +class OpenAiChatClientIT extends AbstractIT { + + private static final Logger logger = LoggerFactory.getLogger(OpenAiModelCallerIT.class); + + @Value("classpath:/prompts/system-message.st") + private Resource systemTextResource; + + @Test + void roleTest() { + + ChatResponse response = ChatClient.builder(modelCaller).build().call() + .system(s -> s.text(systemTextResource).param("name", "Bob").param("voice", "pirate")) + .user(u -> u.text("Tell me about 3 famous pirates from the Golden Age of Piracy and what they did")) + .chat().chatResponse(); + + System.out.println(response); + // UserMessage userMessage = new UserMessage( + // "Tell me about 3 famous pirates from the Golden Age of Piracy and what they + // did."); + // SystemPromptTemplate systemPromptTemplate = new + // SystemPromptTemplate(systemResource); + // Message systemMessage = systemPromptTemplate.createMessage(Map.of("name", + // "Bob", "voice", "pirate")); + // Prompt prompt = new Prompt(List.of(userMessage, systemMessage)); + // ChatResponse response = modelCaller.call(prompt); + assertThat(response.getResults()).hasSize(1); + assertThat(response.getResults().get(0).getOutput().getContent()).contains("Blackbeard"); + // needs fine tuning... evaluateQuestionAndAnswer(request, response, false); + } + + @Test + void listOutputConverter() { + + // TODO: there is a problem here. + Collection list = ChatClient.builder(modelCaller).build().call() + .user(u -> u.text("List five {subject}").param("subject", "ice cream flavors")) + .chat().list(String.class); + + // DefaultConversionService conversionService = new DefaultConversionService(); + // ListOutputConverter outputConverter = new + // ListOutputConverter(conversionService); + + // String format = outputConverter.getFormat(); + // String template = """ + // List five {subject} + // {format} + // """; + // PromptTemplate promptTemplate = new PromptTemplate(template, + // Map.of("subject", "ice cream flavors", "format", format)); + // Prompt prompt = new Prompt(promptTemplate.createMessage()); + // Generation generation = this.modelCaller.call(prompt).getResult(); + + // List list = + // outputConverter.convert(generation.getOutput().getContent()); + assertThat(list).hasSize(5); + + } + + @Test + void mapOutputConverter() { + + Map result = ChatClient.builder(modelCaller).build().call() + .user(u -> u.text("Provide me a List of {subject}") + .param("subject", "an array of numbers from 1 to 9 under they key name 'numbers'")) + .chat().single(new ParameterizedTypeReference>() { + }); + + // MapOutputConverter outputConverter = new MapOutputConverter(); + + // String format = outputConverter.getFormat(); + // String template = """ + // Provide me a List of {subject} + // {format} + // """; + // PromptTemplate promptTemplate = new PromptTemplate(template, + // Map.of("subject", "an array of numbers from 1 to 9 under they key name + // 'numbers'", "format", format)); + // Prompt prompt = new Prompt(promptTemplate.createMessage()); + // Generation generation = modelCaller.call(prompt).getResult(); + + // Map result = + // outputConverter.convert(generation.getOutput().getContent()); + assertThat(result.get("numbers")).isEqualTo(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9)); + } + + @Test + void beanOutputConverter() { + + ActorsFilms actorsFilms = ChatClient.builder(modelCaller).build().call() + .user(u -> u.text("Generate the filmography for a random actor.")) + .chat().single(ActorsFilms.class); + + // BeanOutputConverter outputConverter = new + // BeanOutputConverter<>(ActorsFilms.class); + + // String format = outputConverter.getFormat(); + // String template = """ + // Generate the filmography for a random actor. + // {format} + // """; + // PromptTemplate promptTemplate = new PromptTemplate(template, Map.of("format", + // format)); + // Prompt prompt = new Prompt(promptTemplate.createMessage()); + // Generation generation = modelCaller.call(prompt).getResult(); + + // ActorsFilms actorsFilms = + // outputConverter.convert(generation.getOutput().getContent()); + logger.info("" + actorsFilms); + assertThat(actorsFilms.getActor()).isNotBlank(); + } + + record ActorsFilmsRecord(String actor, List movies) { + } + + @Test + void beanOutputConverterRecords() { + + ActorsFilmsRecord actorsFilms = ChatClient.builder(modelCaller) + .build().call() + .user(u -> u.text("Generate the filmography of 5 movies for Tom Hanks.")) + .chat().single(ActorsFilmsRecord.class); + + // BeanOutputConverter outputConverter = new + // BeanOutputConverter<>(ActorsFilmsRecord.class); + + // String format = outputConverter.getFormat(); + // String template = """ + // Generate the filmography of 5 movies for Tom Hanks. + // {format} + // """; + // PromptTemplate promptTemplate = new PromptTemplate(template, Map.of("format", + // format)); + // Prompt prompt = new Prompt(promptTemplate.createMessage()); + // Generation generation = modelCaller.call(prompt).getResult(); + + // ActorsFilmsRecord actorsFilms = + // outputConverter.convert(generation.getOutput().getContent()); + logger.info("" + actorsFilms); + assertThat(actorsFilms.actor()).isEqualTo("Tom Hanks"); + assertThat(actorsFilms.movies()).hasSize(5); + } + + @Test + void beanStreamOutputConverterRecords() { + + BeanOutputConverter outputConverter = new BeanOutputConverter<>(ActorsFilmsRecord.class); + + String format = outputConverter.getFormat(); + String template = """ + Generate the filmography of 5 movies for Tom Hanks. + {format} + """; + PromptTemplate promptTemplate = new PromptTemplate(template, Map.of("format", format)); + Prompt prompt = new Prompt(promptTemplate.createMessage()); + + String generationTextFromStream = streamingChatClient.stream(prompt) + .collectList() + .block() + .stream() + .map(ChatResponse::getResults) + .flatMap(List::stream) + .map(Generation::getOutput) + .map(AssistantMessage::getContent) + .collect(Collectors.joining()); + + ActorsFilmsRecord actorsFilms = outputConverter.convert(generationTextFromStream); + logger.info("" + actorsFilms); + assertThat(actorsFilms.actor()).isEqualTo("Tom Hanks"); + assertThat(actorsFilms.movies()).hasSize(5); + } + + @Test + void functionCallTest() { + + ChatResponse response = ChatClient.builder(modelCaller) + .build() + .call() + .user(u -> u.text("What's the weather like in San Francisco, Tokyo, and Paris?")) + // TODO how to use the protable function calling options internally. + // Perhaps the ModelCaller a emptyOptions() method needs to be provided. + .options(OpenAiChatOptions.builder().build()) + .function("getCurrentWeather", "Get the weather in location", new MockWeatherService()) + .chat() + .chatResponse(); + + // UserMessage userMessage = new UserMessage("What's the weather like in San + // Francisco, Tokyo, and Paris?"); + + // List messages = new ArrayList<>(List.of(userMessage)); + + // var promptOptions = OpenAiChatOptions.builder() + // .withModel(OpenAiApi.ChatModel.GPT_4_TURBO_PREVIEW.getValue()) + // .withFunctionCallbacks(List.of(FunctionCallbackWrapper.builder(new + // MockWeatherService()) + // .withName("getCurrentWeather") + // .withDescription("Get the weather in location") + // .withResponseConverter((response) -> "" + response.temp() + response.unit()) + // .build())) + // .build(); + + // ChatResponse response = modelCaller.call(new Prompt(messages, promptOptions)); + + logger.info("Response: {}", response); + + assertThat(response.getResult().getOutput().getContent()).containsAnyOf("30.0", "30"); + assertThat(response.getResult().getOutput().getContent()).containsAnyOf("10.0", "10"); + assertThat(response.getResult().getOutput().getContent()).containsAnyOf("15.0", "15"); + } + + @Test + void streamFunctionCallTest() { + + UserMessage userMessage = new UserMessage("What's the weather like in San Francisco, Tokyo, and Paris?"); + + List messages = new ArrayList<>(List.of(userMessage)); + + var promptOptions = OpenAiChatOptions.builder() + // .withModel(OpenAiApi.ChatModel.GPT_4_TURBO_PREVIEW.getValue()) + .withFunctionCallbacks(List.of(FunctionCallbackWrapper.builder(new MockWeatherService()) + .withName("getCurrentWeather") + .withDescription("Get the weather in location") + .withResponseConverter((response) -> "" + response.temp() + response.unit()) + .build())) + .build(); + + Flux response = streamingChatClient.stream(new Prompt(messages, promptOptions)); + + String content = response.collectList() + .block() + .stream() + .map(ChatResponse::getResults) + .flatMap(List::stream) + .map(Generation::getOutput) + .map(AssistantMessage::getContent) + .collect(Collectors.joining()); + logger.info("Response: {}", content); + + assertThat(content).containsAnyOf("30.0", "30"); + assertThat(content).containsAnyOf("10.0", "10"); + assertThat(content).containsAnyOf("15.0", "15"); + } + + @ParameterizedTest(name = "{0} : {displayName} ") + @ValueSource(strings = { "gpt-4-vision-preview", "gpt-4o" }) + void multiModalityEmbeddedImage(String modelName) throws IOException { + + ChatResponse response = ChatClient.builder(modelCaller) + .build() + .call() + // TODO consider adding model(...) method to ChatClient as a shortcut to + // OpenAiChatOptions.builder().withModel(modelName).build() + .options(OpenAiChatOptions.builder().withModel(modelName).build()) + .user(u -> u.text("Explain what do you see on this picture?") + .media(MimeTypeUtils.IMAGE_PNG, new ClassPathResource("/test.png"))) + .chat() + .chatResponse(); + + // var imageData = new ClassPathResource("/test.png"); + + // var userMessage = new UserMessage("Explain what do you see on this picture?", + // List.of(new Media(MimeTypeUtils.IMAGE_PNG, imageData))); + + // var response = modelCaller + // .call(new Prompt(List.of(userMessage), + // OpenAiChatOptions.builder().withModel(modelName).build())); + + logger.info(response.getResult().getOutput().getContent()); + assertThat(response.getResult().getOutput().getContent()).contains("bananas", "apple"); + assertThat(response.getResult().getOutput().getContent()).containsAnyOf("bowl", "basket"); + } + + @ParameterizedTest(name = "{0} : {displayName} ") + @ValueSource(strings = { "gpt-4-vision-preview", "gpt-4o" }) + void multiModalityImageUrl(String modelName) throws IOException { + + // TODO: add url method that wrapps the checked exception. + URL url = new URL("https://docs.spring.io/spring-ai/reference/1.0-SNAPSHOT/_images/multimodal.test.png"); + + ChatResponse response = ChatClient.builder(modelCaller) + .build() + .call() + // TODO consider adding model(...) method to ChatClient as a shortcut to + // OpenAiChatOptions.builder().withModel(modelName).build() + .options(OpenAiChatOptions.builder().withModel(modelName).build()) + .user(u -> u.text("Explain what do you see on this picture?").media(MimeTypeUtils.IMAGE_PNG, url)) + .chat() + .chatResponse(); + + // var userMessage = new UserMessage("Explain what do you see on this picture?", + // List + // .of(new Media(MimeTypeUtils.IMAGE_PNG, + // new + // URL("https://docs.spring.io/spring-ai/reference/1.0-SNAPSHOT/_images/multimodal.test.png")))); + + // ChatResponse response = modelCaller + // .call(new Prompt(List.of(userMessage), + // OpenAiChatOptions.builder().withModel(modelName).build())); + + logger.info(response.getResult().getOutput().getContent()); + assertThat(response.getResult().getOutput().getContent()).contains("bananas", "apple"); + assertThat(response.getResult().getOutput().getContent()).containsAnyOf("bowl", "basket"); + } + + @Test + void streamingMultiModalityImageUrl() throws IOException { + + var userMessage = new UserMessage("Explain what do you see on this picture?", List + .of(new Media(MimeTypeUtils.IMAGE_PNG, + new URL("https://docs.spring.io/spring-ai/reference/1.0-SNAPSHOT/_images/multimodal.test.png")))); + + Flux response = streamingChatClient.stream(new Prompt(List.of(userMessage), + OpenAiChatOptions.builder().withModel(OpenAiApi.ChatModel.GPT_4_VISION_PREVIEW.getValue()).build())); + + String content = response.collectList() + .block() + .stream() + .map(ChatResponse::getResults) + .flatMap(List::stream) + .map(Generation::getOutput) + .map(AssistantMessage::getContent) + .collect(Collectors.joining()); + logger.info("Response: {}", content); + assertThat(content).contains("bananas", "apple"); + assertThat(content).containsAnyOf("bowl", "basket"); + } + +} \ No newline at end of file diff --git a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiChatClientWithChatResponseMetadataTests.java b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiChatClientWithChatResponseMetadataTests.java index fb410fdb0..6dc8b1483 100644 --- a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiChatClientWithChatResponseMetadataTests.java +++ b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiChatClientWithChatResponseMetadataTests.java @@ -27,7 +27,7 @@ import org.springframework.ai.chat.metadata.PromptMetadata; import org.springframework.ai.chat.metadata.RateLimit; import org.springframework.ai.chat.metadata.Usage; import org.springframework.ai.openai.api.OpenAiApi; -import org.springframework.ai.openai.OpenAiModelCall; +import org.springframework.ai.openai.OpenAiModelCaller; import org.springframework.ai.openai.metadata.support.OpenAiApiResponseHeaders; import org.springframework.ai.chat.prompt.Prompt; import org.springframework.beans.factory.annotation.Autowired; @@ -57,7 +57,7 @@ public class OpenAiChatClientWithChatResponseMetadataTests { private static String TEST_API_KEY = "sk-1234567890"; @Autowired - private OpenAiModelCall openAiChatClient; + private OpenAiModelCaller openAiChatClient; @Autowired private MockRestServiceServer server; @@ -171,8 +171,8 @@ public class OpenAiChatClientWithChatResponseMetadataTests { } @Bean - public OpenAiModelCall openAiClient(OpenAiApi openAiApi) { - return new OpenAiModelCall(openAiApi); + public OpenAiModelCaller openAiClient(OpenAiApi openAiApi) { + return new OpenAiModelCaller(openAiApi); } } diff --git a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiModelCall2IT.java b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiModelCaller2IT.java similarity index 91% rename from models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiModelCall2IT.java rename to models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiModelCaller2IT.java index bce2b2a89..ae1843507 100644 --- a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiModelCall2IT.java +++ b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiModelCaller2IT.java @@ -27,7 +27,7 @@ import org.slf4j.LoggerFactory; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.prompt.Prompt; -import org.springframework.ai.openai.OpenAiModelCall; +import org.springframework.ai.openai.OpenAiModelCaller; import org.springframework.ai.openai.OpenAiChatOptions; import org.springframework.ai.openai.api.OpenAiApi; import org.springframework.ai.openai.api.OpenAiApi.ChatCompletionRequest; @@ -41,14 +41,14 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Christian Tzolov */ -@SpringBootTest(classes = OpenAiModelCall2IT.Config.class) +@SpringBootTest(classes = OpenAiModelCaller2IT.Config.class) @EnabledIfEnvironmentVariable(named = "OPENAI_API_KEY", matches = ".+") -public class OpenAiModelCall2IT { +public class OpenAiModelCaller2IT { private final Logger logger = LoggerFactory.getLogger(getClass()); @Autowired - private OpenAiModelCall openAiChatClient; + private OpenAiModelCaller openAiChatClient; @Test void responseFormatTest() throws JsonMappingException, JsonProcessingException { @@ -99,8 +99,8 @@ public class OpenAiModelCall2IT { } @Bean - public OpenAiModelCall openAiClient(OpenAiApi openAiApi) { - return new OpenAiModelCall(openAiApi); + public OpenAiModelCaller openAiClient(OpenAiApi openAiApi) { + return new OpenAiModelCaller(openAiApi); } } diff --git a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiModelCallIT.java b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiModelCallerIT.java similarity index 95% rename from models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiModelCallIT.java rename to models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiModelCallerIT.java index 5a89b378d..f7ac38851 100644 --- a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiModelCallIT.java +++ b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiModelCallerIT.java @@ -31,6 +31,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import reactor.core.publisher.Flux; +import org.springframework.ai.chat.ChatClient; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.Generation; import org.springframework.ai.chat.messages.AssistantMessage; @@ -60,9 +61,9 @@ import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest(classes = OpenAiTestConfiguration.class) @EnabledIfEnvironmentVariable(named = "OPENAI_API_KEY", matches = ".+") -class OpenAiModelCallIT extends AbstractIT { +class OpenAiModelCallerIT extends AbstractIT { - private static final Logger logger = LoggerFactory.getLogger(OpenAiModelCallIT.class); + private static final Logger logger = LoggerFactory.getLogger(OpenAiModelCallerIT.class); @Value("classpath:/prompts/system-message.st") private Resource systemResource; @@ -74,7 +75,7 @@ class OpenAiModelCallIT extends AbstractIT { SystemPromptTemplate systemPromptTemplate = new SystemPromptTemplate(systemResource); Message systemMessage = systemPromptTemplate.createMessage(Map.of("name", "Bob", "voice", "pirate")); Prompt prompt = new Prompt(List.of(userMessage, systemMessage)); - ChatResponse response = modelCall.call(prompt); + ChatResponse response = modelCaller.call(prompt); assertThat(response.getResults()).hasSize(1); assertThat(response.getResults().get(0).getOutput().getContent()).contains("Blackbeard"); // needs fine tuning... evaluateQuestionAndAnswer(request, response, false); @@ -93,7 +94,7 @@ class OpenAiModelCallIT extends AbstractIT { PromptTemplate promptTemplate = new PromptTemplate(template, Map.of("subject", "ice cream flavors", "format", format)); Prompt prompt = new Prompt(promptTemplate.createMessage()); - Generation generation = this.modelCall.call(prompt).getResult(); + Generation generation = this.modelCaller.call(prompt).getResult(); List list = outputConverter.convert(generation.getOutput().getContent()); assertThat(list).hasSize(5); @@ -112,7 +113,7 @@ class OpenAiModelCallIT extends AbstractIT { PromptTemplate promptTemplate = new PromptTemplate(template, Map.of("subject", "an array of numbers from 1 to 9 under they key name 'numbers'", "format", format)); Prompt prompt = new Prompt(promptTemplate.createMessage()); - Generation generation = modelCall.call(prompt).getResult(); + Generation generation = modelCaller.call(prompt).getResult(); Map result = outputConverter.convert(generation.getOutput().getContent()); assertThat(result.get("numbers")).isEqualTo(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9)); @@ -131,7 +132,7 @@ class OpenAiModelCallIT extends AbstractIT { """; PromptTemplate promptTemplate = new PromptTemplate(template, Map.of("format", format)); Prompt prompt = new Prompt(promptTemplate.createMessage()); - Generation generation = modelCall.call(prompt).getResult(); + Generation generation = modelCaller.call(prompt).getResult(); ActorsFilms actorsFilms = outputConverter.convert(generation.getOutput().getContent()); } @@ -151,7 +152,7 @@ class OpenAiModelCallIT extends AbstractIT { """; PromptTemplate promptTemplate = new PromptTemplate(template, Map.of("format", format)); Prompt prompt = new Prompt(promptTemplate.createMessage()); - Generation generation = modelCall.call(prompt).getResult(); + Generation generation = modelCaller.call(prompt).getResult(); ActorsFilmsRecord actorsFilms = outputConverter.convert(generation.getOutput().getContent()); logger.info("" + actorsFilms); @@ -204,7 +205,7 @@ class OpenAiModelCallIT extends AbstractIT { .build())) .build(); - ChatResponse response = modelCall.call(new Prompt(messages, promptOptions)); + ChatResponse response = modelCaller.call(new Prompt(messages, promptOptions)); logger.info("Response: {}", response); @@ -255,7 +256,7 @@ class OpenAiModelCallIT extends AbstractIT { var userMessage = new UserMessage("Explain what do you see on this picture?", List.of(new Media(MimeTypeUtils.IMAGE_PNG, imageData))); - var response = modelCall + var response = modelCaller .call(new Prompt(List.of(userMessage), OpenAiChatOptions.builder().withModel(modelName).build())); logger.info(response.getResult().getOutput().getContent()); @@ -271,7 +272,7 @@ class OpenAiModelCallIT extends AbstractIT { .of(new Media(MimeTypeUtils.IMAGE_PNG, new URL("https://docs.spring.io/spring-ai/reference/1.0-SNAPSHOT/_images/multimodal.test.png")))); - ChatResponse response = modelCall + ChatResponse response = modelCaller .call(new Prompt(List.of(userMessage), OpenAiChatOptions.builder().withModel(modelName).build())); logger.info(response.getResult().getOutput().getContent()); diff --git a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiModelCallTypeReferenceBeanOutputConverterIT.java b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiModelCallerTypeReferenceBeanOutputConverterIT.java similarity index 94% rename from models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiModelCallTypeReferenceBeanOutputConverterIT.java rename to models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiModelCallerTypeReferenceBeanOutputConverterIT.java index c83ef6d58..82ec051ce 100644 --- a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiModelCallTypeReferenceBeanOutputConverterIT.java +++ b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiModelCallerTypeReferenceBeanOutputConverterIT.java @@ -39,10 +39,10 @@ import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest(classes = OpenAiTestConfiguration.class) @EnabledIfEnvironmentVariable(named = "OPENAI_API_KEY", matches = ".+") -class OpenAiModelCallTypeReferenceBeanOutputConverterIT extends AbstractIT { +class OpenAiModelCallerTypeReferenceBeanOutputConverterIT extends AbstractIT { private static final Logger logger = LoggerFactory - .getLogger(OpenAiModelCallTypeReferenceBeanOutputConverterIT.class); + .getLogger(OpenAiModelCallerTypeReferenceBeanOutputConverterIT.class); record ActorsFilmsRecord(String actor, List movies) { } @@ -61,7 +61,7 @@ class OpenAiModelCallTypeReferenceBeanOutputConverterIT extends AbstractIT { """; PromptTemplate promptTemplate = new PromptTemplate(template, Map.of("format", format)); Prompt prompt = new Prompt(promptTemplate.createMessage()); - Generation generation = modelCall.call(prompt).getResult(); + Generation generation = modelCaller.call(prompt).getResult(); List actorsFilms = outputConverter.convert(generation.getOutput().getContent()); logger.info("" + actorsFilms); diff --git a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiRetryTests.java b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiRetryTests.java index d83407762..fad0cad29 100644 --- a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiRetryTests.java +++ b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiRetryTests.java @@ -31,7 +31,7 @@ import org.springframework.ai.image.ImageMessage; import org.springframework.ai.image.ImagePrompt; import org.springframework.ai.openai.OpenAiAudioTranscriptionClient; import org.springframework.ai.openai.OpenAiAudioTranscriptionOptions; -import org.springframework.ai.openai.OpenAiModelCall; +import org.springframework.ai.openai.OpenAiModelCaller; import org.springframework.ai.openai.OpenAiChatOptions; import org.springframework.ai.openai.OpenAiEmbeddingClient; import org.springframework.ai.openai.OpenAiEmbeddingOptions; @@ -107,7 +107,7 @@ public class OpenAiRetryTests { private @Mock OpenAiImageApi openAiImageApi; - private OpenAiModelCall chatClient; + private OpenAiModelCaller chatClient; private OpenAiEmbeddingClient embeddingClient; @@ -121,7 +121,7 @@ public class OpenAiRetryTests { retryListener = new TestRetryListener(); retryTemplate.registerListener(retryListener); - chatClient = new OpenAiModelCall(openAiApi, OpenAiChatOptions.builder().build(), null, retryTemplate); + chatClient = new OpenAiModelCaller(openAiApi, OpenAiChatOptions.builder().build(), null, retryTemplate); embeddingClient = new OpenAiEmbeddingClient(openAiApi, MetadataMode.EMBED, OpenAiEmbeddingOptions.builder().build(), retryTemplate); audioTranscriptionClient = new OpenAiAudioTranscriptionClient(openAiAudioApi, diff --git a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/service/ChatMemoryLongTermSystemPromptIT.java b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/service/ChatMemoryLongTermSystemPromptIT.java index 03c6d9af2..d01a84086 100644 --- a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/service/ChatMemoryLongTermSystemPromptIT.java +++ b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/service/ChatMemoryLongTermSystemPromptIT.java @@ -36,7 +36,7 @@ import org.springframework.ai.chat.memory.SystemPromptChatMemoryAugmentor; import org.springframework.ai.embedding.EmbeddingClient; import org.springframework.ai.evaluation.BaseMemoryTest; import org.springframework.ai.evaluation.RelevancyEvaluator; -import org.springframework.ai.openai.OpenAiModelCall; +import org.springframework.ai.openai.OpenAiModelCaller; import org.springframework.ai.openai.OpenAiEmbeddingClient; import org.springframework.ai.openai.api.OpenAiApi; import org.springframework.ai.tokenizer.JTokkitTokenCountEstimator; @@ -75,8 +75,8 @@ public class ChatMemoryLongTermSystemPromptIT extends BaseMemoryTest { } @Bean - public OpenAiModelCall openAiClient(OpenAiApi openAiApi) { - return new OpenAiModelCall(openAiApi); + public OpenAiModelCaller openAiClient(OpenAiApi openAiApi) { + return new OpenAiModelCaller(openAiApi); } @Bean @@ -98,7 +98,7 @@ public class ChatMemoryLongTermSystemPromptIT extends BaseMemoryTest { } @Bean - public ChatService memoryChatService(OpenAiModelCall chatClient, VectorStore vectorStore, + public ChatService memoryChatService(OpenAiModelCaller chatClient, VectorStore vectorStore, TokenCountEstimator tokenCountEstimator) { return PromptTransformingChatService.builder(chatClient) @@ -110,7 +110,7 @@ public class ChatMemoryLongTermSystemPromptIT extends BaseMemoryTest { } @Bean - public StreamingChatService memoryStreamingChatService(OpenAiModelCall streamingChatClient, + public StreamingChatService memoryStreamingChatService(OpenAiModelCaller streamingChatClient, VectorStore vectorStore, TokenCountEstimator tokenCountEstimator) { return StreamingPromptTransformingChatService.builder(streamingChatClient) @@ -122,7 +122,7 @@ public class ChatMemoryLongTermSystemPromptIT extends BaseMemoryTest { } @Bean - public RelevancyEvaluator relevancyEvaluator(OpenAiModelCall chatClient) { + public RelevancyEvaluator relevancyEvaluator(OpenAiModelCaller chatClient) { return new RelevancyEvaluator(chatClient); } diff --git a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/service/ChatMemoryShortTermMessageListIT.java b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/service/ChatMemoryShortTermMessageListIT.java index 01e838262..5ddc17a99 100644 --- a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/service/ChatMemoryShortTermMessageListIT.java +++ b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/service/ChatMemoryShortTermMessageListIT.java @@ -31,7 +31,7 @@ import org.springframework.ai.chat.memory.LastMaxTokenSizeContentTransformer; import org.springframework.ai.chat.memory.MessageChatMemoryAugmentor; import org.springframework.ai.evaluation.BaseMemoryTest; import org.springframework.ai.evaluation.RelevancyEvaluator; -import org.springframework.ai.openai.OpenAiModelCall; +import org.springframework.ai.openai.OpenAiModelCaller; import org.springframework.ai.openai.api.OpenAiApi; import org.springframework.ai.tokenizer.JTokkitTokenCountEstimator; import org.springframework.ai.tokenizer.TokenCountEstimator; @@ -59,8 +59,8 @@ public class ChatMemoryShortTermMessageListIT extends BaseMemoryTest { } @Bean - public OpenAiModelCall openAiClient(OpenAiApi openAiApi) { - return new OpenAiModelCall(openAiApi); + public OpenAiModelCaller openAiClient(OpenAiApi openAiApi) { + return new OpenAiModelCaller(openAiApi); } @Bean @@ -74,7 +74,7 @@ public class ChatMemoryShortTermMessageListIT extends BaseMemoryTest { } @Bean - public ChatService memoryChatService(OpenAiModelCall chatClient, ChatMemory chatHistory, + public ChatService memoryChatService(OpenAiModelCaller chatClient, ChatMemory chatHistory, TokenCountEstimator tokenCountEstimator) { return PromptTransformingChatService.builder(chatClient) @@ -86,7 +86,7 @@ public class ChatMemoryShortTermMessageListIT extends BaseMemoryTest { } @Bean - public StreamingChatService memoryStreamingChatService(OpenAiModelCall streamingChatClient, + public StreamingChatService memoryStreamingChatService(OpenAiModelCaller streamingChatClient, ChatMemory chatHistory, TokenCountEstimator tokenCountEstimator) { return StreamingPromptTransformingChatService.builder(streamingChatClient) @@ -98,7 +98,7 @@ public class ChatMemoryShortTermMessageListIT extends BaseMemoryTest { } @Bean - public RelevancyEvaluator relevancyEvaluator(OpenAiModelCall chatClient) { + public RelevancyEvaluator relevancyEvaluator(OpenAiModelCaller chatClient) { return new RelevancyEvaluator(chatClient); } diff --git a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/service/ChatMemoryShortTermSystemPromptIT.java b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/service/ChatMemoryShortTermSystemPromptIT.java index e1290f6d2..9acb8a2b9 100644 --- a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/service/ChatMemoryShortTermSystemPromptIT.java +++ b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/service/ChatMemoryShortTermSystemPromptIT.java @@ -32,7 +32,7 @@ import org.springframework.ai.chat.memory.LastMaxTokenSizeContentTransformer; import org.springframework.ai.chat.memory.SystemPromptChatMemoryAugmentor; import org.springframework.ai.evaluation.BaseMemoryTest; import org.springframework.ai.evaluation.RelevancyEvaluator; -import org.springframework.ai.openai.OpenAiModelCall; +import org.springframework.ai.openai.OpenAiModelCaller; import org.springframework.ai.openai.api.OpenAiApi; import org.springframework.ai.tokenizer.JTokkitTokenCountEstimator; import org.springframework.ai.tokenizer.TokenCountEstimator; @@ -60,8 +60,8 @@ public class ChatMemoryShortTermSystemPromptIT extends BaseMemoryTest { } @Bean - public OpenAiModelCall openAiClient(OpenAiApi openAiApi) { - return new OpenAiModelCall(openAiApi); + public OpenAiModelCaller openAiClient(OpenAiApi openAiApi) { + return new OpenAiModelCaller(openAiApi); } @Bean @@ -75,7 +75,7 @@ public class ChatMemoryShortTermSystemPromptIT extends BaseMemoryTest { } @Bean - public ChatService memoryChatService(OpenAiModelCall chatClient, ChatMemory chatHistory, + public ChatService memoryChatService(OpenAiModelCaller chatClient, ChatMemory chatHistory, TokenCountEstimator tokenCountEstimator) { return PromptTransformingChatService.builder(chatClient) @@ -87,7 +87,7 @@ public class ChatMemoryShortTermSystemPromptIT extends BaseMemoryTest { } @Bean - public StreamingChatService memoryStreamingChatService(OpenAiModelCall streamingChatClient, + public StreamingChatService memoryStreamingChatService(OpenAiModelCaller streamingChatClient, ChatMemory chatHistory, TokenCountEstimator tokenCountEstimator) { return StreamingPromptTransformingChatService.builder(streamingChatClient) @@ -99,7 +99,7 @@ public class ChatMemoryShortTermSystemPromptIT extends BaseMemoryTest { } @Bean - public RelevancyEvaluator relevancyEvaluator(OpenAiModelCall chatClient) { + public RelevancyEvaluator relevancyEvaluator(OpenAiModelCaller chatClient) { return new RelevancyEvaluator(chatClient); } diff --git a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/service/LongShortTermChatMemoryWithRagIT.java b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/service/LongShortTermChatMemoryWithRagIT.java index 0acb5a90d..e39e098a8 100644 --- a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/service/LongShortTermChatMemoryWithRagIT.java +++ b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/service/LongShortTermChatMemoryWithRagIT.java @@ -30,7 +30,7 @@ import org.springframework.ai.chat.prompt.transformer.ChatServiceContext; import org.springframework.ai.chat.service.ChatService; import org.springframework.ai.chat.service.PromptTransformingChatService; import org.springframework.ai.openai.OpenAiChatOptions; -import org.springframework.ai.openai.OpenAiModelCall; +import org.springframework.ai.openai.OpenAiModelCaller; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.qdrant.QdrantContainer; @@ -163,8 +163,8 @@ public class LongShortTermChatMemoryWithRagIT { } @Bean - public OpenAiModelCall openAiClient(OpenAiApi openAiApi) { - return new OpenAiModelCall(openAiApi); + public OpenAiModelCaller openAiClient(OpenAiApi openAiApi) { + return new OpenAiModelCaller(openAiApi); } @Bean @@ -186,7 +186,7 @@ public class LongShortTermChatMemoryWithRagIT { } @Bean - public ChatService memoryChatService(OpenAiModelCall chatClient, VectorStore vectorStore, + public ChatService memoryChatService(OpenAiModelCaller chatClient, VectorStore vectorStore, TokenCountEstimator tokenCountEstimator, ChatMemory chatHistory) { return PromptTransformingChatService.builder(chatClient) @@ -240,7 +240,7 @@ public class LongShortTermChatMemoryWithRagIT { // } @Bean - public RelevancyEvaluator relevancyEvaluator(OpenAiModelCall chatClient) { + public RelevancyEvaluator relevancyEvaluator(OpenAiModelCaller chatClient) { // Use GPT 4 as a better model for determining relevancy. gpt 3.5 makes basic // mistakes OpenAiChatOptions openAiChatOptions = OpenAiChatOptions.builder() diff --git a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/service/OpenAiPromptTransformingChatServiceIT.java b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/service/OpenAiPromptTransformingChatServiceIT.java index 80074e07a..ac7c4d180 100644 --- a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/service/OpenAiPromptTransformingChatServiceIT.java +++ b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/service/OpenAiPromptTransformingChatServiceIT.java @@ -23,7 +23,7 @@ import io.qdrant.client.QdrantClient; import io.qdrant.client.QdrantGrpcClient; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.chat.service.ChatService; import org.springframework.ai.chat.prompt.transformer.TransformerContentType; import org.springframework.ai.document.Document; @@ -41,7 +41,7 @@ import org.springframework.ai.chat.prompt.transformer.VectorStoreRetriever; import org.springframework.ai.embedding.EmbeddingClient; import org.springframework.ai.evaluation.EvaluationResponse; import org.springframework.ai.evaluation.RelevancyEvaluator; -import org.springframework.ai.openai.OpenAiModelCall; +import org.springframework.ai.openai.OpenAiModelCaller; import org.springframework.ai.openai.OpenAiEmbeddingClient; import org.springframework.ai.openai.api.OpenAiApi; import org.springframework.ai.reader.JsonReader; @@ -71,7 +71,7 @@ public class OpenAiPromptTransformingChatServiceIT { @Container static QdrantContainer qdrantContainer = new QdrantContainer("qdrant/qdrant:v1.9.2"); - private final ModelCall modelCall; + private final ChatCaller modelCall; private final VectorStore vectorStore; @@ -81,7 +81,7 @@ public class OpenAiPromptTransformingChatServiceIT { private ChatService chatService; @Autowired - public OpenAiPromptTransformingChatServiceIT(ModelCall modelCall, ChatService chatService, + public OpenAiPromptTransformingChatServiceIT(ChatCaller modelCall, ChatService chatService, VectorStore vectorStore) { this.modelCall = modelCall; this.chatService = chatService; @@ -145,8 +145,8 @@ public class OpenAiPromptTransformingChatServiceIT { } @Bean - public ModelCall openAiClient(OpenAiApi openAiApi) { - return new OpenAiModelCall(openAiApi); + public ChatCaller openAiClient(OpenAiApi openAiApi) { + return new OpenAiModelCaller(openAiApi); } @Bean @@ -163,7 +163,7 @@ public class OpenAiPromptTransformingChatServiceIT { } @Bean - public ChatService chatService(ModelCall modelCall, VectorStore vectorStore) { + public ChatService chatService(ChatCaller modelCall, VectorStore vectorStore) { return PromptTransformingChatService.builder(modelCall) .withRetrievers(List.of(new VectorStoreRetriever(vectorStore, SearchRequest.defaults()))) .withAugmentors(List.of(new QuestionContextAugmentor())) diff --git a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/testutils/AbstractIT.java b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/testutils/AbstractIT.java index 2538f2133..ea7b94d41 100644 --- a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/testutils/AbstractIT.java +++ b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/testutils/AbstractIT.java @@ -21,7 +21,7 @@ import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.StreamingChatClient; import org.springframework.ai.chat.prompt.Prompt; @@ -43,7 +43,7 @@ public abstract class AbstractIT { private static final Logger logger = LoggerFactory.getLogger(AbstractIT.class); @Autowired - protected ModelCall modelCall; + protected ChatCaller modelCaller; @Autowired protected StreamingChatClient streamingChatClient; @@ -85,12 +85,12 @@ public abstract class AbstractIT { } Message userMessage = userPromptTemplate.createMessage(); Prompt prompt = new Prompt(List.of(userMessage, systemMessage)); - String yesOrNo = modelCall.call(prompt).getResult().getOutput().getContent(); + String yesOrNo = modelCaller.call(prompt).getResult().getOutput().getContent(); logger.info("Is Answer related to question: " + yesOrNo); if (yesOrNo.equalsIgnoreCase("no")) { SystemMessage notRelatedSystemMessage = new SystemMessage(qaEvaluatorNotRelatedResource); prompt = new Prompt(List.of(userMessage, notRelatedSystemMessage)); - String reasonForFailure = modelCall.call(prompt).getResult().getOutput().getContent(); + String reasonForFailure = modelCaller.call(prompt).getResult().getOutput().getContent(); fail(reasonForFailure); } else { diff --git a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/transformer/MetadataTransformerIT.java b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/transformer/MetadataTransformerIT.java index 363534368..6ae0195ad 100644 --- a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/transformer/MetadataTransformerIT.java +++ b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/transformer/MetadataTransformerIT.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test; import org.springframework.ai.document.DefaultContentFormatter; import org.springframework.ai.document.Document; -import org.springframework.ai.openai.OpenAiModelCall; +import org.springframework.ai.openai.OpenAiModelCaller; import org.springframework.ai.openai.api.OpenAiApi; import org.springframework.ai.transformer.ContentFormatTransformer; import org.springframework.ai.transformer.KeywordMetadataEnricher; @@ -163,18 +163,18 @@ public class MetadataTransformerIT { } @Bean - public OpenAiModelCall openAiChatClient(OpenAiApi openAiApi) { - OpenAiModelCall openAiChatClient = new OpenAiModelCall(openAiApi); + public OpenAiModelCaller openAiChatClient(OpenAiApi openAiApi) { + OpenAiModelCaller openAiChatClient = new OpenAiModelCaller(openAiApi); return openAiChatClient; } @Bean - public KeywordMetadataEnricher keywordMetadata(OpenAiModelCall aiClient) { + public KeywordMetadataEnricher keywordMetadata(OpenAiModelCaller aiClient) { return new KeywordMetadataEnricher(aiClient, 5); } @Bean - public SummaryMetadataEnricher summaryMetadata(OpenAiModelCall aiClient) { + public SummaryMetadataEnricher summaryMetadata(OpenAiModelCaller aiClient) { return new SummaryMetadataEnricher(aiClient, List.of(SummaryType.PREVIOUS, SummaryType.CURRENT, SummaryType.NEXT)); } diff --git a/models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiChatOptions.java b/models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiChatOptions.java index b583c31db..081136c42 100644 --- a/models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiChatOptions.java +++ b/models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiChatOptions.java @@ -28,7 +28,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.ai.chat.prompt.ChatOptions; import org.springframework.ai.model.function.FunctionCallback; import org.springframework.ai.model.function.FunctionCallingOptions; -import org.springframework.ai.vertexai.gemini.VertexAiGeminiModelCall.ChatModel; +import org.springframework.ai.vertexai.gemini.VertexAiGeminiModelCaller.ChatModel; import org.springframework.boot.context.properties.NestedConfigurationProperty; import org.springframework.util.Assert; diff --git a/models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiModelCall.java b/models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiModelCaller.java similarity index 97% rename from models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiModelCall.java rename to models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiModelCaller.java index 336135fc4..e932c9573 100644 --- a/models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiModelCall.java +++ b/models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiModelCaller.java @@ -32,7 +32,7 @@ import com.google.cloud.vertexai.generativeai.PartMaker; import com.google.cloud.vertexai.generativeai.ResponseStream; import com.google.protobuf.Struct; import com.google.protobuf.util.JsonFormat; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.Generation; import org.springframework.ai.chat.StreamingChatClient; @@ -65,9 +65,9 @@ import java.util.stream.Collectors; * @author Grogdunn * @since 0.8.1 */ -public class VertexAiGeminiModelCall - extends AbstractFunctionCallSupport - implements ModelCall, StreamingChatClient, DisposableBean { +public class VertexAiGeminiModelCaller + extends AbstractFunctionCallSupport + implements ChatCaller, StreamingChatClient, DisposableBean { private final static boolean IS_RUNTIME_CALL = true; @@ -117,7 +117,7 @@ public class VertexAiGeminiModelCall } - public VertexAiGeminiModelCall(VertexAI vertexAI) { + public VertexAiGeminiModelCaller(VertexAI vertexAI) { this(vertexAI, VertexAiGeminiChatOptions.builder() .withModel(ChatModel.GEMINI_PRO_VISION) @@ -125,11 +125,11 @@ public class VertexAiGeminiModelCall .build()); } - public VertexAiGeminiModelCall(VertexAI vertexAI, VertexAiGeminiChatOptions options) { + public VertexAiGeminiModelCaller(VertexAI vertexAI, VertexAiGeminiChatOptions options) { this(vertexAI, options, null); } - public VertexAiGeminiModelCall(VertexAI vertexAI, VertexAiGeminiChatOptions options, + public VertexAiGeminiModelCaller(VertexAI vertexAI, VertexAiGeminiChatOptions options, FunctionCallbackContext functionCallbackContext) { super(functionCallbackContext); diff --git a/models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/aot/VertexAiGeminiRuntimeHints.java b/models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/aot/VertexAiGeminiRuntimeHints.java index d24088278..9515ce0a1 100644 --- a/models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/aot/VertexAiGeminiRuntimeHints.java +++ b/models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/aot/VertexAiGeminiRuntimeHints.java @@ -15,7 +15,7 @@ */ package org.springframework.ai.vertexai.gemini.aot; -import org.springframework.ai.vertexai.gemini.VertexAiGeminiModelCall; +import org.springframework.ai.vertexai.gemini.VertexAiGeminiModelCaller; import org.springframework.aot.hint.MemberCategory; import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.RuntimeHintsRegistrar; @@ -34,7 +34,7 @@ public class VertexAiGeminiRuntimeHints implements RuntimeHintsRegistrar { @Override public void registerHints(RuntimeHints hints, ClassLoader classLoader) { var mcs = MemberCategory.values(); - for (var tr : findJsonAnnotatedClassesInPackage(VertexAiGeminiModelCall.class)) + for (var tr : findJsonAnnotatedClassesInPackage(VertexAiGeminiModelCaller.class)) hints.reflection().registerType(tr, mcs); } diff --git a/models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiModelCallIT.java b/models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiModelCallerIT.java similarity index 96% rename from models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiModelCallIT.java rename to models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiModelCallerIT.java index d72285581..343a09d64 100644 --- a/models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiModelCallIT.java +++ b/models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiModelCallerIT.java @@ -53,10 +53,10 @@ import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest @EnabledIfEnvironmentVariable(named = "VERTEX_AI_GEMINI_PROJECT_ID", matches = ".*") @EnabledIfEnvironmentVariable(named = "VERTEX_AI_GEMINI_LOCATION", matches = ".*") -class VertexAiGeminiModelCallIT { +class VertexAiGeminiModelCallerIT { @Autowired - private VertexAiGeminiModelCall client; + private VertexAiGeminiModelCaller client; @Value("classpath:/prompts/system-message.st") private Resource systemResource; @@ -231,10 +231,10 @@ class VertexAiGeminiModelCallIT { } @Bean - public VertexAiGeminiModelCall vertexAiEmbedding(VertexAI vertexAi) { - return new VertexAiGeminiModelCall(vertexAi, + public VertexAiGeminiModelCaller vertexAiEmbedding(VertexAI vertexAi) { + return new VertexAiGeminiModelCaller(vertexAi, VertexAiGeminiChatOptions.builder() - .withModel(VertexAiGeminiModelCall.ChatModel.GEMINI_PRO_VISION) + .withModel(VertexAiGeminiModelCaller.ChatModel.GEMINI_PRO_VISION) .build()); } diff --git a/models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/aot/VertexAiGeminiRuntimeHintsTests.java b/models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/aot/VertexAiGeminiRuntimeHintsTests.java index 1ac4f9599..268b1a47e 100644 --- a/models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/aot/VertexAiGeminiRuntimeHintsTests.java +++ b/models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/aot/VertexAiGeminiRuntimeHintsTests.java @@ -19,7 +19,7 @@ import java.util.Set; import org.junit.jupiter.api.Test; -import org.springframework.ai.vertexai.gemini.VertexAiGeminiModelCall; +import org.springframework.ai.vertexai.gemini.VertexAiGeminiModelCaller; import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.TypeReference; @@ -38,7 +38,7 @@ class VertexAiGeminiRuntimeHintsTests { RuntimeHints runtimeHints = new RuntimeHints(); VertexAiGeminiRuntimeHints vertexAiGeminiRuntimeHints = new VertexAiGeminiRuntimeHints(); vertexAiGeminiRuntimeHints.registerHints(runtimeHints, null); - Set jsonAnnotatedClasses = findJsonAnnotatedClassesInPackage(VertexAiGeminiModelCall.class); + Set jsonAnnotatedClasses = findJsonAnnotatedClassesInPackage(VertexAiGeminiModelCaller.class); for (TypeReference jsonAnnotatedClass : jsonAnnotatedClasses) { assertThat(runtimeHints).matches(reflection().onType(jsonAnnotatedClass)); } diff --git a/models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/function/VertexAiGeminiModelCallFunctionCallingIT.java b/models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/function/VertexAiGeminiModelCallFunctionCallingIT.java index 1f87569c5..7194923a7 100644 --- a/models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/function/VertexAiGeminiModelCallFunctionCallingIT.java +++ b/models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/function/VertexAiGeminiModelCallFunctionCallingIT.java @@ -28,7 +28,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.ai.vertexai.gemini.VertexAiGeminiModelCall; +import org.springframework.ai.vertexai.gemini.VertexAiGeminiModelCaller; import reactor.core.publisher.Flux; import org.springframework.ai.chat.ChatResponse; @@ -55,7 +55,7 @@ public class VertexAiGeminiModelCallFunctionCallingIT { private final Logger logger = LoggerFactory.getLogger(getClass()); @Autowired - private VertexAiGeminiModelCall vertexGeminiClient; + private VertexAiGeminiModelCaller vertexGeminiClient; @AfterEach public void afterEach() { @@ -98,7 +98,7 @@ public class VertexAiGeminiModelCallFunctionCallingIT { """; var promptOptions = VertexAiGeminiChatOptions.builder() - .withModel(VertexAiGeminiModelCall.ChatModel.GEMINI_PRO) + .withModel(VertexAiGeminiModelCaller.ChatModel.GEMINI_PRO) // .withModel(VertexAiGeminiModelCall.ChatModel.GEMINI_PRO_1_5_PRO) .withFunctionCallbacks(List.of(FunctionCallbackWrapper.builder(new MockWeatherService()) .withName("get_current_weather") @@ -127,7 +127,7 @@ public class VertexAiGeminiModelCallFunctionCallingIT { var promptOptions = VertexAiGeminiChatOptions.builder() // .withModel(VertexAiGeminiModelCall.ChatModel.GEMINI_PRO_1_5_PRO) - .withModel(VertexAiGeminiModelCall.ChatModel.GEMINI_PRO.getValue()) + .withModel(VertexAiGeminiModelCaller.ChatModel.GEMINI_PRO.getValue()) .withFunctionCallbacks(List.of( FunctionCallbackWrapper.builder(new MockWeatherService()) .withSchemaType(SchemaType.OPEN_API_SCHEMA) @@ -168,7 +168,7 @@ public class VertexAiGeminiModelCallFunctionCallingIT { List messages = new ArrayList<>(List.of(userMessage)); var promptOptions = VertexAiGeminiChatOptions.builder() - .withModel(VertexAiGeminiModelCall.ChatModel.GEMINI_PRO) + .withModel(VertexAiGeminiModelCaller.ChatModel.GEMINI_PRO) .withFunctionCallbacks(List.of(FunctionCallbackWrapper.builder(new MockWeatherService()) .withSchemaType(SchemaType.OPEN_API_SCHEMA) .withName("getCurrentWeather") @@ -224,10 +224,10 @@ public class VertexAiGeminiModelCallFunctionCallingIT { } @Bean - public VertexAiGeminiModelCall vertexAiEmbedding(VertexAI vertexAi) { - return new VertexAiGeminiModelCall(vertexAi, + public VertexAiGeminiModelCaller vertexAiEmbedding(VertexAI vertexAi) { + return new VertexAiGeminiModelCaller(vertexAi, VertexAiGeminiChatOptions.builder() - .withModel(VertexAiGeminiModelCall.ChatModel.GEMINI_PRO) + .withModel(VertexAiGeminiModelCaller.ChatModel.GEMINI_PRO) .withTemperature(0.9f) .build()); } diff --git a/models/spring-ai-vertex-ai-palm2/src/main/java/org/springframework/ai/vertexai/palm2/VertexAiPaLm2ModelCall.java b/models/spring-ai-vertex-ai-palm2/src/main/java/org/springframework/ai/vertexai/palm2/VertexAiPaLm2ModelCaller.java similarity index 93% rename from models/spring-ai-vertex-ai-palm2/src/main/java/org/springframework/ai/vertexai/palm2/VertexAiPaLm2ModelCall.java rename to models/spring-ai-vertex-ai-palm2/src/main/java/org/springframework/ai/vertexai/palm2/VertexAiPaLm2ModelCaller.java index e5b472c1c..e047d7323 100644 --- a/models/spring-ai-vertex-ai-palm2/src/main/java/org/springframework/ai/vertexai/palm2/VertexAiPaLm2ModelCall.java +++ b/models/spring-ai-vertex-ai-palm2/src/main/java/org/springframework/ai/vertexai/palm2/VertexAiPaLm2ModelCaller.java @@ -18,7 +18,7 @@ package org.springframework.ai.vertexai.palm2; import java.util.List; import java.util.stream.Collectors; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.chat.prompt.ChatOptions; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.Generation; @@ -35,18 +35,18 @@ import org.springframework.util.CollectionUtils; /** * @author Christian Tzolov */ -public class VertexAiPaLm2ModelCall implements ModelCall { +public class VertexAiPaLm2ModelCaller implements ChatCaller { private final VertexAiPaLm2Api vertexAiApi; private final VertexAiPaLm2ChatOptions defaultOptions; - public VertexAiPaLm2ModelCall(VertexAiPaLm2Api vertexAiApi) { + public VertexAiPaLm2ModelCaller(VertexAiPaLm2Api vertexAiApi) { this(vertexAiApi, VertexAiPaLm2ChatOptions.builder().withTemperature(0.7f).withCandidateCount(1).withTopK(20).build()); } - public VertexAiPaLm2ModelCall(VertexAiPaLm2Api vertexAiApi, VertexAiPaLm2ChatOptions defaultOptions) { + public VertexAiPaLm2ModelCaller(VertexAiPaLm2Api vertexAiApi, VertexAiPaLm2ChatOptions defaultOptions) { Assert.notNull(defaultOptions, "Default options must not be null!"); Assert.notNull(vertexAiApi, "VertexAiPaLm2Api must not be null!"); diff --git a/models/spring-ai-vertex-ai-palm2/src/test/java/org/springframework/ai/vertexai/palm2/VertexAiPaLm2ChatGenerationClientIT.java b/models/spring-ai-vertex-ai-palm2/src/test/java/org/springframework/ai/vertexai/palm2/VertexAiPaLm2ChatGenerationClientIT.java index f0a5c9a27..1ea9c86ff 100644 --- a/models/spring-ai-vertex-ai-palm2/src/test/java/org/springframework/ai/vertexai/palm2/VertexAiPaLm2ChatGenerationClientIT.java +++ b/models/spring-ai-vertex-ai-palm2/src/test/java/org/springframework/ai/vertexai/palm2/VertexAiPaLm2ChatGenerationClientIT.java @@ -48,7 +48,7 @@ import static org.assertj.core.api.Assertions.assertThat; class VertexAiPaLm2ChatGenerationClientIT { @Autowired - private VertexAiPaLm2ModelCall client; + private VertexAiPaLm2ModelCaller client; @Value("classpath:/prompts/system-message.st") private Resource systemResource; @@ -136,8 +136,8 @@ class VertexAiPaLm2ChatGenerationClientIT { } @Bean - public VertexAiPaLm2ModelCall vertexAiEmbedding(VertexAiPaLm2Api vertexAiApi) { - return new VertexAiPaLm2ModelCall(vertexAiApi); + public VertexAiPaLm2ModelCaller vertexAiEmbedding(VertexAiPaLm2Api vertexAiApi) { + return new VertexAiPaLm2ModelCaller(vertexAiApi); } } diff --git a/models/spring-ai-vertex-ai-palm2/src/test/java/org/springframework/ai/vertexai/palm2/VertexAiPaLm2ChatRequestTests.java b/models/spring-ai-vertex-ai-palm2/src/test/java/org/springframework/ai/vertexai/palm2/VertexAiPaLm2ChatRequestTests.java index 549a05833..c4321ab29 100644 --- a/models/spring-ai-vertex-ai-palm2/src/test/java/org/springframework/ai/vertexai/palm2/VertexAiPaLm2ChatRequestTests.java +++ b/models/spring-ai-vertex-ai-palm2/src/test/java/org/springframework/ai/vertexai/palm2/VertexAiPaLm2ChatRequestTests.java @@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat; */ public class VertexAiPaLm2ChatRequestTests { - VertexAiPaLm2ModelCall client = new VertexAiPaLm2ModelCall(new VertexAiPaLm2Api("bla")); + VertexAiPaLm2ModelCaller client = new VertexAiPaLm2ModelCaller(new VertexAiPaLm2Api("bla")); @Test public void createRequestWithDefaultOptions() { diff --git a/models/spring-ai-watsonx-ai/src/main/java/org/springframework/ai/watsonx/WatsonxAiModelCall.java b/models/spring-ai-watsonx-ai/src/main/java/org/springframework/ai/watsonx/WatsonxAiModelCaller.java similarity index 93% rename from models/spring-ai-watsonx-ai/src/main/java/org/springframework/ai/watsonx/WatsonxAiModelCall.java rename to models/spring-ai-watsonx-ai/src/main/java/org/springframework/ai/watsonx/WatsonxAiModelCaller.java index 496cb4220..571e5da31 100644 --- a/models/spring-ai-watsonx-ai/src/main/java/org/springframework/ai/watsonx/WatsonxAiModelCall.java +++ b/models/spring-ai-watsonx-ai/src/main/java/org/springframework/ai/watsonx/WatsonxAiModelCaller.java @@ -18,7 +18,7 @@ package org.springframework.ai.watsonx; import java.util.List; import java.util.Map; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import reactor.core.publisher.Flux; import org.springframework.ai.chat.ChatResponse; @@ -35,7 +35,7 @@ import org.springframework.ai.watsonx.utils.MessageToPromptConverter; import org.springframework.util.Assert; /** - * {@link ModelCall} implementation for {@literal watsonx.ai}. + * {@link ChatCaller} implementation for {@literal watsonx.ai}. * * watsonx.ai allows developers to use large language models within a SaaS service. It * supports multiple open-source models as well as IBM created models @@ -48,13 +48,13 @@ import org.springframework.util.Assert; * @author Christian Tzolov * @since 1.0.0 */ -public class WatsonxAiModelCall implements ModelCall, StreamingChatClient { +public class WatsonxAiModelCaller implements ChatCaller, StreamingChatClient { private final WatsonxAiApi watsonxAiApi; private final WatsonxAiChatOptions defaultOptions; - public WatsonxAiModelCall(WatsonxAiApi watsonxAiApi) { + public WatsonxAiModelCaller(WatsonxAiApi watsonxAiApi) { this(watsonxAiApi, WatsonxAiChatOptions.builder() .withTemperature(0.7f) @@ -68,7 +68,7 @@ public class WatsonxAiModelCall implements ModelCall, StreamingChatClient { .build()); } - public WatsonxAiModelCall(WatsonxAiApi watsonxAiApi, WatsonxAiChatOptions defaultOptions) { + public WatsonxAiModelCaller(WatsonxAiApi watsonxAiApi, WatsonxAiChatOptions defaultOptions) { Assert.notNull(watsonxAiApi, "watsonxAiApi cannot be null"); Assert.notNull(defaultOptions, "defaultOptions cannot be null"); this.watsonxAiApi = watsonxAiApi; diff --git a/models/spring-ai-watsonx-ai/src/test/java/org/springframework/ai/watsonx/WatsonxAiModelCallTest.java b/models/spring-ai-watsonx-ai/src/test/java/org/springframework/ai/watsonx/WatsonxAiModelCallerTest.java similarity index 97% rename from models/spring-ai-watsonx-ai/src/test/java/org/springframework/ai/watsonx/WatsonxAiModelCallTest.java rename to models/spring-ai-watsonx-ai/src/test/java/org/springframework/ai/watsonx/WatsonxAiModelCallerTest.java index c9c320c6d..21cdb6da9 100644 --- a/models/spring-ai-watsonx-ai/src/test/java/org/springframework/ai/watsonx/WatsonxAiModelCallTest.java +++ b/models/spring-ai-watsonx-ai/src/test/java/org/springframework/ai/watsonx/WatsonxAiModelCallerTest.java @@ -46,9 +46,9 @@ import static org.mockito.Mockito.when; * @author Pablo Sanchidrian Herrera * @author John Jairo Moreno Rojas */ -public class WatsonxAiModelCallTest { +public class WatsonxAiModelCallerTest { - WatsonxAiModelCall chatClient = new WatsonxAiModelCall(mock(WatsonxAiApi.class)); + WatsonxAiModelCaller chatClient = new WatsonxAiModelCaller(mock(WatsonxAiApi.class)); @Test public void testCreateRequestWithNoModelId() { @@ -157,7 +157,7 @@ public class WatsonxAiModelCallTest { @Test public void testCallMethod() { WatsonxAiApi mockChatApi = mock(WatsonxAiApi.class); - WatsonxAiModelCall client = new WatsonxAiModelCall(mockChatApi); + WatsonxAiModelCaller client = new WatsonxAiModelCaller(mockChatApi); Prompt prompt = new Prompt(List.of(new SystemMessage("Your prompt here")), WatsonxAiChatOptions.builder().withModel("google/flan-ul2").build()); @@ -186,7 +186,7 @@ public class WatsonxAiModelCallTest { @Test public void testStreamMethod() { WatsonxAiApi mockChatApi = mock(WatsonxAiApi.class); - WatsonxAiModelCall client = new WatsonxAiModelCall(mockChatApi); + WatsonxAiModelCaller client = new WatsonxAiModelCaller(mockChatApi); Prompt prompt = new Prompt(List.of(new SystemMessage("Your prompt here")), WatsonxAiChatOptions.builder().withModel("google/flan-ul2").build()); diff --git a/spring-ai-core/src/main/java/org/springframework/ai/chat/ModelCall.java b/spring-ai-core/src/main/java/org/springframework/ai/chat/ChatCaller.java similarity index 95% rename from spring-ai-core/src/main/java/org/springframework/ai/chat/ModelCall.java rename to spring-ai-core/src/main/java/org/springframework/ai/chat/ChatCaller.java index d8186bf1e..8498801ac 100644 --- a/spring-ai-core/src/main/java/org/springframework/ai/chat/ModelCall.java +++ b/spring-ai-core/src/main/java/org/springframework/ai/chat/ChatCaller.java @@ -24,7 +24,7 @@ import org.springframework.ai.chat.messages.UserMessage; import org.springframework.ai.model.ModelClient; @FunctionalInterface -public interface ModelCall extends ModelClient { +public interface ChatCaller extends ModelClient { default String call(String message) { Prompt prompt = new Prompt(new UserMessage(message)); diff --git a/spring-ai-core/src/main/java/org/springframework/ai/chat/ChatClient.java b/spring-ai-core/src/main/java/org/springframework/ai/chat/ChatClient.java index e34f7002d..7d5d52e5d 100644 --- a/spring-ai-core/src/main/java/org/springframework/ai/chat/ChatClient.java +++ b/spring-ai-core/src/main/java/org/springframework/ai/chat/ChatClient.java @@ -25,10 +25,12 @@ import org.springframework.ai.chat.prompt.PromptTemplate; import org.springframework.ai.converter.BeanOutputConverter; import org.springframework.ai.model.function.FunctionCallback; import org.springframework.ai.model.function.FunctionCallbackWrapper; +import org.springframework.ai.model.function.FunctionCallingOptions; import org.springframework.ai.model.function.FunctionCallingOptionsBuilder; import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.io.Resource; import org.springframework.util.Assert; +import org.springframework.util.CollectionUtils; import org.springframework.util.MimeType; import org.springframework.util.StringUtils; @@ -49,8 +51,8 @@ import java.util.function.Consumer; */ public interface ChatClient { - static ChatClientBuilder builder(ModelCall connector) { - return new ChatClientBuilder(connector); + static ChatClientBuilder builder(ChatCaller caller) { + return new ChatClientBuilder(caller); } ChatResponse call(Prompt prompt); @@ -165,7 +167,7 @@ public interface ChatClient { class ChatClientRequest { - private final ModelCall connector; + private final ChatCaller caller; private String userText = ""; @@ -173,6 +175,8 @@ public interface ChatClient { private ChatOptions chatOptions; + private FunctionCallingOptions functionCallingOptions; + private final List media = new ArrayList<>(); private final List functionNames = new ArrayList<>(); @@ -187,15 +191,15 @@ public interface ChatClient { /* copy constructor */ ChatClientRequest(ChatClientRequest ccr) { - this(ccr.connector, ccr.userText, ccr.systemText, ccr.functionCallbacks, ccr.functionNames, ccr.media, + this(ccr.caller, ccr.userText, ccr.systemText, ccr.functionCallbacks, ccr.functionNames, ccr.media, ccr.chatOptions); } - public ChatClientRequest(ModelCall connector, String userText, String systemText, + public ChatClientRequest(ChatCaller caller, String userText, String systemText, List functionCallbacks, List functionNames, List media, ChatOptions chatOptions) { - this.connector = connector; + this.caller = caller; this.chatOptions = chatOptions; this.userText = userText; @@ -258,9 +262,9 @@ public interface ChatClient { private final ChatClientRequest request; - private final ModelCall modelCall; + private final ChatCaller modelCall; - public ChatResponseSpec(ModelCall modelCall, ChatClientRequest request) { + public ChatResponseSpec(ChatCaller modelCall, ChatClientRequest request) { this.modelCall = modelCall; this.request = request; } @@ -272,8 +276,8 @@ public interface ChatClient { private T doSingleWithBeanOutputConverter(BeanOutputConverter boc) { var processedUserText = this.request.userText + System.lineSeparator() + System.lineSeparator() - + boc.getFormat(); - var chatResponse = doGetChatResponse(processedUserText); + + "{format}"; + var chatResponse = doGetChatResponse(processedUserText, boc.getFormat()); var stringResponse = chatResponse.getResult().getOutput().getContent(); return boc.convert(stringResponse); } @@ -285,6 +289,15 @@ public interface ChatClient { } private ChatResponse doGetChatResponse(String processedUserText) { + return this.doGetChatResponse(processedUserText, ""); + } + + private ChatResponse doGetChatResponse(String processedUserText, String formatParam) { + Map userParams = new HashMap<>(this.request.userParams); + if (StringUtils.hasText(formatParam)) { + userParams.put("format", formatParam); + } + var messages = new ArrayList(); var textsAreValid = (StringUtils.hasText(processedUserText) || StringUtils.hasText(this.request.systemText)); @@ -292,18 +305,28 @@ public interface ChatClient { Assert.state(!(messagesAreValid && textsAreValid), "you must specify either " + Message.class.getName() + " instances or user/system texts, but not both"); if (textsAreValid) { - var userMessage = new UserMessage( - new PromptTemplate(processedUserText, this.request.userParams).render(), - this.request.media); - var systemMessage = new SystemMessage( - new PromptTemplate(this.request.systemText, this.request.systemParams).render()); - messages.add(systemMessage); + UserMessage userMessage = null; + if (!CollectionUtils.isEmpty(userParams)) { + userMessage = new UserMessage(new PromptTemplate(processedUserText, userParams).render(), + this.request.media); + } + else { + userMessage = new UserMessage(processedUserText, this.request.media); + } + if (StringUtils.hasText(this.request.systemText) || !this.request.systemParams.isEmpty()) { + var systemMessage = new SystemMessage( + new PromptTemplate(this.request.systemText, this.request.systemParams).render()); + messages.add(systemMessage); + } messages.add(userMessage); } else { messages.addAll(this.request.messages); } - if (this.request.chatOptions instanceof FunctionCallingOptionsBuilder.PortableFunctionCallingOptions functionCallingOptions) { + if (this.request.chatOptions instanceof FunctionCallingOptions functionCallingOptions) { + // if (this.request.chatOptions instanceof + // FunctionCallingOptionsBuilder.PortableFunctionCallingOptions + // functionCallingOptions) { if (!this.request.functionNames.isEmpty()) { functionCallingOptions.setFunctions(new HashSet<>(this.request.functionNames)); } @@ -336,7 +359,7 @@ public interface ChatClient { } public ChatResponseSpec chat() { - return new ChatResponseSpec(this.connector, this); + return new ChatResponseSpec(this.caller, this); } } @@ -345,10 +368,10 @@ public interface ChatClient { private final ChatClientRequest defaultRequest; - private final ModelCall modelCall; + private final ChatCaller modelCall; - ChatClientBuilder(ModelCall modelCall) { - Assert.notNull(modelCall, "the " + ModelCall.class.getName() + " must be non-null"); + ChatClientBuilder(ChatCaller modelCall) { + Assert.notNull(modelCall, "the " + ChatCaller.class.getName() + " must be non-null"); this.modelCall = modelCall; this.defaultRequest = new ChatClientRequest(modelCall, "", "", List.of(), List.of(), List.of(), null); } diff --git a/spring-ai-core/src/main/java/org/springframework/ai/chat/DefaultChatClient.java b/spring-ai-core/src/main/java/org/springframework/ai/chat/DefaultChatClient.java index 93af65760..8c7ffd0f3 100644 --- a/spring-ai-core/src/main/java/org/springframework/ai/chat/DefaultChatClient.java +++ b/spring-ai-core/src/main/java/org/springframework/ai/chat/DefaultChatClient.java @@ -10,11 +10,11 @@ import org.springframework.ai.chat.prompt.Prompt; */ class DefaultChatClient implements ChatClient { - private final ModelCall modelCall; + private final ChatCaller modelCall; private final ChatClientRequest defaultChatClientRequest; - public DefaultChatClient(ModelCall modelCall, ChatClientRequest defaultChatClientRequest) { + public DefaultChatClient(ChatCaller modelCall, ChatClientRequest defaultChatClientRequest) { this.modelCall = modelCall; this.defaultChatClientRequest = defaultChatClientRequest; } diff --git a/spring-ai-core/src/main/java/org/springframework/ai/chat/service/PromptTransformingChatService.java b/spring-ai-core/src/main/java/org/springframework/ai/chat/service/PromptTransformingChatService.java index f7c1eb716..c94049e6e 100644 --- a/spring-ai-core/src/main/java/org/springframework/ai/chat/service/PromptTransformingChatService.java +++ b/spring-ai-core/src/main/java/org/springframework/ai/chat/service/PromptTransformingChatService.java @@ -15,7 +15,7 @@ */ package org.springframework.ai.chat.service; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.prompt.transformer.ChatServiceContext; import org.springframework.ai.chat.prompt.transformer.PromptTransformer; @@ -35,7 +35,7 @@ import java.util.Objects; */ public class PromptTransformingChatService implements ChatService { - private ModelCall modelCall; + private ChatCaller modelCall; private List retrievers; @@ -45,7 +45,7 @@ public class PromptTransformingChatService implements ChatService { private List chatServiceListeners; - public PromptTransformingChatService(ModelCall modelCall, List retrievers, + public PromptTransformingChatService(ChatCaller modelCall, List retrievers, List documentPostProcessors, List augmentors, List chatServiceListeners) { Objects.requireNonNull(modelCall, "modelCall must not be null"); @@ -56,7 +56,7 @@ public class PromptTransformingChatService implements ChatService { this.chatServiceListeners = chatServiceListeners; } - public static Builder builder(ModelCall modelCall) { + public static Builder builder(ChatCaller modelCall) { return new Builder().withChatClient(modelCall); } @@ -98,7 +98,7 @@ public class PromptTransformingChatService implements ChatService { public static class Builder { - private ModelCall modelCall; + private ChatCaller modelCall; private List retrievers = new ArrayList<>(); @@ -108,7 +108,7 @@ public class PromptTransformingChatService implements ChatService { private List chatServiceListeners = new ArrayList<>(); - public Builder withChatClient(ModelCall modelCall) { + public Builder withChatClient(ChatCaller modelCall) { this.modelCall = modelCall; return this; } diff --git a/spring-ai-core/src/main/java/org/springframework/ai/evaluation/RelevancyEvaluator.java b/spring-ai-core/src/main/java/org/springframework/ai/evaluation/RelevancyEvaluator.java index f9f7fa91f..342af9de5 100644 --- a/spring-ai-core/src/main/java/org/springframework/ai/evaluation/RelevancyEvaluator.java +++ b/spring-ai-core/src/main/java/org/springframework/ai/evaluation/RelevancyEvaluator.java @@ -1,6 +1,6 @@ package org.springframework.ai.evaluation; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.messages.Message; import org.springframework.ai.chat.messages.MessageType; @@ -31,13 +31,13 @@ public class RelevancyEvaluator implements Evaluator { private final ChatOptions chatOptions; - private ModelCall modelCall; + private ChatCaller modelCall; - public RelevancyEvaluator(ModelCall modelCall) { + public RelevancyEvaluator(ChatCaller modelCall) { this(modelCall, ChatOptionsBuilder.builder().build()); } - public RelevancyEvaluator(ModelCall modelCall, ChatOptions chatOptions) { + public RelevancyEvaluator(ChatCaller modelCall, ChatOptions chatOptions) { this.modelCall = modelCall; this.chatOptions = chatOptions; } diff --git a/spring-ai-core/src/main/java/org/springframework/ai/transformer/KeywordMetadataEnricher.java b/spring-ai-core/src/main/java/org/springframework/ai/transformer/KeywordMetadataEnricher.java index 10bdbf0e7..4b10225af 100644 --- a/spring-ai-core/src/main/java/org/springframework/ai/transformer/KeywordMetadataEnricher.java +++ b/spring-ai-core/src/main/java/org/springframework/ai/transformer/KeywordMetadataEnricher.java @@ -18,7 +18,7 @@ package org.springframework.ai.transformer; import java.util.List; import java.util.Map; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.document.Document; import org.springframework.ai.document.DocumentTransformer; import org.springframework.ai.chat.prompt.Prompt; @@ -43,14 +43,14 @@ public class KeywordMetadataEnricher implements DocumentTransformer { /** * Model predictor */ - private final ModelCall modelCall; + private final ChatCaller modelCall; /** * The number of keywords to extract. */ private final int keywordCount; - public KeywordMetadataEnricher(ModelCall modelCall, int keywordCount) { + public KeywordMetadataEnricher(ChatCaller modelCall, int keywordCount) { Assert.notNull(modelCall, "ModelCall must not be null"); Assert.isTrue(keywordCount >= 1, "Document count must be >= 1"); diff --git a/spring-ai-core/src/main/java/org/springframework/ai/transformer/SummaryMetadataEnricher.java b/spring-ai-core/src/main/java/org/springframework/ai/transformer/SummaryMetadataEnricher.java index 10f4b171f..508b24fcf 100644 --- a/spring-ai-core/src/main/java/org/springframework/ai/transformer/SummaryMetadataEnricher.java +++ b/spring-ai-core/src/main/java/org/springframework/ai/transformer/SummaryMetadataEnricher.java @@ -20,7 +20,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.document.Document; import org.springframework.ai.document.DocumentTransformer; import org.springframework.ai.document.MetadataMode; @@ -62,7 +62,7 @@ public class SummaryMetadataEnricher implements DocumentTransformer { /** * AI client. */ - private final ModelCall modelCall; + private final ChatCaller modelCall; /** * Number of documents from front to use for title extraction. @@ -76,11 +76,11 @@ public class SummaryMetadataEnricher implements DocumentTransformer { */ private final String summaryTemplate; - public SummaryMetadataEnricher(ModelCall modelCall, List summaryTypes) { + public SummaryMetadataEnricher(ChatCaller modelCall, List summaryTypes) { this(modelCall, summaryTypes, DEFAULT_SUMMARY_EXTRACT_TEMPLATE, MetadataMode.ALL); } - public SummaryMetadataEnricher(ModelCall modelCall, List summaryTypes, String summaryTemplate, + public SummaryMetadataEnricher(ChatCaller modelCall, List summaryTypes, String summaryTemplate, MetadataMode metadataMode) { Assert.notNull(modelCall, "ModelCall must not be null"); Assert.hasText(summaryTemplate, "Summary template must not be empty"); diff --git a/spring-ai-core/src/test/java/org/springframework/ai/chat/Main.java b/spring-ai-core/src/test/java/org/springframework/ai/chat/Main.java new file mode 100644 index 000000000..120a40eed --- /dev/null +++ b/spring-ai-core/src/test/java/org/springframework/ai/chat/Main.java @@ -0,0 +1,59 @@ +/* + * 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.chat; + +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URL; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.util.MimeType; +import org.springframework.util.MimeTypeUtils; + +/** + * @author Christian Tzolov + */ +@ExtendWith(MockitoExtension.class) +public class Main { + + @Mock + ChatCaller modelCaller; + + @Test + public void test() throws MalformedURLException { + + var url = new URL("https://docs.spring.io/spring-ai/reference/1.0-SNAPSHOT/_images/multimodal.test.png"); + + ChatClient client = ChatClient.builder(modelCaller) + .defaultSystem(s -> s.text("System text {music}")) + .defaultUser(u -> u.param("music", "Jazz")) + .defaultFunctions("function1") + .build(); + + String response = client.call() + .user(u -> u.text("User text {music}").param("music", "Rock").media(MimeTypeUtils.IMAGE_PNG, url)) + .chat() + .single(String.class); + + } + +} diff --git a/spring-ai-core/src/test/java/org/springframework/ai/chat/ModelCallTests.java b/spring-ai-core/src/test/java/org/springframework/ai/chat/ModelCallTests.java index a036a7de6..c04537729 100644 --- a/spring-ai-core/src/test/java/org/springframework/ai/chat/ModelCallTests.java +++ b/spring-ai-core/src/test/java/org/springframework/ai/chat/ModelCallTests.java @@ -34,7 +34,7 @@ import org.springframework.ai.chat.messages.AssistantMessage; import org.springframework.ai.chat.prompt.Prompt; /** - * Unit Tests for {@link ModelCall}. + * Unit Tests for {@link ChatCaller}. * * @author John Blum * @since 0.2.0 @@ -47,7 +47,7 @@ class ModelCallTests { String userMessage = "Zero Wing"; String responseMessage = "All your bases are belong to us"; - ModelCall mockClient = Mockito.mock(ModelCall.class); + ChatCaller mockClient = Mockito.mock(ChatCaller.class); AssistantMessage mockAssistantMessage = Mockito.mock(AssistantMessage.class); when(mockAssistantMessage.getContent()).thenReturn(responseMessage); diff --git a/spring-ai-core/src/test/java/org/springframework/ai/chat/memory/ChatMemoryTests.java b/spring-ai-core/src/test/java/org/springframework/ai/chat/memory/ChatMemoryTests.java index f76584040..79e7be2ac 100644 --- a/spring-ai-core/src/test/java/org/springframework/ai/chat/memory/ChatMemoryTests.java +++ b/spring-ai-core/src/test/java/org/springframework/ai/chat/memory/ChatMemoryTests.java @@ -25,7 +25,7 @@ import org.mockito.Captor; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.Generation; import org.springframework.ai.chat.StreamingChatClient; @@ -48,7 +48,7 @@ import static org.mockito.Mockito.when; public class ChatMemoryTests { @Mock - ModelCall modelCall; + ChatCaller modelCall; @Mock StreamingChatClient streamingChatClient; diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/anthropic/AnthropicAutoConfiguration.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/anthropic/AnthropicAutoConfiguration.java index cd184ff31..22281fd86 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/anthropic/AnthropicAutoConfiguration.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/anthropic/AnthropicAutoConfiguration.java @@ -17,7 +17,7 @@ package org.springframework.ai.autoconfigure.anthropic; import java.util.List; -import org.springframework.ai.anthropic.AnthropicModelCall; +import org.springframework.ai.anthropic.AnthropicModelCaller; import org.springframework.ai.anthropic.api.AnthropicApi; import org.springframework.ai.autoconfigure.retry.SpringAiRetryAutoConfiguration; import org.springframework.ai.model.function.FunctionCallback; @@ -57,7 +57,7 @@ public class AnthropicAutoConfiguration { @Bean @ConditionalOnMissingBean - public AnthropicModelCall anthropicChatClient(AnthropicApi anthropicApi, AnthropicChatProperties chatProperties, + public AnthropicModelCaller anthropicChatClient(AnthropicApi anthropicApi, AnthropicChatProperties chatProperties, RetryTemplate retryTemplate, FunctionCallbackContext functionCallbackContext, List toolFunctionCallbacks) { @@ -65,7 +65,7 @@ public class AnthropicAutoConfiguration { chatProperties.getOptions().getFunctionCallbacks().addAll(toolFunctionCallbacks); } - return new AnthropicModelCall(anthropicApi, chatProperties.getOptions(), retryTemplate, + return new AnthropicModelCaller(anthropicApi, chatProperties.getOptions(), retryTemplate, functionCallbackContext); } diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/anthropic/AnthropicChatProperties.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/anthropic/AnthropicChatProperties.java index 2f89076a5..dd6476a8f 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/anthropic/AnthropicChatProperties.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/anthropic/AnthropicChatProperties.java @@ -15,7 +15,7 @@ */ package org.springframework.ai.autoconfigure.anthropic; -import org.springframework.ai.anthropic.AnthropicModelCall; +import org.springframework.ai.anthropic.AnthropicModelCaller; import org.springframework.ai.anthropic.AnthropicChatOptions; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.NestedConfigurationProperty; @@ -43,9 +43,9 @@ public class AnthropicChatProperties { */ @NestedConfigurationProperty private AnthropicChatOptions options = AnthropicChatOptions.builder() - .withModel(AnthropicModelCall.DEFAULT_MODEL_NAME) - .withMaxTokens(AnthropicModelCall.DEFAULT_MAX_TOKENS) - .withTemperature(AnthropicModelCall.DEFAULT_TEMPERATURE) + .withModel(AnthropicModelCaller.DEFAULT_MODEL_NAME) + .withMaxTokens(AnthropicModelCaller.DEFAULT_MAX_TOKENS) + .withTemperature(AnthropicModelCaller.DEFAULT_TEMPERATURE) .build(); public AnthropicChatOptions getOptions() { diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/azure/openai/AzureOpenAiAutoConfiguration.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/azure/openai/AzureOpenAiAutoConfiguration.java index 009909874..18b828c91 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/azure/openai/AzureOpenAiAutoConfiguration.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/azure/openai/AzureOpenAiAutoConfiguration.java @@ -22,7 +22,7 @@ import com.azure.ai.openai.OpenAIClientBuilder; import com.azure.core.credential.AzureKeyCredential; import com.azure.core.util.ClientOptions; -import org.springframework.ai.azure.openai.AzureOpenAiModelCall; +import org.springframework.ai.azure.openai.AzureOpenAiModelCaller; import org.springframework.ai.azure.openai.AzureOpenAiEmbeddingClient; import org.springframework.ai.model.function.FunctionCallback; import org.springframework.ai.model.function.FunctionCallbackContext; @@ -37,7 +37,7 @@ import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; @AutoConfiguration -@ConditionalOnClass({ OpenAIClientBuilder.class, AzureOpenAiModelCall.class }) +@ConditionalOnClass({ OpenAIClientBuilder.class, AzureOpenAiModelCaller.class }) @EnableConfigurationProperties({ AzureOpenAiChatProperties.class, AzureOpenAiEmbeddingProperties.class, AzureOpenAiConnectionProperties.class }) public class AzureOpenAiAutoConfiguration { @@ -58,7 +58,7 @@ public class AzureOpenAiAutoConfiguration { @Bean @ConditionalOnProperty(prefix = AzureOpenAiChatProperties.CONFIG_PREFIX, name = "enabled", havingValue = "true", matchIfMissing = true) - public AzureOpenAiModelCall azureOpenAiChatClient(OpenAIClient openAIClient, + public AzureOpenAiModelCaller azureOpenAiChatClient(OpenAIClient openAIClient, AzureOpenAiChatProperties chatProperties, List toolFunctionCallbacks, FunctionCallbackContext functionCallbackContext) { @@ -66,8 +66,8 @@ public class AzureOpenAiAutoConfiguration { chatProperties.getOptions().getFunctionCallbacks().addAll(toolFunctionCallbacks); } - AzureOpenAiModelCall azureOpenAiChatClient = new AzureOpenAiModelCall(openAIClient, chatProperties.getOptions(), - functionCallbackContext); + AzureOpenAiModelCaller azureOpenAiChatClient = new AzureOpenAiModelCaller(openAIClient, + chatProperties.getOptions(), functionCallbackContext); return azureOpenAiChatClient; } diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/anthropic/BedrockAnthropicChatAutoConfiguration.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/anthropic/BedrockAnthropicChatAutoConfiguration.java index 1073bdafe..e241c56d0 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/anthropic/BedrockAnthropicChatAutoConfiguration.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/anthropic/BedrockAnthropicChatAutoConfiguration.java @@ -18,7 +18,7 @@ package org.springframework.ai.autoconfigure.bedrock.anthropic; import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.ai.autoconfigure.bedrock.BedrockAwsConnectionConfiguration; import org.springframework.ai.autoconfigure.bedrock.BedrockAwsConnectionProperties; -import org.springframework.ai.bedrock.anthropic.BedrockAnthropicModelCall; +import org.springframework.ai.bedrock.anthropic.BedrockAnthropicModelCaller; import org.springframework.ai.bedrock.anthropic.api.AnthropicChatBedrockApi; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; @@ -59,9 +59,9 @@ public class BedrockAnthropicChatAutoConfiguration { @Bean @ConditionalOnBean(AnthropicChatBedrockApi.class) - public BedrockAnthropicModelCall anthropicChatClient(AnthropicChatBedrockApi anthropicApi, + public BedrockAnthropicModelCaller anthropicChatClient(AnthropicChatBedrockApi anthropicApi, BedrockAnthropicChatProperties properties) { - return new BedrockAnthropicModelCall(anthropicApi, properties.getOptions()); + return new BedrockAnthropicModelCaller(anthropicApi, properties.getOptions()); } } diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/anthropic3/BedrockAnthropic3ChatAutoConfiguration.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/anthropic3/BedrockAnthropic3ChatAutoConfiguration.java index 116303352..050e60768 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/anthropic3/BedrockAnthropic3ChatAutoConfiguration.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/anthropic3/BedrockAnthropic3ChatAutoConfiguration.java @@ -18,7 +18,7 @@ package org.springframework.ai.autoconfigure.bedrock.anthropic3; import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.ai.autoconfigure.bedrock.BedrockAwsConnectionConfiguration; import org.springframework.ai.autoconfigure.bedrock.BedrockAwsConnectionProperties; -import org.springframework.ai.bedrock.anthropic3.BedrockAnthropic3ModelCall; +import org.springframework.ai.bedrock.anthropic3.BedrockAnthropic3ModelCaller; import org.springframework.ai.bedrock.anthropic3.api.Anthropic3ChatBedrockApi; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; @@ -59,9 +59,9 @@ public class BedrockAnthropic3ChatAutoConfiguration { @Bean @ConditionalOnBean(Anthropic3ChatBedrockApi.class) - public BedrockAnthropic3ModelCall anthropic3ChatClient(Anthropic3ChatBedrockApi anthropicApi, + public BedrockAnthropic3ModelCaller anthropic3ChatClient(Anthropic3ChatBedrockApi anthropicApi, BedrockAnthropic3ChatProperties properties) { - return new BedrockAnthropic3ModelCall(anthropicApi, properties.getOptions()); + return new BedrockAnthropic3ModelCaller(anthropicApi, properties.getOptions()); } } diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/cohere/BedrockCohereChatAutoConfiguration.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/cohere/BedrockCohereChatAutoConfiguration.java index eeb6a913e..8fdd1b708 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/cohere/BedrockCohereChatAutoConfiguration.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/cohere/BedrockCohereChatAutoConfiguration.java @@ -18,7 +18,7 @@ package org.springframework.ai.autoconfigure.bedrock.cohere; import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.ai.autoconfigure.bedrock.BedrockAwsConnectionConfiguration; import org.springframework.ai.autoconfigure.bedrock.BedrockAwsConnectionProperties; -import org.springframework.ai.bedrock.cohere.BedrockCohereModelCall; +import org.springframework.ai.bedrock.cohere.BedrockCohereModelCaller; import org.springframework.ai.bedrock.cohere.api.CohereChatBedrockApi; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; @@ -57,10 +57,10 @@ public class BedrockCohereChatAutoConfiguration { @Bean @ConditionalOnBean(CohereChatBedrockApi.class) - public BedrockCohereModelCall cohereChatClient(CohereChatBedrockApi cohereChatApi, + public BedrockCohereModelCaller cohereChatClient(CohereChatBedrockApi cohereChatApi, BedrockCohereChatProperties properties) { - return new BedrockCohereModelCall(cohereChatApi, properties.getOptions()); + return new BedrockCohereModelCaller(cohereChatApi, properties.getOptions()); } } diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/jurrasic2/BedrockAi21Jurassic2ChatAutoConfiguration.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/jurrasic2/BedrockAi21Jurassic2ChatAutoConfiguration.java index dc934c09e..4c30ecd52 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/jurrasic2/BedrockAi21Jurassic2ChatAutoConfiguration.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/jurrasic2/BedrockAi21Jurassic2ChatAutoConfiguration.java @@ -19,7 +19,7 @@ package org.springframework.ai.autoconfigure.bedrock.jurrasic2; import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.ai.autoconfigure.bedrock.BedrockAwsConnectionConfiguration; import org.springframework.ai.autoconfigure.bedrock.BedrockAwsConnectionProperties; -import org.springframework.ai.bedrock.jurassic2.BedrockAi21Jurassic2ModelCall; +import org.springframework.ai.bedrock.jurassic2.BedrockAi21Jurassic2ModelCaller; import org.springframework.ai.bedrock.jurassic2.api.Ai21Jurassic2ChatBedrockApi; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; @@ -59,10 +59,10 @@ public class BedrockAi21Jurassic2ChatAutoConfiguration { @Bean @ConditionalOnBean(Ai21Jurassic2ChatBedrockApi.class) - public BedrockAi21Jurassic2ModelCall jurassic2ChatClient(Ai21Jurassic2ChatBedrockApi ai21Jurassic2ChatBedrockApi, + public BedrockAi21Jurassic2ModelCaller jurassic2ChatClient(Ai21Jurassic2ChatBedrockApi ai21Jurassic2ChatBedrockApi, BedrockAi21Jurassic2ChatProperties properties) { - return BedrockAi21Jurassic2ModelCall.builder(ai21Jurassic2ChatBedrockApi) + return BedrockAi21Jurassic2ModelCaller.builder(ai21Jurassic2ChatBedrockApi) .withOptions(properties.getOptions()) .build(); } diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/llama/BedrockLlamaChatAutoConfiguration.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/llama/BedrockLlamaChatAutoConfiguration.java index bd36674cc..1a982c6b4 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/llama/BedrockLlamaChatAutoConfiguration.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/llama/BedrockLlamaChatAutoConfiguration.java @@ -16,7 +16,7 @@ package org.springframework.ai.autoconfigure.bedrock.llama; import com.fasterxml.jackson.databind.ObjectMapper; -import org.springframework.ai.bedrock.llama.BedrockLlamaModelCall; +import org.springframework.ai.bedrock.llama.BedrockLlamaModelCaller; import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider; import software.amazon.awssdk.regions.providers.AwsRegionProvider; @@ -59,9 +59,10 @@ public class BedrockLlamaChatAutoConfiguration { @Bean @ConditionalOnBean(LlamaChatBedrockApi.class) - public BedrockLlamaModelCall llamaChatClient(LlamaChatBedrockApi llamaApi, BedrockLlamaChatProperties properties) { + public BedrockLlamaModelCaller llamaChatClient(LlamaChatBedrockApi llamaApi, + BedrockLlamaChatProperties properties) { - return new BedrockLlamaModelCall(llamaApi, properties.getOptions()); + return new BedrockLlamaModelCaller(llamaApi, properties.getOptions()); } } diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/titan/BedrockTitanChatAutoConfiguration.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/titan/BedrockTitanChatAutoConfiguration.java index 9e59c5243..65eba57e9 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/titan/BedrockTitanChatAutoConfiguration.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/bedrock/titan/BedrockTitanChatAutoConfiguration.java @@ -18,7 +18,7 @@ package org.springframework.ai.autoconfigure.bedrock.titan; import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.ai.autoconfigure.bedrock.BedrockAwsConnectionConfiguration; import org.springframework.ai.autoconfigure.bedrock.BedrockAwsConnectionProperties; -import org.springframework.ai.bedrock.titan.BedrockTitanModelCall; +import org.springframework.ai.bedrock.titan.BedrockTitanModelCaller; import org.springframework.ai.bedrock.titan.api.TitanChatBedrockApi; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; @@ -57,10 +57,10 @@ public class BedrockTitanChatAutoConfiguration { @Bean @ConditionalOnBean(TitanChatBedrockApi.class) - public BedrockTitanModelCall titanChatClient(TitanChatBedrockApi titanChatApi, + public BedrockTitanModelCaller titanChatClient(TitanChatBedrockApi titanChatApi, BedrockTitanChatProperties properties) { - return new BedrockTitanModelCall(titanChatApi, properties.getOptions()); + return new BedrockTitanModelCaller(titanChatApi, properties.getOptions()); } } diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/huggingface/HuggingfaceChatAutoConfiguration.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/huggingface/HuggingfaceChatAutoConfiguration.java index 72b1ca584..c9e1967d2 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/huggingface/HuggingfaceChatAutoConfiguration.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/huggingface/HuggingfaceChatAutoConfiguration.java @@ -15,7 +15,7 @@ */ package org.springframework.ai.autoconfigure.huggingface; -import org.springframework.ai.huggingface.HuggingfaceModelCall; +import org.springframework.ai.huggingface.HuggingfaceModelCaller; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -24,7 +24,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.context.annotation.Bean; @AutoConfiguration -@ConditionalOnClass(HuggingfaceModelCall.class) +@ConditionalOnClass(HuggingfaceModelCaller.class) @EnableConfigurationProperties(HuggingfaceChatProperties.class) public class HuggingfaceChatAutoConfiguration { @@ -32,8 +32,8 @@ public class HuggingfaceChatAutoConfiguration { @ConditionalOnMissingBean @ConditionalOnProperty(prefix = HuggingfaceChatProperties.CONFIG_PREFIX, name = "enabled", havingValue = "true", matchIfMissing = true) - public HuggingfaceModelCall huggingfaceChatClient(HuggingfaceChatProperties huggingfaceChatProperties) { - return new HuggingfaceModelCall(huggingfaceChatProperties.getApiKey(), huggingfaceChatProperties.getUrl()); + public HuggingfaceModelCaller huggingfaceChatClient(HuggingfaceChatProperties huggingfaceChatProperties) { + return new HuggingfaceModelCaller(huggingfaceChatProperties.getApiKey(), huggingfaceChatProperties.getUrl()); } } diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/mistralai/MistralAiAutoConfiguration.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/mistralai/MistralAiAutoConfiguration.java index 78ec9ed69..3c986c162 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/mistralai/MistralAiAutoConfiguration.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/mistralai/MistralAiAutoConfiguration.java @@ -18,7 +18,7 @@ package org.springframework.ai.autoconfigure.mistralai; import java.util.List; import org.springframework.ai.autoconfigure.retry.SpringAiRetryAutoConfiguration; -import org.springframework.ai.mistralai.MistralAiModelCall; +import org.springframework.ai.mistralai.MistralAiModelCaller; import org.springframework.ai.mistralai.MistralAiEmbeddingClient; import org.springframework.ai.mistralai.api.MistralAiApi; import org.springframework.ai.model.function.FunctionCallback; @@ -69,7 +69,7 @@ public class MistralAiAutoConfiguration { @ConditionalOnMissingBean @ConditionalOnProperty(prefix = MistralAiChatProperties.CONFIG_PREFIX, name = "enabled", havingValue = "true", matchIfMissing = true) - public MistralAiModelCall mistralAiChatClient(MistralAiCommonProperties commonProperties, + public MistralAiModelCaller mistralAiChatClient(MistralAiCommonProperties commonProperties, MistralAiChatProperties chatProperties, RestClient.Builder restClientBuilder, List toolFunctionCallbacks, FunctionCallbackContext functionCallbackContext, RetryTemplate retryTemplate, ResponseErrorHandler responseErrorHandler) { @@ -81,7 +81,7 @@ public class MistralAiAutoConfiguration { chatProperties.getOptions().getFunctionCallbacks().addAll(toolFunctionCallbacks); } - return new MistralAiModelCall(mistralAiApi, chatProperties.getOptions(), functionCallbackContext, + return new MistralAiModelCaller(mistralAiApi, chatProperties.getOptions(), functionCallbackContext, retryTemplate); } diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/ollama/OllamaAutoConfiguration.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/ollama/OllamaAutoConfiguration.java index 17c2dd066..12c842bfb 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/ollama/OllamaAutoConfiguration.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/ollama/OllamaAutoConfiguration.java @@ -15,7 +15,7 @@ */ package org.springframework.ai.autoconfigure.ollama; -import org.springframework.ai.ollama.OllamaModelCall; +import org.springframework.ai.ollama.OllamaModelCaller; import org.springframework.ai.ollama.OllamaEmbeddingClient; import org.springframework.ai.ollama.api.OllamaApi; import org.springframework.boot.autoconfigure.AutoConfiguration; @@ -56,8 +56,8 @@ public class OllamaAutoConfiguration { @ConditionalOnMissingBean @ConditionalOnProperty(prefix = OllamaChatProperties.CONFIG_PREFIX, name = "enabled", havingValue = "true", matchIfMissing = true) - public OllamaModelCall ollamaChatClient(OllamaApi ollamaApi, OllamaChatProperties properties) { - return new OllamaModelCall(ollamaApi, properties.getOptions()); + public OllamaModelCaller ollamaChatClient(OllamaApi ollamaApi, OllamaChatProperties properties) { + return new OllamaModelCaller(ollamaApi, properties.getOptions()); } @Bean diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/openai/OpenAiAutoConfiguration.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/openai/OpenAiAutoConfiguration.java index 0b6fa829d..d0904b0ea 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/openai/OpenAiAutoConfiguration.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/openai/OpenAiAutoConfiguration.java @@ -21,7 +21,7 @@ import org.springframework.ai.autoconfigure.retry.SpringAiRetryAutoConfiguration import org.springframework.ai.model.function.FunctionCallback; import org.springframework.ai.model.function.FunctionCallbackContext; import org.springframework.ai.openai.*; -import org.springframework.ai.openai.OpenAiModelCall; +import org.springframework.ai.openai.OpenAiModelCaller; import org.springframework.ai.openai.api.OpenAiApi; import org.springframework.ai.openai.api.OpenAiAudioApi; import org.springframework.ai.openai.api.OpenAiImageApi; @@ -54,7 +54,7 @@ public class OpenAiAutoConfiguration { @ConditionalOnMissingBean @ConditionalOnProperty(prefix = OpenAiChatProperties.CONFIG_PREFIX, name = "enabled", havingValue = "true", matchIfMissing = true) - public OpenAiModelCall openAiChatClient(OpenAiConnectionProperties commonProperties, + public OpenAiModelCaller openAiChatClient(OpenAiConnectionProperties commonProperties, OpenAiChatProperties chatProperties, RestClient.Builder restClientBuilder, List toolFunctionCallbacks, FunctionCallbackContext functionCallbackContext, RetryTemplate retryTemplate, ResponseErrorHandler responseErrorHandler) { @@ -66,7 +66,7 @@ public class OpenAiAutoConfiguration { chatProperties.getOptions().getFunctionCallbacks().addAll(toolFunctionCallbacks); } - return new OpenAiModelCall(openAiApi, chatProperties.getOptions(), functionCallbackContext, retryTemplate); + return new OpenAiModelCaller(openAiApi, chatProperties.getOptions(), functionCallbackContext, retryTemplate); } @Bean diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vertexai/gemini/VertexAiGeminiAutoConfiguration.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vertexai/gemini/VertexAiGeminiAutoConfiguration.java index adad10a6e..9349dd63d 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vertexai/gemini/VertexAiGeminiAutoConfiguration.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vertexai/gemini/VertexAiGeminiAutoConfiguration.java @@ -24,7 +24,7 @@ import com.google.cloud.vertexai.VertexAI; import org.springframework.ai.model.function.FunctionCallback; import org.springframework.ai.model.function.FunctionCallbackContext; import org.springframework.ai.model.function.FunctionCallbackWrapper.Builder.SchemaType; -import org.springframework.ai.vertexai.gemini.VertexAiGeminiModelCall; +import org.springframework.ai.vertexai.gemini.VertexAiGeminiModelCaller; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -40,7 +40,7 @@ import org.springframework.util.StringUtils; * @author Christian Tzolov * @since 0.8.0 */ -@ConditionalOnClass({ VertexAI.class, VertexAiGeminiModelCall.class }) +@ConditionalOnClass({ VertexAI.class, VertexAiGeminiModelCaller.class }) @EnableConfigurationProperties({ VertexAiGeminiChatProperties.class, VertexAiGeminiConnectionProperties.class }) public class VertexAiGeminiAutoConfiguration { @@ -74,7 +74,7 @@ public class VertexAiGeminiAutoConfiguration { @Bean @ConditionalOnMissingBean - public VertexAiGeminiModelCall vertexAiGeminiChat(VertexAI vertexAi, VertexAiGeminiChatProperties chatProperties, + public VertexAiGeminiModelCaller vertexAiGeminiChat(VertexAI vertexAi, VertexAiGeminiChatProperties chatProperties, List toolFunctionCallbacks, ApplicationContext context) { FunctionCallbackContext functionCallbackContext = springAiFunctionManager(context); @@ -83,7 +83,7 @@ public class VertexAiGeminiAutoConfiguration { chatProperties.getOptions().getFunctionCallbacks().addAll(toolFunctionCallbacks); } - return new VertexAiGeminiModelCall(vertexAi, chatProperties.getOptions(), functionCallbackContext); + return new VertexAiGeminiModelCaller(vertexAi, chatProperties.getOptions(), functionCallbackContext); } /** diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vertexai/gemini/VertexAiGeminiChatProperties.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vertexai/gemini/VertexAiGeminiChatProperties.java index 3d97630c0..3506b71b1 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vertexai/gemini/VertexAiGeminiChatProperties.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vertexai/gemini/VertexAiGeminiChatProperties.java @@ -15,7 +15,7 @@ */ package org.springframework.ai.autoconfigure.vertexai.gemini; -import org.springframework.ai.vertexai.gemini.VertexAiGeminiModelCall; +import org.springframework.ai.vertexai.gemini.VertexAiGeminiModelCaller; import org.springframework.ai.vertexai.gemini.VertexAiGeminiChatOptions; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -30,7 +30,7 @@ public class VertexAiGeminiChatProperties { public static final String CONFIG_PREFIX = "spring.ai.vertex.ai.gemini.chat"; - public static final String DEFAULT_MODEL = VertexAiGeminiModelCall.ChatModel.GEMINI_PRO_VISION.getValue(); + public static final String DEFAULT_MODEL = VertexAiGeminiModelCaller.ChatModel.GEMINI_PRO_VISION.getValue(); /** * Vertex AI Gemini API generative options. diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vertexai/palm2/VertexAiPalm2AutoConfiguration.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vertexai/palm2/VertexAiPalm2AutoConfiguration.java index 13753c374..118aebf92 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vertexai/palm2/VertexAiPalm2AutoConfiguration.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vertexai/palm2/VertexAiPalm2AutoConfiguration.java @@ -15,7 +15,7 @@ */ package org.springframework.ai.autoconfigure.vertexai.palm2; -import org.springframework.ai.vertexai.palm2.VertexAiPaLm2ModelCall; +import org.springframework.ai.vertexai.palm2.VertexAiPaLm2ModelCaller; import org.springframework.ai.vertexai.palm2.VertexAiPaLm2EmbeddingClient; import org.springframework.ai.vertexai.palm2.api.VertexAiPaLm2Api; import org.springframework.boot.autoconfigure.AutoConfiguration; @@ -47,9 +47,9 @@ public class VertexAiPalm2AutoConfiguration { @ConditionalOnMissingBean @ConditionalOnProperty(prefix = VertexAiPlam2ChatProperties.CONFIG_PREFIX, name = "enabled", havingValue = "true", matchIfMissing = true) - public VertexAiPaLm2ModelCall vertexAiChatClient(VertexAiPaLm2Api vertexAiApi, + public VertexAiPaLm2ModelCaller vertexAiChatClient(VertexAiPaLm2Api vertexAiApi, VertexAiPlam2ChatProperties chatProperties) { - return new VertexAiPaLm2ModelCall(vertexAiApi, chatProperties.getOptions()); + return new VertexAiPaLm2ModelCaller(vertexAiApi, chatProperties.getOptions()); } @Bean diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/watsonxai/WatsonxAiAutoConfiguration.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/watsonxai/WatsonxAiAutoConfiguration.java index 7cec3a7eb..767f3ceb9 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/watsonxai/WatsonxAiAutoConfiguration.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/watsonxai/WatsonxAiAutoConfiguration.java @@ -15,7 +15,7 @@ */ package org.springframework.ai.autoconfigure.watsonxai; -import org.springframework.ai.watsonx.WatsonxAiModelCall; +import org.springframework.ai.watsonx.WatsonxAiModelCaller; import org.springframework.ai.watsonx.api.WatsonxAiApi; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; @@ -50,8 +50,8 @@ public class WatsonxAiAutoConfiguration { @Bean @ConditionalOnMissingBean - public WatsonxAiModelCall watsonxChatClient(WatsonxAiApi watsonxApi, WatsonxAiChatProperties chatProperties) { - return new WatsonxAiModelCall(watsonxApi, chatProperties.getOptions()); + public WatsonxAiModelCaller watsonxChatClient(WatsonxAiApi watsonxApi, WatsonxAiChatProperties chatProperties) { + return new WatsonxAiModelCaller(watsonxApi, chatProperties.getOptions()); } } diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/anthropic/AnthropicAutoConfigurationIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/anthropic/AnthropicAutoConfigurationIT.java index 20ed0de87..70095c73a 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/anthropic/AnthropicAutoConfigurationIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/anthropic/AnthropicAutoConfigurationIT.java @@ -22,7 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; -import org.springframework.ai.anthropic.AnthropicModelCall; +import org.springframework.ai.anthropic.AnthropicModelCaller; import reactor.core.publisher.Flux; import org.springframework.ai.autoconfigure.retry.SpringAiRetryAutoConfiguration; @@ -50,7 +50,7 @@ public class AnthropicAutoConfigurationIT { @Test void generate() { contextRunner.run(context -> { - AnthropicModelCall chatClient = context.getBean(AnthropicModelCall.class); + AnthropicModelCaller chatClient = context.getBean(AnthropicModelCaller.class); String response = chatClient.call("Hello"); assertThat(response).isNotEmpty(); logger.info("Response: " + response); @@ -60,7 +60,7 @@ public class AnthropicAutoConfigurationIT { @Test void generateStreaming() { contextRunner.run(context -> { - AnthropicModelCall chatClient = context.getBean(AnthropicModelCall.class); + AnthropicModelCaller chatClient = context.getBean(AnthropicModelCaller.class); Flux responseFlux = chatClient.stream(new Prompt(new UserMessage("Hello"))); String response = responseFlux.collectList() diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/anthropic/AnthropicPropertiesTests.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/anthropic/AnthropicPropertiesTests.java index c980a85bf..f676638d4 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/anthropic/AnthropicPropertiesTests.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/anthropic/AnthropicPropertiesTests.java @@ -17,7 +17,7 @@ package org.springframework.ai.autoconfigure.anthropic; import org.junit.jupiter.api.Test; -import org.springframework.ai.anthropic.AnthropicModelCall; +import org.springframework.ai.anthropic.AnthropicModelCaller; import org.springframework.ai.autoconfigure.retry.SpringAiRetryAutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.web.client.RestClientAutoConfiguration; @@ -102,7 +102,7 @@ public class AnthropicPropertiesTests { RestClientAutoConfiguration.class, AnthropicAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(AnthropicChatProperties.class)).isNotEmpty(); - assertThat(context.getBeansOfType(AnthropicModelCall.class)).isNotEmpty(); + assertThat(context.getBeansOfType(AnthropicModelCaller.class)).isNotEmpty(); }); // Explicitly enable the chat auto-configuration. @@ -111,7 +111,7 @@ public class AnthropicPropertiesTests { RestClientAutoConfiguration.class, AnthropicAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(AnthropicChatProperties.class)).isNotEmpty(); - assertThat(context.getBeansOfType(AnthropicModelCall.class)).isNotEmpty(); + assertThat(context.getBeansOfType(AnthropicModelCaller.class)).isNotEmpty(); }); // Explicitly disable the chat auto-configuration. @@ -120,7 +120,7 @@ public class AnthropicPropertiesTests { RestClientAutoConfiguration.class, AnthropicAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(AnthropicChatProperties.class)).isEmpty(); - assertThat(context.getBeansOfType(AnthropicModelCall.class)).isEmpty(); + assertThat(context.getBeansOfType(AnthropicModelCaller.class)).isEmpty(); }); } diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/anthropic/tool/FunctionCallWithFunctionBeanIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/anthropic/tool/FunctionCallWithFunctionBeanIT.java index 88998257c..55911585e 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/anthropic/tool/FunctionCallWithFunctionBeanIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/anthropic/tool/FunctionCallWithFunctionBeanIT.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.ai.anthropic.AnthropicModelCall; +import org.springframework.ai.anthropic.AnthropicModelCaller; import org.springframework.ai.anthropic.AnthropicChatOptions; import org.springframework.ai.anthropic.api.AnthropicApi; import org.springframework.ai.autoconfigure.anthropic.AnthropicAutoConfiguration; @@ -61,7 +61,7 @@ class FunctionCallWithFunctionBeanIT { "spring.ai.anthropic.chat.options.model=" + AnthropicApi.ChatModel.CLAUDE_3_OPUS.getValue()) .run(context -> { - AnthropicModelCall chatClient = context.getBean(AnthropicModelCall.class); + AnthropicModelCaller chatClient = context.getBean(AnthropicModelCaller.class); var userMessage = new UserMessage( "What's the weather like in San Francisco, in Paris, France and in Tokyo, Japan? Return the temperature in Celsius."); diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/anthropic/tool/FunctionCallWithPromptFunctionIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/anthropic/tool/FunctionCallWithPromptFunctionIT.java index 565682494..30f0ecaaf 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/anthropic/tool/FunctionCallWithPromptFunctionIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/anthropic/tool/FunctionCallWithPromptFunctionIT.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.ai.anthropic.AnthropicModelCall; +import org.springframework.ai.anthropic.AnthropicModelCaller; import org.springframework.ai.anthropic.AnthropicChatOptions; import org.springframework.ai.anthropic.api.AnthropicApi; import org.springframework.ai.autoconfigure.anthropic.AnthropicAutoConfiguration; @@ -54,7 +54,7 @@ public class FunctionCallWithPromptFunctionIT { "spring.ai.anthropic.chat.options.model=" + AnthropicApi.ChatModel.CLAUDE_3_OPUS.getValue()) .run(context -> { - AnthropicModelCall chatClient = context.getBean(AnthropicModelCall.class); + AnthropicModelCaller chatClient = context.getBean(AnthropicModelCaller.class); UserMessage userMessage = new UserMessage( "What's the weather like in San Francisco, in Paris and in Tokyo? Return the temperature in Celsius."); diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/azure/AzureOpenAiAutoConfigurationIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/azure/AzureOpenAiAutoConfigurationIT.java index e70bacbe9..16e6f4e8d 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/azure/AzureOpenAiAutoConfigurationIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/azure/AzureOpenAiAutoConfigurationIT.java @@ -21,7 +21,7 @@ import java.util.stream.Collectors; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; -import org.springframework.ai.azure.openai.AzureOpenAiModelCall; +import org.springframework.ai.azure.openai.AzureOpenAiModelCaller; import org.springframework.ai.chat.messages.AssistantMessage; import reactor.core.publisher.Flux; @@ -77,7 +77,7 @@ public class AzureOpenAiAutoConfigurationIT { @Test public void chatCompletion() { contextRunner.run(context -> { - AzureOpenAiModelCall chatClient = context.getBean(AzureOpenAiModelCall.class); + AzureOpenAiModelCaller chatClient = context.getBean(AzureOpenAiModelCaller.class); ChatResponse response = chatClient.call(new Prompt(List.of(userMessage, systemMessage))); assertThat(response.getResult().getOutput().getContent()).contains("Blackbeard"); }); @@ -87,7 +87,7 @@ public class AzureOpenAiAutoConfigurationIT { public void chatCompletionStreaming() { contextRunner.run(context -> { - AzureOpenAiModelCall chatClient = context.getBean(AzureOpenAiModelCall.class); + AzureOpenAiModelCaller chatClient = context.getBean(AzureOpenAiModelCaller.class); Flux response = chatClient.stream(new Prompt(List.of(userMessage, systemMessage))); @@ -127,17 +127,17 @@ public class AzureOpenAiAutoConfigurationIT { // Disable the chat auto-configuration. contextRunner.withPropertyValues("spring.ai.azure.openai.chat.enabled=false").run(context -> { - assertThat(context.getBeansOfType(AzureOpenAiModelCall.class)).isEmpty(); + assertThat(context.getBeansOfType(AzureOpenAiModelCaller.class)).isEmpty(); }); // The chat auto-configuration is enabled by default. contextRunner.run(context -> { - assertThat(context.getBeansOfType(AzureOpenAiModelCall.class)).isNotEmpty(); + assertThat(context.getBeansOfType(AzureOpenAiModelCaller.class)).isNotEmpty(); }); // Explicitly enable the chat auto-configuration. contextRunner.withPropertyValues("spring.ai.azure.openai.chat.enabled=true").run(context -> { - assertThat(context.getBeansOfType(AzureOpenAiModelCall.class)).isNotEmpty(); + assertThat(context.getBeansOfType(AzureOpenAiModelCaller.class)).isNotEmpty(); }); } diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/azure/tool/FunctionCallWithFunctionBeanIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/azure/tool/FunctionCallWithFunctionBeanIT.java index 548b2633c..6423a2a67 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/azure/tool/FunctionCallWithFunctionBeanIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/azure/tool/FunctionCallWithFunctionBeanIT.java @@ -24,9 +24,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.ai.autoconfigure.azure.openai.AzureOpenAiAutoConfiguration; -import org.springframework.ai.azure.openai.AzureOpenAiModelCall; +import org.springframework.ai.azure.openai.AzureOpenAiModelCaller; import org.springframework.ai.azure.openai.AzureOpenAiChatOptions; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.messages.UserMessage; import org.springframework.ai.chat.prompt.Prompt; @@ -57,7 +57,7 @@ class FunctionCallWithFunctionBeanIT { contextRunner.withPropertyValues("spring.ai.azure.openai.chat.options..deployment-name=gpt-4-0125-preview") .run(context -> { - ModelCall modelCall = context.getBean(AzureOpenAiModelCall.class); + ChatCaller modelCall = context.getBean(AzureOpenAiModelCaller.class); UserMessage userMessage = new UserMessage( "What's the weather like in San Francisco, Paris and in Tokyo? Use Multi-turn function calling."); diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/azure/tool/FunctionCallWithFunctionWrapperIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/azure/tool/FunctionCallWithFunctionWrapperIT.java index 5b3fde935..b1db7199e 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/azure/tool/FunctionCallWithFunctionWrapperIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/azure/tool/FunctionCallWithFunctionWrapperIT.java @@ -23,7 +23,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.ai.autoconfigure.azure.openai.AzureOpenAiAutoConfiguration; -import org.springframework.ai.azure.openai.AzureOpenAiModelCall; +import org.springframework.ai.azure.openai.AzureOpenAiModelCaller; import org.springframework.ai.azure.openai.AzureOpenAiChatOptions; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.messages.UserMessage; @@ -56,7 +56,7 @@ public class FunctionCallWithFunctionWrapperIT { contextRunner.withPropertyValues("spring.ai.azure.openai.chat.options.deployment-name=gpt-4-0125-preview") .run(context -> { - AzureOpenAiModelCall chatClient = context.getBean(AzureOpenAiModelCall.class); + AzureOpenAiModelCaller chatClient = context.getBean(AzureOpenAiModelCaller.class); UserMessage userMessage = new UserMessage( "What's the weather like in San Francisco, Paris and in Tokyo?"); diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/azure/tool/FunctionCallWithPromptFunctionIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/azure/tool/FunctionCallWithPromptFunctionIT.java index 7bca52093..55c9d3a36 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/azure/tool/FunctionCallWithPromptFunctionIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/azure/tool/FunctionCallWithPromptFunctionIT.java @@ -23,7 +23,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.ai.autoconfigure.azure.openai.AzureOpenAiAutoConfiguration; -import org.springframework.ai.azure.openai.AzureOpenAiModelCall; +import org.springframework.ai.azure.openai.AzureOpenAiModelCaller; import org.springframework.ai.azure.openai.AzureOpenAiChatOptions; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.messages.UserMessage; @@ -52,7 +52,7 @@ public class FunctionCallWithPromptFunctionIT { contextRunner.withPropertyValues("spring.ai.azure.openai.chat.options.deployment-name=gpt-4-0125-preview") .run(context -> { - AzureOpenAiModelCall chatClient = context.getBean(AzureOpenAiModelCall.class); + AzureOpenAiModelCaller chatClient = context.getBean(AzureOpenAiModelCaller.class); UserMessage userMessage = new UserMessage( "What's the weather like in San Francisco, in Paris and in Tokyo? Use Multi-turn function calling."); diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/anthropic/BedrockAnthropicChatAutoConfigurationIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/anthropic/BedrockAnthropicChatAutoConfigurationIT.java index 706be8f82..1512502ef 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/anthropic/BedrockAnthropicChatAutoConfigurationIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/anthropic/BedrockAnthropicChatAutoConfigurationIT.java @@ -21,7 +21,7 @@ import java.util.stream.Collectors; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; -import org.springframework.ai.bedrock.anthropic.BedrockAnthropicModelCall; +import org.springframework.ai.bedrock.anthropic.BedrockAnthropicModelCaller; import org.springframework.ai.chat.messages.AssistantMessage; import reactor.core.publisher.Flux; import software.amazon.awssdk.regions.Region; @@ -69,7 +69,7 @@ public class BedrockAnthropicChatAutoConfigurationIT { @Test public void chatCompletion() { contextRunner.run(context -> { - BedrockAnthropicModelCall anthropicChatClient = context.getBean(BedrockAnthropicModelCall.class); + BedrockAnthropicModelCaller anthropicChatClient = context.getBean(BedrockAnthropicModelCaller.class); ChatResponse response = anthropicChatClient.call(new Prompt(List.of(userMessage, systemMessage))); assertThat(response.getResult().getOutput().getContent()).contains("Blackbeard"); }); @@ -79,7 +79,7 @@ public class BedrockAnthropicChatAutoConfigurationIT { public void chatCompletionStreaming() { contextRunner.run(context -> { - BedrockAnthropicModelCall anthropicChatClient = context.getBean(BedrockAnthropicModelCall.class); + BedrockAnthropicModelCaller anthropicChatClient = context.getBean(BedrockAnthropicModelCaller.class); Flux response = anthropicChatClient.stream(new Prompt(List.of(userMessage, systemMessage))); @@ -130,7 +130,7 @@ public class BedrockAnthropicChatAutoConfigurationIT { .withConfiguration(AutoConfigurations.of(BedrockAnthropicChatAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(BedrockAnthropicChatProperties.class)).isEmpty(); - assertThat(context.getBeansOfType(BedrockAnthropicModelCall.class)).isEmpty(); + assertThat(context.getBeansOfType(BedrockAnthropicModelCaller.class)).isEmpty(); }); // Explicitly enable the chat auto-configuration. @@ -138,7 +138,7 @@ public class BedrockAnthropicChatAutoConfigurationIT { .withConfiguration(AutoConfigurations.of(BedrockAnthropicChatAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(BedrockAnthropicChatProperties.class)).isNotEmpty(); - assertThat(context.getBeansOfType(BedrockAnthropicModelCall.class)).isNotEmpty(); + assertThat(context.getBeansOfType(BedrockAnthropicModelCaller.class)).isNotEmpty(); }); // Explicitly disable the chat auto-configuration. @@ -146,7 +146,7 @@ public class BedrockAnthropicChatAutoConfigurationIT { .withConfiguration(AutoConfigurations.of(BedrockAnthropicChatAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(BedrockAnthropicChatProperties.class)).isEmpty(); - assertThat(context.getBeansOfType(BedrockAnthropicModelCall.class)).isEmpty(); + assertThat(context.getBeansOfType(BedrockAnthropicModelCaller.class)).isEmpty(); }); } diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/anthropic3/BedrockAnthropic3ChatAutoConfigurationIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/anthropic3/BedrockAnthropic3ChatAutoConfigurationIT.java index be4194773..1f0a4c3ce 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/anthropic3/BedrockAnthropic3ChatAutoConfigurationIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/anthropic3/BedrockAnthropic3ChatAutoConfigurationIT.java @@ -21,7 +21,7 @@ import java.util.stream.Collectors; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; -import org.springframework.ai.bedrock.anthropic3.BedrockAnthropic3ModelCall; +import org.springframework.ai.bedrock.anthropic3.BedrockAnthropic3ModelCaller; import org.springframework.ai.chat.messages.AssistantMessage; import reactor.core.publisher.Flux; import software.amazon.awssdk.regions.Region; @@ -69,7 +69,7 @@ public class BedrockAnthropic3ChatAutoConfigurationIT { @Test public void chatCompletion() { contextRunner.run(context -> { - BedrockAnthropic3ModelCall anthropicChatClient = context.getBean(BedrockAnthropic3ModelCall.class); + BedrockAnthropic3ModelCaller anthropicChatClient = context.getBean(BedrockAnthropic3ModelCaller.class); ChatResponse response = anthropicChatClient.call(new Prompt(List.of(userMessage, systemMessage))); assertThat(response.getResult().getOutput().getContent()).contains("Blackbeard"); }); @@ -79,7 +79,7 @@ public class BedrockAnthropic3ChatAutoConfigurationIT { public void chatCompletionStreaming() { contextRunner.run(context -> { - BedrockAnthropic3ModelCall anthropicChatClient = context.getBean(BedrockAnthropic3ModelCall.class); + BedrockAnthropic3ModelCaller anthropicChatClient = context.getBean(BedrockAnthropic3ModelCaller.class); Flux response = anthropicChatClient.stream(new Prompt(List.of(userMessage, systemMessage))); @@ -130,7 +130,7 @@ public class BedrockAnthropic3ChatAutoConfigurationIT { .withConfiguration(AutoConfigurations.of(BedrockAnthropic3ChatAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(BedrockAnthropic3ChatProperties.class)).isEmpty(); - assertThat(context.getBeansOfType(BedrockAnthropic3ModelCall.class)).isEmpty(); + assertThat(context.getBeansOfType(BedrockAnthropic3ModelCaller.class)).isEmpty(); }); // Explicitly enable the chat auto-configuration. @@ -138,7 +138,7 @@ public class BedrockAnthropic3ChatAutoConfigurationIT { .withConfiguration(AutoConfigurations.of(BedrockAnthropic3ChatAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(BedrockAnthropic3ChatProperties.class)).isNotEmpty(); - assertThat(context.getBeansOfType(BedrockAnthropic3ModelCall.class)).isNotEmpty(); + assertThat(context.getBeansOfType(BedrockAnthropic3ModelCaller.class)).isNotEmpty(); }); // Explicitly disable the chat auto-configuration. @@ -146,7 +146,7 @@ public class BedrockAnthropic3ChatAutoConfigurationIT { .withConfiguration(AutoConfigurations.of(BedrockAnthropic3ChatAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(BedrockAnthropic3ChatProperties.class)).isEmpty(); - assertThat(context.getBeansOfType(BedrockAnthropic3ModelCall.class)).isEmpty(); + assertThat(context.getBeansOfType(BedrockAnthropic3ModelCaller.class)).isEmpty(); }); } diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/cohere/BedrockCohereChatAutoConfigurationIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/cohere/BedrockCohereChatAutoConfigurationIT.java index 01f53e70b..ffe6f9579 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/cohere/BedrockCohereChatAutoConfigurationIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/cohere/BedrockCohereChatAutoConfigurationIT.java @@ -21,7 +21,7 @@ import java.util.stream.Collectors; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; -import org.springframework.ai.bedrock.cohere.BedrockCohereModelCall; +import org.springframework.ai.bedrock.cohere.BedrockCohereModelCaller; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.messages.AssistantMessage; import reactor.core.publisher.Flux; @@ -72,7 +72,7 @@ public class BedrockCohereChatAutoConfigurationIT { @Test public void chatCompletion() { contextRunner.run(context -> { - BedrockCohereModelCall cohereChatClient = context.getBean(BedrockCohereModelCall.class); + BedrockCohereModelCaller cohereChatClient = context.getBean(BedrockCohereModelCaller.class); ChatResponse response = cohereChatClient.call(new Prompt(List.of(userMessage, systemMessage))); assertThat(response.getResult().getOutput().getContent()).contains("Blackbeard"); }); @@ -82,7 +82,7 @@ public class BedrockCohereChatAutoConfigurationIT { public void chatCompletionStreaming() { contextRunner.run(context -> { - BedrockCohereModelCall cohereChatClient = context.getBean(BedrockCohereModelCall.class); + BedrockCohereModelCaller cohereChatClient = context.getBean(BedrockCohereModelCaller.class); Flux response = cohereChatClient.stream(new Prompt(List.of(userMessage, systemMessage))); @@ -146,7 +146,7 @@ public class BedrockCohereChatAutoConfigurationIT { .withConfiguration(AutoConfigurations.of(BedrockCohereChatAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(BedrockCohereChatProperties.class)).isEmpty(); - assertThat(context.getBeansOfType(BedrockCohereModelCall.class)).isEmpty(); + assertThat(context.getBeansOfType(BedrockCohereModelCaller.class)).isEmpty(); }); // Explicitly enable the chat auto-configuration. @@ -154,7 +154,7 @@ public class BedrockCohereChatAutoConfigurationIT { .withConfiguration(AutoConfigurations.of(BedrockCohereChatAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(BedrockCohereChatProperties.class)).isNotEmpty(); - assertThat(context.getBeansOfType(BedrockCohereModelCall.class)).isNotEmpty(); + assertThat(context.getBeansOfType(BedrockCohereModelCaller.class)).isNotEmpty(); }); // Explicitly disable the chat auto-configuration. @@ -162,7 +162,7 @@ public class BedrockCohereChatAutoConfigurationIT { .withConfiguration(AutoConfigurations.of(BedrockCohereChatAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(BedrockCohereChatProperties.class)).isEmpty(); - assertThat(context.getBeansOfType(BedrockCohereModelCall.class)).isEmpty(); + assertThat(context.getBeansOfType(BedrockCohereModelCaller.class)).isEmpty(); }); } diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/jurassic2/BedrockAi21Jurassic2ChatAutoConfigurationIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/jurassic2/BedrockAi21Jurassic2ChatAutoConfigurationIT.java index 4c9efdd01..283ff04cc 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/jurassic2/BedrockAi21Jurassic2ChatAutoConfigurationIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/jurassic2/BedrockAi21Jurassic2ChatAutoConfigurationIT.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.springframework.ai.autoconfigure.bedrock.BedrockAwsConnectionProperties; import org.springframework.ai.autoconfigure.bedrock.jurrasic2.BedrockAi21Jurassic2ChatAutoConfiguration; import org.springframework.ai.autoconfigure.bedrock.jurrasic2.BedrockAi21Jurassic2ChatProperties; -import org.springframework.ai.bedrock.jurassic2.BedrockAi21Jurassic2ModelCall; +import org.springframework.ai.bedrock.jurassic2.BedrockAi21Jurassic2ModelCaller; import org.springframework.ai.bedrock.jurassic2.api.Ai21Jurassic2ChatBedrockApi; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.messages.Message; @@ -69,8 +69,8 @@ public class BedrockAi21Jurassic2ChatAutoConfigurationIT { @Test public void chatCompletion() { contextRunner.run(context -> { - BedrockAi21Jurassic2ModelCall ai21Jurassic2ChatClient = context - .getBean(BedrockAi21Jurassic2ModelCall.class); + BedrockAi21Jurassic2ModelCaller ai21Jurassic2ChatClient = context + .getBean(BedrockAi21Jurassic2ModelCaller.class); ChatResponse response = ai21Jurassic2ChatClient.call(new Prompt(List.of(userMessage, systemMessage))); assertThat(response.getResult().getOutput().getContent()).contains("Blackbeard"); }); @@ -111,7 +111,7 @@ public class BedrockAi21Jurassic2ChatAutoConfigurationIT { .withConfiguration(AutoConfigurations.of(BedrockAi21Jurassic2ChatAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(BedrockAi21Jurassic2ChatProperties.class)).isEmpty(); - assertThat(context.getBeansOfType(BedrockAi21Jurassic2ModelCall.class)).isEmpty(); + assertThat(context.getBeansOfType(BedrockAi21Jurassic2ModelCaller.class)).isEmpty(); }); // Explicitly enable the chat auto-configuration. @@ -119,7 +119,7 @@ public class BedrockAi21Jurassic2ChatAutoConfigurationIT { .withConfiguration(AutoConfigurations.of(BedrockAi21Jurassic2ChatAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(BedrockAi21Jurassic2ChatProperties.class)).isNotEmpty(); - assertThat(context.getBeansOfType(BedrockAi21Jurassic2ModelCall.class)).isNotEmpty(); + assertThat(context.getBeansOfType(BedrockAi21Jurassic2ModelCaller.class)).isNotEmpty(); }); // Explicitly disable the chat auto-configuration. @@ -127,7 +127,7 @@ public class BedrockAi21Jurassic2ChatAutoConfigurationIT { .withConfiguration(AutoConfigurations.of(BedrockAi21Jurassic2ChatAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(BedrockAi21Jurassic2ChatProperties.class)).isEmpty(); - assertThat(context.getBeansOfType(BedrockAi21Jurassic2ModelCall.class)).isEmpty(); + assertThat(context.getBeansOfType(BedrockAi21Jurassic2ModelCaller.class)).isEmpty(); }); } diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/llama/BedrockLlamaChatAutoConfigurationIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/llama/BedrockLlamaChatAutoConfigurationIT.java index 742eefa27..34cc04e06 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/llama/BedrockLlamaChatAutoConfigurationIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/llama/BedrockLlamaChatAutoConfigurationIT.java @@ -21,7 +21,7 @@ import java.util.stream.Collectors; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; -import org.springframework.ai.bedrock.llama.BedrockLlamaModelCall; +import org.springframework.ai.bedrock.llama.BedrockLlamaModelCaller; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.messages.AssistantMessage; import reactor.core.publisher.Flux; @@ -71,7 +71,7 @@ public class BedrockLlamaChatAutoConfigurationIT { @Test public void chatCompletion() { contextRunner.run(context -> { - BedrockLlamaModelCall llamaChatClient = context.getBean(BedrockLlamaModelCall.class); + BedrockLlamaModelCaller llamaChatClient = context.getBean(BedrockLlamaModelCaller.class); ChatResponse response = llamaChatClient.call(new Prompt(List.of(userMessage, systemMessage))); assertThat(response.getResult().getOutput().getContent()).contains("Blackbeard"); }); @@ -81,7 +81,7 @@ public class BedrockLlamaChatAutoConfigurationIT { public void chatCompletionStreaming() { contextRunner.run(context -> { - BedrockLlamaModelCall llamaChatClient = context.getBean(BedrockLlamaModelCall.class); + BedrockLlamaModelCaller llamaChatClient = context.getBean(BedrockLlamaModelCaller.class); Flux response = llamaChatClient.stream(new Prompt(List.of(userMessage, systemMessage))); @@ -133,7 +133,7 @@ public class BedrockLlamaChatAutoConfigurationIT { new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(BedrockLlamaChatAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(BedrockLlamaChatProperties.class)).isEmpty(); - assertThat(context.getBeansOfType(BedrockLlamaModelCall.class)).isEmpty(); + assertThat(context.getBeansOfType(BedrockLlamaModelCaller.class)).isEmpty(); }); // Explicitly enable the chat auto-configuration. @@ -141,7 +141,7 @@ public class BedrockLlamaChatAutoConfigurationIT { .withConfiguration(AutoConfigurations.of(BedrockLlamaChatAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(BedrockLlamaChatProperties.class)).isNotEmpty(); - assertThat(context.getBeansOfType(BedrockLlamaModelCall.class)).isNotEmpty(); + assertThat(context.getBeansOfType(BedrockLlamaModelCaller.class)).isNotEmpty(); }); // Explicitly disable the chat auto-configuration. @@ -149,7 +149,7 @@ public class BedrockLlamaChatAutoConfigurationIT { .withConfiguration(AutoConfigurations.of(BedrockLlamaChatAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(BedrockLlamaChatProperties.class)).isEmpty(); - assertThat(context.getBeansOfType(BedrockLlamaModelCall.class)).isEmpty(); + assertThat(context.getBeansOfType(BedrockLlamaModelCaller.class)).isEmpty(); }); } diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/titan/BedrockTitanChatAutoConfigurationIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/titan/BedrockTitanChatAutoConfigurationIT.java index ee5ed90f8..7c7d2933e 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/titan/BedrockTitanChatAutoConfigurationIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/bedrock/titan/BedrockTitanChatAutoConfigurationIT.java @@ -27,7 +27,7 @@ import reactor.core.publisher.Flux; import software.amazon.awssdk.regions.Region; import org.springframework.ai.autoconfigure.bedrock.BedrockAwsConnectionProperties; -import org.springframework.ai.bedrock.titan.BedrockTitanModelCall; +import org.springframework.ai.bedrock.titan.BedrockTitanModelCaller; import org.springframework.ai.bedrock.titan.api.TitanChatBedrockApi.TitanChatModel; import org.springframework.ai.chat.Generation; import org.springframework.ai.chat.prompt.Prompt; @@ -70,7 +70,7 @@ public class BedrockTitanChatAutoConfigurationIT { @Test public void chatCompletion() { contextRunner.run(context -> { - BedrockTitanModelCall chatClient = context.getBean(BedrockTitanModelCall.class); + BedrockTitanModelCaller chatClient = context.getBean(BedrockTitanModelCaller.class); ChatResponse response = chatClient.call(new Prompt(List.of(userMessage, systemMessage))); assertThat(response.getResult().getOutput().getContent()).contains("Blackbeard"); }); @@ -80,7 +80,7 @@ public class BedrockTitanChatAutoConfigurationIT { public void chatCompletionStreaming() { contextRunner.run(context -> { - BedrockTitanModelCall chatClient = context.getBean(BedrockTitanModelCall.class); + BedrockTitanModelCaller chatClient = context.getBean(BedrockTitanModelCaller.class); Flux response = chatClient.stream(new Prompt(List.of(userMessage, systemMessage))); @@ -137,7 +137,7 @@ public class BedrockTitanChatAutoConfigurationIT { new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(BedrockTitanChatAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(BedrockTitanChatProperties.class)).isEmpty(); - assertThat(context.getBeansOfType(BedrockTitanModelCall.class)).isEmpty(); + assertThat(context.getBeansOfType(BedrockTitanModelCaller.class)).isEmpty(); }); // Explicitly enable the chat auto-configuration. @@ -145,7 +145,7 @@ public class BedrockTitanChatAutoConfigurationIT { .withConfiguration(AutoConfigurations.of(BedrockTitanChatAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(BedrockTitanChatProperties.class)).isNotEmpty(); - assertThat(context.getBeansOfType(BedrockTitanModelCall.class)).isNotEmpty(); + assertThat(context.getBeansOfType(BedrockTitanModelCaller.class)).isNotEmpty(); }); // Explicitly disable the chat auto-configuration. @@ -153,7 +153,7 @@ public class BedrockTitanChatAutoConfigurationIT { .withConfiguration(AutoConfigurations.of(BedrockTitanChatAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(BedrockTitanChatProperties.class)).isEmpty(); - assertThat(context.getBeansOfType(BedrockTitanModelCall.class)).isEmpty(); + assertThat(context.getBeansOfType(BedrockTitanModelCaller.class)).isEmpty(); }); } diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/mistralai/MistralAiAutoConfigurationIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/mistralai/MistralAiAutoConfigurationIT.java index 297db3737..e90531607 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/mistralai/MistralAiAutoConfigurationIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/mistralai/MistralAiAutoConfigurationIT.java @@ -22,7 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; -import org.springframework.ai.mistralai.MistralAiModelCall; +import org.springframework.ai.mistralai.MistralAiModelCaller; import reactor.core.publisher.Flux; import org.springframework.ai.autoconfigure.retry.SpringAiRetryAutoConfiguration; @@ -54,7 +54,7 @@ public class MistralAiAutoConfigurationIT { @Test void generate() { contextRunner.run(context -> { - MistralAiModelCall client = context.getBean(MistralAiModelCall.class); + MistralAiModelCaller client = context.getBean(MistralAiModelCaller.class); String response = client.call("Hello"); assertThat(response).isNotEmpty(); logger.info("Response: " + response); @@ -64,7 +64,7 @@ public class MistralAiAutoConfigurationIT { @Test void generateStreaming() { contextRunner.run(context -> { - MistralAiModelCall client = context.getBean(MistralAiModelCall.class); + MistralAiModelCaller client = context.getBean(MistralAiModelCaller.class); Flux responseFlux = client.stream(new Prompt(new UserMessage("Hello"))); String response = responseFlux.collectList().block().stream().map(chatResponse -> { return chatResponse.getResults().get(0).getOutput().getContent(); diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/mistralai/tool/PaymentStatusBeanIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/mistralai/tool/PaymentStatusBeanIT.java index 4859b3bd9..d4e03a507 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/mistralai/tool/PaymentStatusBeanIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/mistralai/tool/PaymentStatusBeanIT.java @@ -30,7 +30,7 @@ import org.springframework.ai.autoconfigure.retry.SpringAiRetryAutoConfiguration import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.messages.UserMessage; import org.springframework.ai.chat.prompt.Prompt; -import org.springframework.ai.mistralai.MistralAiModelCall; +import org.springframework.ai.mistralai.MistralAiModelCaller; import org.springframework.ai.mistralai.MistralAiChatOptions; import org.springframework.ai.mistralai.api.MistralAiApi; import org.springframework.boot.autoconfigure.AutoConfigurations; @@ -60,7 +60,7 @@ class PaymentStatusBeanIT { .withPropertyValues("spring.ai.mistralai.chat.options.model=" + MistralAiApi.ChatModel.LARGE.getValue()) .run(context -> { - MistralAiModelCall chatClient = context.getBean(MistralAiModelCall.class); + MistralAiModelCaller chatClient = context.getBean(MistralAiModelCaller.class); ChatResponse response = chatClient .call(new Prompt(List.of(new UserMessage("What's the status of my transaction with id T1001?")), diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/mistralai/tool/PaymentStatusBeanOpenAiIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/mistralai/tool/PaymentStatusBeanOpenAiIT.java index dd612bec8..1fe6530d1 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/mistralai/tool/PaymentStatusBeanOpenAiIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/mistralai/tool/PaymentStatusBeanOpenAiIT.java @@ -31,7 +31,7 @@ import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.messages.UserMessage; import org.springframework.ai.chat.prompt.Prompt; import org.springframework.ai.mistralai.api.MistralAiApi; -import org.springframework.ai.openai.OpenAiModelCall; +import org.springframework.ai.openai.OpenAiModelCaller; import org.springframework.ai.openai.OpenAiChatOptions; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.web.client.RestClientAutoConfiguration; @@ -43,7 +43,7 @@ import org.springframework.context.annotation.Description; import static org.assertj.core.api.Assertions.assertThat; /** - * Same test as {@link PaymentStatusBeanIT.java} but using {@link OpenAiModelCall} for + * Same test as {@link PaymentStatusBeanIT.java} but using {@link OpenAiModelCaller} for * Mistral AI Function Calling implementation. * * @author Christian Tzolov @@ -67,7 +67,7 @@ class PaymentStatusBeanOpenAiIT { .withPropertyValues("spring.ai.openai.chat.options.model=" + MistralAiApi.ChatModel.SMALL.getValue()) .run(context -> { - OpenAiModelCall chatClient = context.getBean(OpenAiModelCall.class); + OpenAiModelCaller chatClient = context.getBean(OpenAiModelCaller.class); ChatResponse response = chatClient .call(new Prompt(List.of(new UserMessage("What's the status of my transaction with id T1001?")), diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/mistralai/tool/PaymentStatusPromptIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/mistralai/tool/PaymentStatusPromptIT.java index f8e64ae0a..394718b32 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/mistralai/tool/PaymentStatusPromptIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/mistralai/tool/PaymentStatusPromptIT.java @@ -30,7 +30,7 @@ import org.springframework.ai.autoconfigure.retry.SpringAiRetryAutoConfiguration import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.messages.UserMessage; import org.springframework.ai.chat.prompt.Prompt; -import org.springframework.ai.mistralai.MistralAiModelCall; +import org.springframework.ai.mistralai.MistralAiModelCaller; import org.springframework.ai.mistralai.MistralAiChatOptions; import org.springframework.ai.mistralai.api.MistralAiApi; import org.springframework.ai.model.function.FunctionCallbackWrapper; @@ -71,7 +71,7 @@ public class PaymentStatusPromptIT { .withPropertyValues("spring.ai.mistralai.chat.options.model=" + MistralAiApi.ChatModel.SMALL.getValue()) .run(context -> { - MistralAiModelCall chatClient = context.getBean(MistralAiModelCall.class); + MistralAiModelCaller chatClient = context.getBean(MistralAiModelCaller.class); UserMessage userMessage = new UserMessage("What's the status of my transaction with id T1001?"); diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/mistralai/tool/WeatherServicePromptIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/mistralai/tool/WeatherServicePromptIT.java index 1eee53117..89132c0de 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/mistralai/tool/WeatherServicePromptIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/mistralai/tool/WeatherServicePromptIT.java @@ -33,7 +33,7 @@ import org.springframework.ai.autoconfigure.retry.SpringAiRetryAutoConfiguration import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.messages.UserMessage; import org.springframework.ai.chat.prompt.Prompt; -import org.springframework.ai.mistralai.MistralAiModelCall; +import org.springframework.ai.mistralai.MistralAiModelCaller; import org.springframework.ai.mistralai.MistralAiChatOptions; import org.springframework.ai.mistralai.api.MistralAiApi; import org.springframework.ai.mistralai.api.MistralAiApi.ChatCompletionRequest.ToolChoice; @@ -64,7 +64,7 @@ public class WeatherServicePromptIT { .withPropertyValues("spring.ai.mistralai.chat.options.model=" + MistralAiApi.ChatModel.LARGE.getValue()) .run(context -> { - MistralAiModelCall chatClient = context.getBean(MistralAiModelCall.class); + MistralAiModelCaller chatClient = context.getBean(MistralAiModelCaller.class); UserMessage userMessage = new UserMessage("What's the weather like in Paris?"); // UserMessage userMessage = new UserMessage("What's the weather like in diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/ollama/OllamaChatAutoConfigurationIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/ollama/OllamaChatAutoConfigurationIT.java index a2d9f0f6a..5a314c8ee 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/ollama/OllamaChatAutoConfigurationIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/ollama/OllamaChatAutoConfigurationIT.java @@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.Generation; import org.springframework.ai.chat.messages.AssistantMessage; -import org.springframework.ai.ollama.OllamaModelCall; +import org.springframework.ai.ollama.OllamaModelCaller; import org.springframework.ai.chat.prompt.Prompt; import org.springframework.ai.chat.prompt.SystemPromptTemplate; import org.springframework.ai.chat.messages.Message; @@ -104,7 +104,7 @@ public class OllamaChatAutoConfigurationIT { @Test public void chatCompletion() { contextRunner.run(context -> { - OllamaModelCall chatClient = context.getBean(OllamaModelCall.class); + OllamaModelCaller chatClient = context.getBean(OllamaModelCaller.class); ChatResponse response = chatClient.call(new Prompt(List.of(userMessage, systemMessage))); assertThat(response.getResult().getOutput().getContent()).contains("Blackbeard"); }); @@ -114,7 +114,7 @@ public class OllamaChatAutoConfigurationIT { public void chatCompletionStreaming() { contextRunner.run(context -> { - OllamaModelCall chatClient = context.getBean(OllamaModelCall.class); + OllamaModelCaller chatClient = context.getBean(OllamaModelCaller.class); Flux response = chatClient.stream(new Prompt(List.of(userMessage, systemMessage))); @@ -136,17 +136,17 @@ public class OllamaChatAutoConfigurationIT { void chatActivation() { contextRunner.withPropertyValues("spring.ai.ollama.chat.enabled=false").run(context -> { assertThat(context.getBeansOfType(OllamaChatProperties.class)).isNotEmpty(); - assertThat(context.getBeansOfType(OllamaModelCall.class)).isEmpty(); + assertThat(context.getBeansOfType(OllamaModelCaller.class)).isEmpty(); }); contextRunner.run(context -> { assertThat(context.getBeansOfType(OllamaChatProperties.class)).isNotEmpty(); - assertThat(context.getBeansOfType(OllamaModelCall.class)).isNotEmpty(); + assertThat(context.getBeansOfType(OllamaModelCaller.class)).isNotEmpty(); }); contextRunner.withPropertyValues("spring.ai.ollama.chat.enabled=true").run(context -> { assertThat(context.getBeansOfType(OllamaChatProperties.class)).isNotEmpty(); - assertThat(context.getBeansOfType(OllamaModelCall.class)).isNotEmpty(); + assertThat(context.getBeansOfType(OllamaModelCaller.class)).isNotEmpty(); }); } diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/openai/OpenAiAutoConfigurationIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/openai/OpenAiAutoConfigurationIT.java index 8a3c0e561..a205a4114 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/openai/OpenAiAutoConfigurationIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/openai/OpenAiAutoConfigurationIT.java @@ -35,7 +35,7 @@ import reactor.core.publisher.Flux; import org.springframework.ai.autoconfigure.retry.SpringAiRetryAutoConfiguration; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.embedding.EmbeddingResponse; -import org.springframework.ai.openai.OpenAiModelCall; +import org.springframework.ai.openai.OpenAiModelCaller; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.web.client.RestClientAutoConfiguration; import org.springframework.boot.test.context.runner.ApplicationContextRunner; @@ -55,7 +55,7 @@ public class OpenAiAutoConfigurationIT { @Test void generate() { contextRunner.run(context -> { - OpenAiModelCall client = context.getBean(OpenAiModelCall.class); + OpenAiModelCaller client = context.getBean(OpenAiModelCaller.class); String response = client.call("Hello"); assertThat(response).isNotEmpty(); logger.info("Response: " + response); @@ -102,7 +102,7 @@ public class OpenAiAutoConfigurationIT { @Test void generateStreaming() { contextRunner.run(context -> { - OpenAiModelCall client = context.getBean(OpenAiModelCall.class); + OpenAiModelCaller client = context.getBean(OpenAiModelCaller.class); Flux responseFlux = client.stream(new Prompt(new UserMessage("Hello"))); String response = responseFlux.collectList().block().stream().map(chatResponse -> { return chatResponse.getResults().get(0).getOutput().getContent(); diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/openai/OpenAiPropertiesTests.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/openai/OpenAiPropertiesTests.java index ba1d32a96..66108a5b1 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/openai/OpenAiPropertiesTests.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/openai/OpenAiPropertiesTests.java @@ -21,7 +21,7 @@ import org.skyscreamer.jsonassert.JSONCompareMode; import org.springframework.ai.autoconfigure.retry.SpringAiRetryAutoConfiguration; import org.springframework.ai.model.ModelOptionsUtils; -import org.springframework.ai.openai.OpenAiModelCall; +import org.springframework.ai.openai.OpenAiModelCaller; import org.springframework.ai.openai.OpenAiEmbeddingClient; import org.springframework.ai.openai.OpenAiImageClient; import org.springframework.ai.openai.api.OpenAiApi.ChatCompletionRequest.ResponseFormat; @@ -593,7 +593,7 @@ public class OpenAiPropertiesTests { RestClientAutoConfiguration.class, OpenAiAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(OpenAiChatProperties.class)).isNotEmpty(); - assertThat(context.getBeansOfType(OpenAiModelCall.class)).isEmpty(); + assertThat(context.getBeansOfType(OpenAiModelCaller.class)).isEmpty(); }); new ApplicationContextRunner() @@ -602,7 +602,7 @@ public class OpenAiPropertiesTests { RestClientAutoConfiguration.class, OpenAiAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(OpenAiChatProperties.class)).isNotEmpty(); - assertThat(context.getBeansOfType(OpenAiModelCall.class)).isNotEmpty(); + assertThat(context.getBeansOfType(OpenAiModelCaller.class)).isNotEmpty(); }); new ApplicationContextRunner() @@ -612,7 +612,7 @@ public class OpenAiPropertiesTests { RestClientAutoConfiguration.class, OpenAiAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(OpenAiChatProperties.class)).isNotEmpty(); - assertThat(context.getBeansOfType(OpenAiModelCall.class)).isNotEmpty(); + assertThat(context.getBeansOfType(OpenAiModelCaller.class)).isNotEmpty(); }); } diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/openai/tool/FunctionCallbackInPromptIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/openai/tool/FunctionCallbackInPromptIT.java index eb41139a0..caf1104f2 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/openai/tool/FunctionCallbackInPromptIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/openai/tool/FunctionCallbackInPromptIT.java @@ -32,7 +32,7 @@ import org.springframework.ai.chat.messages.AssistantMessage; import org.springframework.ai.chat.messages.UserMessage; import org.springframework.ai.chat.prompt.Prompt; import org.springframework.ai.model.function.FunctionCallbackWrapper; -import org.springframework.ai.openai.OpenAiModelCall; +import org.springframework.ai.openai.OpenAiModelCaller; import org.springframework.ai.openai.OpenAiChatOptions; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.web.client.RestClientAutoConfiguration; @@ -54,7 +54,7 @@ public class FunctionCallbackInPromptIT { void functionCallTest() { contextRunner.withPropertyValues("spring.ai.openai.chat.options.model=gpt-4-turbo-preview").run(context -> { - OpenAiModelCall chatClient = context.getBean(OpenAiModelCall.class); + OpenAiModelCaller chatClient = context.getBean(OpenAiModelCaller.class); UserMessage userMessage = new UserMessage("What's the weather like in San Francisco, Tokyo, and Paris?"); @@ -79,7 +79,7 @@ public class FunctionCallbackInPromptIT { contextRunner.withPropertyValues("spring.ai.openai.chat.options.model=gpt-4-turbo-preview").run(context -> { - OpenAiModelCall chatClient = context.getBean(OpenAiModelCall.class); + OpenAiModelCaller chatClient = context.getBean(OpenAiModelCaller.class); UserMessage userMessage = new UserMessage("What's the weather like in San Francisco, Tokyo, and Paris?"); diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/openai/tool/FunctionCallbackWithPlainFunctionBeanIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/openai/tool/FunctionCallbackWithPlainFunctionBeanIT.java index 6a637ce4a..2af30a86c 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/openai/tool/FunctionCallbackWithPlainFunctionBeanIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/openai/tool/FunctionCallbackWithPlainFunctionBeanIT.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.ai.openai.OpenAiModelCall; +import org.springframework.ai.openai.OpenAiModelCaller; import reactor.core.publisher.Flux; import org.springframework.ai.autoconfigure.openai.OpenAiAutoConfiguration; @@ -60,7 +60,7 @@ class FunctionCallbackWithPlainFunctionBeanIT { void functionCallTest() { contextRunner.withPropertyValues("spring.ai.openai.chat.options.model=gpt-4-turbo-preview").run(context -> { - OpenAiModelCall chatClient = context.getBean(OpenAiModelCall.class); + OpenAiModelCaller chatClient = context.getBean(OpenAiModelCaller.class); // Test weatherFunction UserMessage userMessage = new UserMessage("What's the weather like in San Francisco, Tokyo, and Paris?"); @@ -87,7 +87,7 @@ class FunctionCallbackWithPlainFunctionBeanIT { void functionCallWithPortableFunctionCallingOptions() { contextRunner.withPropertyValues("spring.ai.openai.chat.options.model=gpt-4-turbo-preview").run(context -> { - OpenAiModelCall chatClient = context.getBean(OpenAiModelCall.class); + OpenAiModelCaller chatClient = context.getBean(OpenAiModelCaller.class); // Test weatherFunction UserMessage userMessage = new UserMessage("What's the weather like in San Francisco, Tokyo, and Paris?"); @@ -106,7 +106,7 @@ class FunctionCallbackWithPlainFunctionBeanIT { void streamFunctionCallTest() { contextRunner.withPropertyValues("spring.ai.openai.chat.options.model=gpt-4-turbo-preview").run(context -> { - OpenAiModelCall chatClient = context.getBean(OpenAiModelCall.class); + OpenAiModelCaller chatClient = context.getBean(OpenAiModelCaller.class); // Test weatherFunction UserMessage userMessage = new UserMessage("What's the weather like in San Francisco, Tokyo, and Paris?"); diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/openai/tool/FunctionCallbackWrapperIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/openai/tool/FunctionCallbackWrapperIT.java index 8e200194a..00e414061 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/openai/tool/FunctionCallbackWrapperIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/openai/tool/FunctionCallbackWrapperIT.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.ai.openai.OpenAiModelCall; +import org.springframework.ai.openai.OpenAiModelCaller; import reactor.core.publisher.Flux; import org.springframework.ai.autoconfigure.openai.OpenAiAutoConfiguration; @@ -58,7 +58,7 @@ public class FunctionCallbackWrapperIT { void functionCallTest() { contextRunner.withPropertyValues("spring.ai.openai.chat.options.model=gpt-4-turbo-preview").run(context -> { - OpenAiModelCall chatClient = context.getBean(OpenAiModelCall.class); + OpenAiModelCaller chatClient = context.getBean(OpenAiModelCaller.class); UserMessage userMessage = new UserMessage("What's the weather like in San Francisco, Tokyo, and Paris?"); @@ -76,7 +76,7 @@ public class FunctionCallbackWrapperIT { void streamFunctionCallTest() { contextRunner.withPropertyValues("spring.ai.openai.chat.options.model=gpt-4-turbo-preview").run(context -> { - OpenAiModelCall chatClient = context.getBean(OpenAiModelCall.class); + OpenAiModelCaller chatClient = context.getBean(OpenAiModelCaller.class); UserMessage userMessage = new UserMessage("What's the weather like in San Francisco, Tokyo, and Paris?"); diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/vertexai/gemini/VertexAiGeminiAutoConfigurationIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/vertexai/gemini/VertexAiGeminiAutoConfigurationIT.java index e956e5241..80905a1b9 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/vertexai/gemini/VertexAiGeminiAutoConfigurationIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/vertexai/gemini/VertexAiGeminiAutoConfigurationIT.java @@ -21,7 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; -import org.springframework.ai.vertexai.gemini.VertexAiGeminiModelCall; +import org.springframework.ai.vertexai.gemini.VertexAiGeminiModelCaller; import reactor.core.publisher.Flux; import org.springframework.ai.chat.ChatResponse; @@ -46,7 +46,7 @@ public class VertexAiGeminiAutoConfigurationIT { @Test void generate() { contextRunner.run(context -> { - VertexAiGeminiModelCall client = context.getBean(VertexAiGeminiModelCall.class); + VertexAiGeminiModelCaller client = context.getBean(VertexAiGeminiModelCaller.class); String response = client.call("Hello"); assertThat(response).isNotEmpty(); logger.info("Response: " + response); @@ -56,7 +56,7 @@ public class VertexAiGeminiAutoConfigurationIT { @Test void generateStreaming() { contextRunner.run(context -> { - VertexAiGeminiModelCall client = context.getBean(VertexAiGeminiModelCall.class); + VertexAiGeminiModelCaller client = context.getBean(VertexAiGeminiModelCaller.class); Flux responseFlux = client.stream(new Prompt(new UserMessage("Hello"))); String response = responseFlux.collectList().block().stream().map(chatResponse -> { return chatResponse.getResults().get(0).getOutput().getContent(); diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/vertexai/gemini/tool/FunctionCallWithFunctionBeanIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/vertexai/gemini/tool/FunctionCallWithFunctionBeanIT.java index 9b2d78479..d08f5f862 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/vertexai/gemini/tool/FunctionCallWithFunctionBeanIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/vertexai/gemini/tool/FunctionCallWithFunctionBeanIT.java @@ -28,7 +28,7 @@ import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.messages.SystemMessage; import org.springframework.ai.chat.messages.UserMessage; import org.springframework.ai.chat.prompt.Prompt; -import org.springframework.ai.vertexai.gemini.VertexAiGeminiModelCall; +import org.springframework.ai.vertexai.gemini.VertexAiGeminiModelCaller; import org.springframework.ai.vertexai.gemini.VertexAiGeminiChatOptions; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.ApplicationContextRunner; @@ -56,11 +56,11 @@ class FunctionCallWithFunctionBeanIT { contextRunner.withPropertyValues("spring.ai.vertex.ai.gemini.chat.options.model=" // + VertexAiGeminiModelCall.ChatModel.GEMINI_PRO.getValue()) - + VertexAiGeminiModelCall.ChatModel.GEMINI_PRO_1_5_PRO.getValue()) + + VertexAiGeminiModelCaller.ChatModel.GEMINI_PRO_1_5_PRO.getValue()) // + VertexAiGeminiModelCall.ChatModel.GEMINI_PRO_1_5_FLASH.getValue()) .run(context -> { - VertexAiGeminiModelCall chatClient = context.getBean(VertexAiGeminiModelCall.class); + VertexAiGeminiModelCaller chatClient = context.getBean(VertexAiGeminiModelCaller.class); var systemMessage = new SystemMessage(""" Use Multi-turn function calling. diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/vertexai/gemini/tool/FunctionCallWithFunctionWrapperIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/vertexai/gemini/tool/FunctionCallWithFunctionWrapperIT.java index 11c671737..d52beb6bc 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/vertexai/gemini/tool/FunctionCallWithFunctionWrapperIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/vertexai/gemini/tool/FunctionCallWithFunctionWrapperIT.java @@ -30,7 +30,7 @@ import org.springframework.ai.chat.prompt.Prompt; import org.springframework.ai.model.function.FunctionCallback; import org.springframework.ai.model.function.FunctionCallbackWrapper; import org.springframework.ai.model.function.FunctionCallbackWrapper.Builder.SchemaType; -import org.springframework.ai.vertexai.gemini.VertexAiGeminiModelCall; +import org.springframework.ai.vertexai.gemini.VertexAiGeminiModelCaller; import org.springframework.ai.vertexai.gemini.VertexAiGeminiChatOptions; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.ApplicationContextRunner; @@ -55,10 +55,10 @@ public class FunctionCallWithFunctionWrapperIT { void functionCallTest() { contextRunner .withPropertyValues("spring.ai.vertex.ai.gemini.chat.options.model=" - + VertexAiGeminiModelCall.ChatModel.GEMINI_PRO.getValue()) + + VertexAiGeminiModelCaller.ChatModel.GEMINI_PRO.getValue()) .run(context -> { - VertexAiGeminiModelCall chatClient = context.getBean(VertexAiGeminiModelCall.class); + VertexAiGeminiModelCaller chatClient = context.getBean(VertexAiGeminiModelCaller.class); var systemMessage = new SystemMessage(""" Use Multi-turn function calling. diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/vertexai/gemini/tool/FunctionCallWithPromptFunctionIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/vertexai/gemini/tool/FunctionCallWithPromptFunctionIT.java index d99d79449..6d0fa4f63 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/vertexai/gemini/tool/FunctionCallWithPromptFunctionIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/vertexai/gemini/tool/FunctionCallWithPromptFunctionIT.java @@ -29,7 +29,7 @@ import org.springframework.ai.chat.messages.UserMessage; import org.springframework.ai.chat.prompt.Prompt; import org.springframework.ai.model.function.FunctionCallbackWrapper; import org.springframework.ai.model.function.FunctionCallbackWrapper.Builder.SchemaType; -import org.springframework.ai.vertexai.gemini.VertexAiGeminiModelCall; +import org.springframework.ai.vertexai.gemini.VertexAiGeminiModelCaller; import org.springframework.ai.vertexai.gemini.VertexAiGeminiChatOptions; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.ApplicationContextRunner; @@ -51,10 +51,10 @@ public class FunctionCallWithPromptFunctionIT { void functionCallTest() { contextRunner .withPropertyValues("spring.ai.vertex.ai.gemini.chat.options.model=" - + VertexAiGeminiModelCall.ChatModel.GEMINI_PRO.getValue()) + + VertexAiGeminiModelCaller.ChatModel.GEMINI_PRO.getValue()) .run(context -> { - VertexAiGeminiModelCall chatClient = context.getBean(VertexAiGeminiModelCall.class); + VertexAiGeminiModelCaller chatClient = context.getBean(VertexAiGeminiModelCaller.class); var systemMessage = new SystemMessage(""" Use Multi-turn function calling. diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/vertexai/palm2/VertexAiPaLm2AutoConfigurationIT.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/vertexai/palm2/VertexAiPaLm2AutoConfigurationIT.java index b310abe64..67147e72e 100644 --- a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/vertexai/palm2/VertexAiPaLm2AutoConfigurationIT.java +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/vertexai/palm2/VertexAiPaLm2AutoConfigurationIT.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.springframework.ai.embedding.EmbeddingResponse; -import org.springframework.ai.vertexai.palm2.VertexAiPaLm2ModelCall; +import org.springframework.ai.vertexai.palm2.VertexAiPaLm2ModelCaller; import org.springframework.ai.vertexai.palm2.VertexAiPaLm2EmbeddingClient; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.web.client.RestClientAutoConfiguration; @@ -48,7 +48,7 @@ public class VertexAiPaLm2AutoConfigurationIT { @Test void generate() { contextRunner.run(context -> { - VertexAiPaLm2ModelCall client = context.getBean(VertexAiPaLm2ModelCall.class); + VertexAiPaLm2ModelCaller client = context.getBean(VertexAiPaLm2ModelCaller.class); String response = client.call("Hello"); @@ -102,19 +102,19 @@ public class VertexAiPaLm2AutoConfigurationIT { // Disable the chat auto-configuration. contextRunner.withPropertyValues("spring.ai.vertex.ai.chat.enabled=false").run(context -> { assertThat(context.getBeansOfType(VertexAiPlam2ChatProperties.class)).isNotEmpty(); - assertThat(context.getBeansOfType(VertexAiPaLm2ModelCall.class)).isEmpty(); + assertThat(context.getBeansOfType(VertexAiPaLm2ModelCaller.class)).isEmpty(); }); // The chat auto-configuration is enabled by default. contextRunner.run(context -> { assertThat(context.getBeansOfType(VertexAiPlam2ChatProperties.class)).isNotEmpty(); - assertThat(context.getBeansOfType(VertexAiPaLm2ModelCall.class)).isNotEmpty(); + assertThat(context.getBeansOfType(VertexAiPaLm2ModelCaller.class)).isNotEmpty(); }); // Explicitly enable the chat auto-configuration. contextRunner.withPropertyValues("spring.ai.vertex.ai.chat.enabled=true").run(context -> { assertThat(context.getBeansOfType(VertexAiPlam2ChatProperties.class)).isNotEmpty(); - assertThat(context.getBeansOfType(VertexAiPaLm2ModelCall.class)).isNotEmpty(); + assertThat(context.getBeansOfType(VertexAiPaLm2ModelCaller.class)).isNotEmpty(); }); } diff --git a/spring-ai-test/src/main/java/org/springframework/ai/evaluation/BasicEvaluationTest.java b/spring-ai-test/src/main/java/org/springframework/ai/evaluation/BasicEvaluationTest.java index 5153bb1ea..3f11718be 100644 --- a/spring-ai-test/src/main/java/org/springframework/ai/evaluation/BasicEvaluationTest.java +++ b/spring-ai-test/src/main/java/org/springframework/ai/evaluation/BasicEvaluationTest.java @@ -17,7 +17,7 @@ package org.springframework.ai.evaluation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.chat.ChatResponse; import org.springframework.ai.chat.prompt.Prompt; import org.springframework.ai.chat.prompt.PromptTemplate; @@ -38,7 +38,7 @@ public class BasicEvaluationTest { private static final Logger logger = LoggerFactory.getLogger(BasicEvaluationTest.class); @Autowired - protected ModelCall openAiModelCall; + protected ChatCaller openAiModelCall; @Value("classpath:/prompts/spring/test/evaluation/qa-evaluator-accurate-answer.st") protected Resource qaEvaluatorAccurateAnswerResource; diff --git a/vector-stores/spring-ai-hanadb-store/src/test/java/org/springframework/ai/vectorstore/CricketWorldCupHanaController.java b/vector-stores/spring-ai-hanadb-store/src/test/java/org/springframework/ai/vectorstore/CricketWorldCupHanaController.java index 7e58a29bf..5340bb7df 100644 --- a/vector-stores/spring-ai-hanadb-store/src/test/java/org/springframework/ai/vectorstore/CricketWorldCupHanaController.java +++ b/vector-stores/spring-ai-hanadb-store/src/test/java/org/springframework/ai/vectorstore/CricketWorldCupHanaController.java @@ -17,7 +17,7 @@ package org.springframework.ai.vectorstore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.ai.chat.ModelCall; +import org.springframework.ai.chat.ChatCaller; import org.springframework.ai.chat.messages.UserMessage; import org.springframework.ai.chat.prompt.Prompt; import org.springframework.ai.chat.prompt.SystemPromptTemplate; @@ -51,10 +51,10 @@ public class CricketWorldCupHanaController { private final VectorStore hanaCloudVectorStore; - private final ModelCall modelCall; + private final ChatCaller modelCall; @Autowired - public CricketWorldCupHanaController(ModelCall modelCall, VectorStore hanaCloudVectorStore) { + public CricketWorldCupHanaController(ChatCaller modelCall, VectorStore hanaCloudVectorStore) { this.modelCall = modelCall; this.hanaCloudVectorStore = hanaCloudVectorStore; }