From c22b2f05ddcbd3fd7b0268170c05fc8124970c85 Mon Sep 17 00:00:00 2001 From: Mark Pollack Date: Sun, 26 May 2024 14:26:08 -0400 Subject: [PATCH] Add support for use of AZURE_OPENAI_DEPLOYMENT_NAME in IT tests * remove from README.md info of changed default for initialize-schema --- README.md | 21 ------------------- .../azure/tool/DeploymentNameUtil.java | 17 +++++++++++++++ .../tool/FunctionCallWithFunctionBeanIT.java | 4 +++- .../FunctionCallWithFunctionWrapperIT.java | 3 ++- .../FunctionCallWithPromptFunctionIT.java | 3 ++- 5 files changed, 24 insertions(+), 24 deletions(-) create mode 100644 spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/azure/tool/DeploymentNameUtil.java diff --git a/README.md b/README.md index 18a8f487b..e3e9c3378 100644 --- a/README.md +++ b/README.md @@ -12,27 +12,6 @@ For further information go to our [Spring AI reference documentation](https://do On our march to release 1.0.0 M1 we have made several breaking changes. Apologies, it is for the best! -**(22.25.2024)** - -Vector stores that have a schema are now *not* initialized by default. -As is the convention with other Spring projects that rely on a schema, you must opt into allowing Spring to create a schema for you. -A new configuration property named `initialize-schema` has been introduced, with `false` being the default value. -Check the documentation section for your vector store's configuration properties for the full syntax. -The following vector stores have been impacted by this change - -* Azure AI Search -* Chroma -* Elasticsearch -* SAP Hana -* Milvus -* MongoDB -* Neo4j -* PGVector -* Pinecone -* Qdrant -* Redis -* Weaviate - **(22.05.2024)** A major change was made that took the 'old' `ChatClient` and moved the functionality into `ChatModel`. The 'new' `ChatClient` now takes an instance of `ChatModel`. This was done do support a fluent API for creating and executing prompts in a style similar to other client classes in the Spring ecosystem, such as `RestClient`, `WebClient`, and `JdbcClient`. Refer to the [JavaDoc](https://docs.spring.io/spring-ai/docs/1.0.0-SNAPSHOT/api/) for more information on the Fluent API, proper reference documentation is coming shortly. diff --git a/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/azure/tool/DeploymentNameUtil.java b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/azure/tool/DeploymentNameUtil.java new file mode 100644 index 000000000..e8f9d61b9 --- /dev/null +++ b/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/azure/tool/DeploymentNameUtil.java @@ -0,0 +1,17 @@ +package org.springframework.ai.autoconfigure.azure.tool; + +import org.springframework.util.StringUtils; + +public class DeploymentNameUtil { + + public static String getDeploymentName() { + String deploymentName = System.getenv("AZURE_OPENAI_DEPLOYMENT_NAME"); + if (StringUtils.hasText(deploymentName)) { + return deploymentName; + } + else { + return "gpt-4-0125-preview"; + } + } + +} 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 9522abfec..3cb6b1567 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 @@ -35,8 +35,10 @@ import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Description; +import org.springframework.util.StringUtils; import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.ai.autoconfigure.azure.tool.DeploymentNameUtil.getDeploymentName; @EnabledIfEnvironmentVariable(named = "AZURE_OPENAI_API_KEY", matches = ".+") @EnabledIfEnvironmentVariable(named = "AZURE_OPENAI_ENDPOINT", matches = ".+") @@ -54,7 +56,7 @@ class FunctionCallWithFunctionBeanIT { @Test void functionCallTest() { - contextRunner.withPropertyValues("spring.ai.azure.openai.chat.options..deployment-name=gpt-4-0125-preview") + contextRunner.withPropertyValues("spring.ai.azure.openai.chat.options..deployment-name=" + getDeploymentName()) .run(context -> { ChatModel chatModel = context.getBean(AzureOpenAiChatModel.class); 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 102da5d88..47ec9bfb0 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 @@ -36,6 +36,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.ai.autoconfigure.azure.tool.DeploymentNameUtil.getDeploymentName; @EnabledIfEnvironmentVariable(named = "AZURE_OPENAI_API_KEY", matches = ".+") @EnabledIfEnvironmentVariable(named = "AZURE_OPENAI_ENDPOINT", matches = ".+") @@ -53,7 +54,7 @@ public class FunctionCallWithFunctionWrapperIT { @Test void functionCallTest() { - contextRunner.withPropertyValues("spring.ai.azure.openai.chat.options.deployment-name=gpt-4-0125-preview") + contextRunner.withPropertyValues("spring.ai.azure.openai.chat.options.deployment-name=" + getDeploymentName()) .run(context -> { AzureOpenAiChatModel chatModel = context.getBean(AzureOpenAiChatModel.class); 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 b10e8a9d2..4c2b622ec 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 @@ -33,6 +33,7 @@ import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.ai.autoconfigure.azure.tool.DeploymentNameUtil.getDeploymentName; @EnabledIfEnvironmentVariable(named = "AZURE_OPENAI_API_KEY", matches = ".+") @EnabledIfEnvironmentVariable(named = "AZURE_OPENAI_ENDPOINT", matches = ".+") @@ -49,7 +50,7 @@ public class FunctionCallWithPromptFunctionIT { @Test void functionCallTest() { - contextRunner.withPropertyValues("spring.ai.azure.openai.chat.options.deployment-name=gpt-4-0125-preview") + contextRunner.withPropertyValues("spring.ai.azure.openai.chat.options.deployment-name=" + getDeploymentName()) .run(context -> { AzureOpenAiChatModel chatModel = context.getBean(AzureOpenAiChatModel.class);