From 555a1799e8416186a9024aa618e32d698ea06012 Mon Sep 17 00:00:00 2001
From: John Oliver <1615532+johnoliver@users.noreply.github.com>
Date: Fri, 17 May 2024 15:58:13 +0100
Subject: [PATCH] Java: Upgrade azure-ai-openai to 1.0.0-beta.8 (#6312)
### Motivation and Context
### Description
### Contribution Checklist
- [ ] The code builds clean without any errors or warnings
- [ ] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [ ] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone :smile:
---
java/CHANGELOG.md | 4 ++
.../tests/ToolCallBehaviourTest.java | 4 +-
...-12b6744e-443f-4fe7-82e2-55cc41195ff1.json | 2 +-
...-71b07779-49a8-44e5-a60b-ee5b0a3ad697.json | 2 +-
...-0c8046c5-74ad-4836-8aa9-09da60f367a2.json | 2 +-
...-0215b128-4822-4368-ac3d-2f580a221f00.json | 2 +-
java/pom.xml | 2 +-
.../semantickernel/BookingPlugin.java | 41 +++++++++++--------
8 files changed, 34 insertions(+), 25 deletions(-)
diff --git a/java/CHANGELOG.md b/java/CHANGELOG.md
index c95efabae6..0a07f380ba 100644
--- a/java/CHANGELOG.md
+++ b/java/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 1.1.1
+
+- Upgrade azure-ai-openai to 1.0.0-beta.8
+
# 1.1.0
### Breaking Changes
diff --git a/java/api-test/integration-tests/src/test/java/com/microsoft/semantickernel/tests/ToolCallBehaviourTest.java b/java/api-test/integration-tests/src/test/java/com/microsoft/semantickernel/tests/ToolCallBehaviourTest.java
index 9cfc737560..2da7da6022 100644
--- a/java/api-test/integration-tests/src/test/java/com/microsoft/semantickernel/tests/ToolCallBehaviourTest.java
+++ b/java/api-test/integration-tests/src/test/java/com/microsoft/semantickernel/tests/ToolCallBehaviourTest.java
@@ -223,7 +223,7 @@ public class ToolCallBehaviourTest {
public static MappingBuilder buildTextResponse(String bodyMatcher, String responseBody) {
return post(urlEqualTo(
- "//openai/deployments/gpt-35-turbo-2/completions?api-version=2024-02-15-preview"))
+ "//openai/deployments/gpt-35-turbo-2/completions?api-version=2024-03-01-preview"))
.withRequestBody(new ContainsPattern(bodyMatcher))
.willReturn(
aResponse()
@@ -234,7 +234,7 @@ public class ToolCallBehaviourTest {
public static MappingBuilder buildResponse(String bodyMatcher, String responseBody) {
return post(urlEqualTo(
- "//openai/deployments/gpt-35-turbo-2/chat/completions?api-version=2024-02-15-preview"))
+ "//openai/deployments/gpt-35-turbo-2/chat/completions?api-version=2024-03-01-preview"))
.withRequestBody(new ContainsPattern(bodyMatcher))
.willReturn(
aResponse()
diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo-2_chat_completions-12b6744e-443f-4fe7-82e2-55cc41195ff1.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo-2_chat_completions-12b6744e-443f-4fe7-82e2-55cc41195ff1.json
index 490d29e084..24f15f34d1 100644
--- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo-2_chat_completions-12b6744e-443f-4fe7-82e2-55cc41195ff1.json
+++ b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo-2_chat_completions-12b6744e-443f-4fe7-82e2-55cc41195ff1.json
@@ -2,7 +2,7 @@
"priority": 1,
"request": {
"method": "POST",
- "url": "//openai/deployments/gpt-35-turbo-2/chat/completions?api-version=2024-02-15-preview",
+ "url": "//openai/deployments/gpt-35-turbo-2/chat/completions?api-version=2024-03-01-preview",
"bodyPatterns": [
{
"contains": "That is all"
diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo-2_chat_completions-71b07779-49a8-44e5-a60b-ee5b0a3ad697.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo-2_chat_completions-71b07779-49a8-44e5-a60b-ee5b0a3ad697.json
index ece87e0b73..2b2e290bb2 100644
--- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo-2_chat_completions-71b07779-49a8-44e5-a60b-ee5b0a3ad697.json
+++ b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo-2_chat_completions-71b07779-49a8-44e5-a60b-ee5b0a3ad697.json
@@ -1,7 +1,7 @@
{
"request": {
"method": "POST",
- "url": "//openai/deployments/gpt-35-turbo-2/chat/completions?api-version=2024-02-15-preview"
+ "url": "//openai/deployments/gpt-35-turbo-2/chat/completions?api-version=2024-03-01-preview"
},
"response": {
"body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707253061,\"model\":\"gpt-35-turbo\",\"prompt_filter_results\":[{\"prompt_index\":0,\"content_filter_results\":{\"hate\":{\"filtered\":false,\"severity\":\"safe\"},\"self_harm\":{\"filtered\":false,\"severity\":\"safe\"},\"sexual\":{\"filtered\":false,\"severity\":\"safe\"},\"violence\":{\"filtered\":false,\"severity\":\"safe\"}}}],\"choices\":[{\"finish_reason\":\"stop\",\"index\":0,\"message\":{\"role\":\"assistant\",\"content\":\"1979b4ce-5463-4cfb-8ec8-1d05c4b44ccf\"},\"content_filter_results\":{\"hate\":{\"filtered\":false,\"severity\":\"safe\"},\"self_harm\":{\"filtered\":false,\"severity\":\"safe\"},\"sexual\":{\"filtered\":false,\"severity\":\"safe\"},\"violence\":{\"filtered\":false,\"severity\":\"safe\"}}}],\"usage\":{\"prompt_tokens\":17,\"completion_tokens\":67,\"total_tokens\":84}}",
diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-0c8046c5-74ad-4836-8aa9-09da60f367a2.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-0c8046c5-74ad-4836-8aa9-09da60f367a2.json
index 6510666fdb..c909297f80 100644
--- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-0c8046c5-74ad-4836-8aa9-09da60f367a2.json
+++ b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-0c8046c5-74ad-4836-8aa9-09da60f367a2.json
@@ -1,7 +1,7 @@
{
"request": {
"method": "POST",
- "url": "//openai/deployments/gpt-35-turbo/chat/completions?api-version=2024-02-15-preview"
+ "url": "//openai/deployments/gpt-35-turbo/chat/completions?api-version=2024-03-01-preview"
},
"response": {
"body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707253039,\"model\":\"gpt-35-turbo\",\"prompt_filter_results\":[{\"prompt_index\":0,\"content_filter_results\":{\"hate\":{\"filtered\":false,\"severity\":\"safe\"},\"self_harm\":{\"filtered\":false,\"severity\":\"safe\"},\"sexual\":{\"filtered\":false,\"severity\":\"safe\"},\"violence\":{\"filtered\":false,\"severity\":\"safe\"}}}],\"choices\":[{\"finish_reason\":\"stop\",\"index\":0,\"message\":{\"role\":\"assistant\",\"content\":\"ac9817bc-7e1a-48e4-b06c-0ff7618b88c6\"},\"content_filter_results\":{\"hate\":{\"filtered\":false,\"severity\":\"safe\"},\"self_harm\":{\"filtered\":false,\"severity\":\"safe\"},\"sexual\":{\"filtered\":false,\"severity\":\"safe\"},\"violence\":{\"filtered\":false,\"severity\":\"safe\"}}}],\"usage\":{\"prompt_tokens\":26,\"completion_tokens\":131,\"total_tokens\":157}}",
diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-0215b128-4822-4368-ac3d-2f580a221f00.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-0215b128-4822-4368-ac3d-2f580a221f00.json
index 36c1d1c770..3a0ea31ced 100644
--- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-0215b128-4822-4368-ac3d-2f580a221f00.json
+++ b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-0215b128-4822-4368-ac3d-2f580a221f00.json
@@ -1,7 +1,7 @@
{
"request": {
"method": "POST",
- "url": "//openai/deployments/text-davinci-003/completions?api-version=2024-02-15-preview"
+ "url": "//openai/deployments/text-davinci-003/completions?api-version=2024-03-01-preview"
},
"response": {
"body": "{\"id\":\"cmpl-xxx\",\"object\":\"text_completion\",\"created\":1707253062,\"model\":\"text-davinci-003\",\"prompt_filter_results\":[{\"prompt_index\":0,\"content_filter_results\":{\"hate\":{\"filtered\":false,\"severity\":\"safe\"},\"self_harm\":{\"filtered\":false,\"severity\":\"safe\"},\"sexual\":{\"filtered\":false,\"severity\":\"safe\"},\"violence\":{\"filtered\":false,\"severity\":\"safe\"}}}],\"choices\":[{\"text\":\"7949e981-c632-422f-9b76-335a2379cd83\",\"index\":0,\"finish_reason\":\"stop\",\"logprobs\":null,\"content_filter_results\":{\"hate\":{\"filtered\":false,\"severity\":\"safe\"},\"self_harm\":{\"filtered\":false,\"severity\":\"safe\"},\"sexual\":{\"filtered\":false,\"severity\":\"safe\"},\"violence\":{\"filtered\":false,\"severity\":\"safe\"}}}],\"usage\":{\"prompt_tokens\":10,\"completion_tokens\":26,\"total_tokens\":36}}",
diff --git a/java/pom.xml b/java/pom.xml
index 3029392383..273a02ca4c 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -14,7 +14,7 @@
Parent pom for the Semantic Kernel Project
- 1.0.0-beta.7
+ 1.0.0-beta.8
10.13.0
0.10.21
2.19.1
diff --git a/java/samples/semantickernel-demos/booking-agent-m365/src/main/java/com/microsoft/semantickernel/BookingPlugin.java b/java/samples/semantickernel-demos/booking-agent-m365/src/main/java/com/microsoft/semantickernel/BookingPlugin.java
index 60afec1573..68c1ff95eb 100644
--- a/java/samples/semantickernel-demos/booking-agent-m365/src/main/java/com/microsoft/semantickernel/BookingPlugin.java
+++ b/java/samples/semantickernel-demos/booking-agent-m365/src/main/java/com/microsoft/semantickernel/BookingPlugin.java
@@ -42,9 +42,9 @@ public class BookingPlugin {
@KernelFunctionParameter(name = "partySize", description = "The number of people in the party", type = int.class) int partySize,
@KernelFunctionParameter(name = "customerName", description = "The name of the customer") String customerName,
@KernelFunctionParameter(name = "customerEmail", description = "The email of the customer") String customerEmail,
- @KernelFunctionParameter(name = "customerPhone", description = "The phone of the customer") String customerPhone
- ) {
- System.out.println("System > Do you want to book a table at " + restaurant + " on " + date + " for " + partySize + " people?");
+ @KernelFunctionParameter(name = "customerPhone", description = "The phone of the customer") String customerPhone) {
+ System.out.println("System > Do you want to book a table at " + restaurant + " on " + date
+ + " for " + partySize + " people?");
System.out.println("System > Please confirm the booking by typing 'yes' or 'no'");
Scanner scanner = new Scanner(System.in);
String response = scanner.nextLine().toLowerCase();
@@ -92,8 +92,9 @@ public class BookingPlugin {
}
}));
- graphServiceClient.solutions().bookingBusinesses().byBookingBusinessId(bookingBusinessId)
- .appointments().post(bookingAppointment);
+ graphServiceClient.solutions().bookingBusinesses()
+ .byBookingBusinessId(bookingBusinessId)
+ .appointments().post(bookingAppointment);
return "Booking successful!";
}
@@ -103,20 +104,21 @@ public class BookingPlugin {
@DefineKernelFunction(name = "listReservations", description = "List all reservations for a customer")
public List listReservations(
- @KernelFunctionParameter(name = "customerName", description = "The name of the customer") String customerName) {
+ @KernelFunctionParameter(name = "customerName", description = "The name of the customer") String customerName) {
List appointments = graphServiceClient.solutions().bookingBusinesses()
- .byBookingBusinessId(bookingBusinessId).appointments().get().getValue();
+ .byBookingBusinessId(bookingBusinessId).appointments().get().getValue();
List reservations = new ArrayList<>();
for (BookingAppointment appointment : appointments) {
if (appointment.getCustomers() != null && !appointment.getCustomers().isEmpty() &&
- appointment.getCustomers().get(0).getBackingStore().get("name").equals(customerName)) {
+ appointment.getCustomers().get(0).getBackingStore().get("name")
+ .equals(customerName)) {
String reservation = "Restaurant: " +
- appointment.getServiceLocation().getDisplayName() +
- "Date: " +
- appointment.getStartDateTime().getDateTime() +
- "Party size: " +
- appointment.getMaximumAttendeesCount();
+ appointment.getServiceLocation().getDisplayName() +
+ "Date: " +
+ appointment.getStartDateTime().getDateTime() +
+ "Party size: " +
+ appointment.getMaximumAttendeesCount();
reservations.add(reservation);
}
@@ -125,15 +127,17 @@ public class BookingPlugin {
return reservations;
}
- private BookingAppointment getAppointment(String restaurant, String customerName, OffsetDateTime date) {
+ private BookingAppointment getAppointment(String restaurant, String customerName,
+ OffsetDateTime date) {
List appointments = graphServiceClient.solutions().bookingBusinesses()
.byBookingBusinessId(bookingBusinessId).appointments().get().getValue();
for (BookingAppointment appointment : appointments) {
if (appointment.getServiceLocation().getDisplayName().equals(restaurant)
- && appointment.getCustomers() != null && !appointment.getCustomers().isEmpty()
- && appointment.getCustomers().get(0).getBackingStore().get("name").equals(customerName)
- && OffsetDateTime.parse(appointment.getStartDateTime().getDateTime())
+ && appointment.getCustomers() != null && !appointment.getCustomers().isEmpty()
+ && appointment.getCustomers().get(0).getBackingStore().get("name")
+ .equals(customerName)
+ && OffsetDateTime.parse(appointment.getStartDateTime().getDateTime())
.equals(date)) {
return appointment;
}
@@ -147,7 +151,8 @@ public class BookingPlugin {
@KernelFunctionParameter(name = "date", description = "The date of the reservation in UTC", type = OffsetDateTime.class) OffsetDateTime date,
@KernelFunctionParameter(name = "customerName", description = "The name of the customer") String customerName) {
- System.out.println("System > [Cancelling a reservation for " + customerName + " at " + restaurant + " on " + date + "]");
+ System.out.println("System > [Cancelling a reservation for " + customerName + " at "
+ + restaurant + " on " + date + "]");
BookingAppointment appointment = getAppointment(restaurant, customerName, date);
graphServiceClient.solutions().bookingBusinesses().byBookingBusinessId(bookingBusinessId)