Java: Upgrade azure-ai-openai to 1.0.0-beta.8 (#6312)

### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [ ] 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 😄
This commit is contained in:
John Oliver
2024-05-17 14:58:13 +00:00
committed by GitHub
parent a207f9a67b
commit 555a1799e8
8 changed files with 34 additions and 25 deletions
+4
View File
@@ -1,3 +1,7 @@
# 1.1.1
- Upgrade azure-ai-openai to 1.0.0-beta.8
# 1.1.0
### Breaking Changes
@@ -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()
@@ -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"
@@ -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}}",
@@ -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}}",
@@ -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}}",
+1 -1
View File
@@ -14,7 +14,7 @@
<description>Parent pom for the Semantic Kernel Project</description>
<properties>
<azure-ai-openai.version>1.0.0-beta.7</azure-ai-openai.version>
<azure-ai-openai.version>1.0.0-beta.8</azure-ai-openai.version>
<checkstyle.version>10.13.0</checkstyle.version>
<com.uber.nullaway.version>0.10.21</com.uber.nullaway.version>
<google.errorprone.core.version>2.19.1</google.errorprone.core.version>
@@ -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<String> listReservations(
@KernelFunctionParameter(name = "customerName", description = "The name of the customer") String customerName) {
@KernelFunctionParameter(name = "customerName", description = "The name of the customer") String customerName) {
List<BookingAppointment> appointments = graphServiceClient.solutions().bookingBusinesses()
.byBookingBusinessId(bookingBusinessId).appointments().get().getValue();
.byBookingBusinessId(bookingBusinessId).appointments().get().getValue();
List<String> 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<BookingAppointment> 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)