From 7e28bb0c66e71f3f965b713575f3e9d8b60a23dc Mon Sep 17 00:00:00 2001 From: John Oliver <1615532+johnoliver@users.noreply.github.com> Date: Thu, 30 May 2024 15:38:03 +0100 Subject: [PATCH] =?UTF-8?q?Java:=20Fix=20OpenAPI=20importer=20not=20being?= =?UTF-8?q?=20able=20to=20match=20parameters,=20and=20removing=E2=80=A6=20?= =?UTF-8?q?(#6438)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … crlf from prompts ### 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 | 5 +++++ .../aiservices/openai/chatcompletion/OpenAIFunction.java | 2 +- .../samples/openapi/OpenAPIHttpRequestPlugin.java | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/java/CHANGELOG.md b/java/CHANGELOG.md index a414d74bf703..d0c864adf181 100644 --- a/java/CHANGELOG.md +++ b/java/CHANGELOG.md @@ -1,3 +1,8 @@ +# 1.1.5 + +- Fix bug with removing new lines on function parameters on Windows +- Fix bug forming serializing arguments to tool calls + # 1.1.3 - Fix bug appending plugin name to tool calls diff --git a/java/aiservices/openai/src/main/java/com/microsoft/semantickernel/aiservices/openai/chatcompletion/OpenAIFunction.java b/java/aiservices/openai/src/main/java/com/microsoft/semantickernel/aiservices/openai/chatcompletion/OpenAIFunction.java index 862e7cc4c6f9..0ed048e8a3d5 100644 --- a/java/aiservices/openai/src/main/java/com/microsoft/semantickernel/aiservices/openai/chatcompletion/OpenAIFunction.java +++ b/java/aiservices/openai/src/main/java/com/microsoft/semantickernel/aiservices/openai/chatcompletion/OpenAIFunction.java @@ -155,7 +155,7 @@ private static String getSchemaForFunctionParameter(@Nullable InputVariable para if (parameter != null && parameter.getDescription() != null && !parameter.getDescription() .isEmpty()) { String description = parameter.getDescription(); - description = description.replace("\n", ""); + description = description.replaceAll("\\r?\\n|\\r", ""); description = description.replace("\"", "\\\""); description = String.format("\"description\":\"%s\"", description); diff --git a/java/samples/semantickernel-sample-plugins/semantickernel-openapi-plugin/src/main/java/com/microsoft/semantickernel/samples/openapi/OpenAPIHttpRequestPlugin.java b/java/samples/semantickernel-sample-plugins/semantickernel-openapi-plugin/src/main/java/com/microsoft/semantickernel/samples/openapi/OpenAPIHttpRequestPlugin.java index ce2bd70cba4a..e37b089160fd 100644 --- a/java/samples/semantickernel-sample-plugins/semantickernel-openapi-plugin/src/main/java/com/microsoft/semantickernel/samples/openapi/OpenAPIHttpRequestPlugin.java +++ b/java/samples/semantickernel-sample-plugins/semantickernel-openapi-plugin/src/main/java/com/microsoft/semantickernel/samples/openapi/OpenAPIHttpRequestPlugin.java @@ -179,7 +179,7 @@ private Stream getParameterStreamOfArguments( .getGet() .getParameters() .stream() - .filter(param -> param.getName().equals(contextVariable)).findFirst()) + .filter(param -> param.getName().equalsIgnoreCase(contextVariable)).findFirst()) .filter(Optional::isPresent) .map(Optional::get); }