From 4c26f4abd0077e1ec51524863564752ab31893bc Mon Sep 17 00:00:00 2001 From: John Oliver <1615532+johnoliver@users.noreply.github.com> Date: Mon, 26 Feb 2024 19:31:00 +0000 Subject: [PATCH] Java: Update handlebars function calling (#5122) ### 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: --- .../chatcompletion/XMLPromptParser.java | 4 +- .../tests/WiremockExamplesIT.java | 38 +++- ...-12b6744e-443f-4fe7-82e2-55cc41195ff1.json | 17 ++ ...-45379a29-d6d3-4613-a885-b30ccaaa6db0.json | 23 --- ...-686c6f9b-7c66-41af-8b9b-86e44fcdb2b1.json | 23 --- ...-71b07779-49a8-44e5-a60b-ee5b0a3ad697.json | 16 +- ...-c9edbe4a-e60b-4796-bd01-11bafa211bab.json | 26 --- ...-093a64da-80ba-49bf-a4fd-625224d60b3a.json | 23 --- ...-0c8046c5-74ad-4836-8aa9-09da60f367a2.json | 14 +- ...-252c54f4-1111-467b-b028-7687e4ed5021.json | 26 --- ...-270f9641-5867-4ca4-a738-d3b1d18faefb.json | 25 --- ...-364efff1-b5dd-4796-8c01-936b19045de2.json | 26 --- ...-36d8c189-3b93-4a19-b92f-8effb670f75a.json | 23 --- ...-3708b848-8dbe-4c2d-a057-04abcee675c0.json | 23 --- ...-4939b782-4212-435b-8d7d-c3454fe0200c.json | 23 --- ...-5d78a6d8-abca-488a-8752-599051a3e352.json | 26 --- ...-604be5a5-3e55-44ee-a85f-9d9e63b1763a.json | 26 --- ...-70facef2-7e60-49d5-8009-b38915a1b355.json | 23 --- ...-779728d0-3cfa-4374-aa56-7038de43449e.json | 25 --- ...-79f4220d-21e6-43e2-8a2e-6a281fcbfea9.json | 23 --- ...-8ccdcbb2-4a82-47c4-a3da-93041481ce06.json | 23 --- ...-bcdbf876-8b4c-4de1-99b4-deaad761fdbe.json | 23 --- ...-c71f3ff7-70f7-4966-a752-811bf1c01382.json | 25 --- ...-ca797b35-ef23-4628-9c6f-b1ea00ba5e3e.json | 23 --- ...-daf144e4-182b-4100-91f2-49b6115a1026.json | 25 --- ...-dc3d7bb6-815c-44fc-a15f-a6f9ce7eb012.json | 23 --- ...-f0070b1d-f4eb-4691-9d72-a0b935a227eb.json | 23 --- ...-0215b128-4822-4368-ac3d-2f580a221f00.json | 17 +- ...-1296bcee-1e54-43b1-b4b3-4642dd8bd0a0.json | 25 --- ...-350fea53-3d73-4d59-b603-dba32fdc5af9.json | 23 --- ...-3ce79fbf-90ee-4575-aeb4-6f7d545d1db6.json | 23 --- ...-3d48b3d9-5263-4d35-97dc-6db5b0335989.json | 23 --- ...-544c72c2-de8a-407d-a319-b7c04a8c237e.json | 23 --- ...-7441c9cd-22ef-41a0-8c0b-f050326ca99c.json | 26 --- ...-7718fb6b-1cae-4420-8e34-126c14d00539.json | 23 --- ...-857195c1-97b9-4118-8c05-d25d0020f8e2.json | 23 --- ...-85f3675c-e404-4138-96c2-e49d4521e4f6.json | 23 --- ...-990e9efb-2d61-424d-bbf6-a68e2d25552f.json | 23 --- ...-a29ad1f1-2423-4dbf-a127-fd2c93998fcd.json | 23 --- ...-fb3fd96e-de60-4e75-b551-493819766937.json | 23 --- .../java/FunctionsWithinPrompts_Example.java | 169 ++++++++++++++++++ .../ContextVariableTypes.java | 2 + ...nVariableContextVariableTypeConverter.java | 46 +++++ .../orchestration/ToolCallBehavior.java | 6 +- .../handlebars/HandlebarsPromptTemplate.java | 120 ++++++------- 45 files changed, 333 insertions(+), 926 deletions(-) create mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo-2_chat_completions-12b6744e-443f-4fe7-82e2-55cc41195ff1.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo-2_chat_completions-45379a29-d6d3-4613-a885-b30ccaaa6db0.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo-2_chat_completions-686c6f9b-7c66-41af-8b9b-86e44fcdb2b1.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo-2_chat_completions-c9edbe4a-e60b-4796-bd01-11bafa211bab.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-093a64da-80ba-49bf-a4fd-625224d60b3a.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-252c54f4-1111-467b-b028-7687e4ed5021.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-270f9641-5867-4ca4-a738-d3b1d18faefb.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-364efff1-b5dd-4796-8c01-936b19045de2.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-36d8c189-3b93-4a19-b92f-8effb670f75a.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-3708b848-8dbe-4c2d-a057-04abcee675c0.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-4939b782-4212-435b-8d7d-c3454fe0200c.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-5d78a6d8-abca-488a-8752-599051a3e352.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-604be5a5-3e55-44ee-a85f-9d9e63b1763a.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-70facef2-7e60-49d5-8009-b38915a1b355.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-779728d0-3cfa-4374-aa56-7038de43449e.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-79f4220d-21e6-43e2-8a2e-6a281fcbfea9.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-8ccdcbb2-4a82-47c4-a3da-93041481ce06.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-bcdbf876-8b4c-4de1-99b4-deaad761fdbe.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-c71f3ff7-70f7-4966-a752-811bf1c01382.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-ca797b35-ef23-4628-9c6f-b1ea00ba5e3e.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-daf144e4-182b-4100-91f2-49b6115a1026.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-dc3d7bb6-815c-44fc-a15f-a6f9ce7eb012.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-f0070b1d-f4eb-4691-9d72-a0b935a227eb.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-1296bcee-1e54-43b1-b4b3-4642dd8bd0a0.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-350fea53-3d73-4d59-b603-dba32fdc5af9.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-3ce79fbf-90ee-4575-aeb4-6f7d545d1db6.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-3d48b3d9-5263-4d35-97dc-6db5b0335989.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-544c72c2-de8a-407d-a319-b7c04a8c237e.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-7441c9cd-22ef-41a0-8c0b-f050326ca99c.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-7718fb6b-1cae-4420-8e34-126c14d00539.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-857195c1-97b9-4118-8c05-d25d0020f8e2.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-85f3675c-e404-4138-96c2-e49d4521e4f6.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-990e9efb-2d61-424d-bbf6-a68e2d25552f.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-a29ad1f1-2423-4dbf-a127-fd2c93998fcd.json delete mode 100644 java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-fb3fd96e-de60-4e75-b551-493819766937.json create mode 100644 java/samples/sample-code/src/main/java/com/microsoft/semantickernel/samples/syntaxexamples/java/FunctionsWithinPrompts_Example.java create mode 100644 java/semantickernel-api/src/main/java/com/microsoft/semantickernel/contextvariables/converters/CollectionVariableContextVariableTypeConverter.java diff --git a/java/aiservices/openai/src/main/java/com/microsoft/semantickernel/aiservices/openai/chatcompletion/XMLPromptParser.java b/java/aiservices/openai/src/main/java/com/microsoft/semantickernel/aiservices/openai/chatcompletion/XMLPromptParser.java index 81af20222f..b6aa583955 100644 --- a/java/aiservices/openai/src/main/java/com/microsoft/semantickernel/aiservices/openai/chatcompletion/XMLPromptParser.java +++ b/java/aiservices/openai/src/main/java/com/microsoft/semantickernel/aiservices/openai/chatcompletion/XMLPromptParser.java @@ -7,6 +7,7 @@ import com.azure.ai.openai.models.FunctionDefinition; import com.azure.core.util.BinaryData; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.microsoft.semantickernel.orchestration.ToolCallBehavior; import com.microsoft.semantickernel.services.chatcompletion.AuthorRole; import com.microsoft.semantickernel.exceptions.SKException; import java.io.ByteArrayInputStream; @@ -106,7 +107,8 @@ class XMLPromptParser { String name = getAttributeValue(event, "name"); String description = getAttributeValue(event, "description"); // name has to match '^[a-zA-Z0-9_-]{1,64}$' - functionDefinition = new FunctionDefinition(pluginName + "-" + name) + functionDefinition = new FunctionDefinition( + ToolCallBehavior.formFullFunctionName(pluginName, name)) .setDescription(description); } else if (elementName.equals("parameter")) { String name = getAttributeValue(event, "name"); diff --git a/java/api-test/integration-tests/src/test/java/com/microsoft/semantickernel/tests/WiremockExamplesIT.java b/java/api-test/integration-tests/src/test/java/com/microsoft/semantickernel/tests/WiremockExamplesIT.java index cf3eeaacab..039dc3b006 100644 --- a/java/api-test/integration-tests/src/test/java/com/microsoft/semantickernel/tests/WiremockExamplesIT.java +++ b/java/api-test/integration-tests/src/test/java/com/microsoft/semantickernel/tests/WiremockExamplesIT.java @@ -27,17 +27,25 @@ import com.microsoft.semantickernel.samples.syntaxexamples.Example62_CustomAISer import com.microsoft.semantickernel.samples.syntaxexamples.Example63_ChatCompletionPrompts; import com.microsoft.semantickernel.samples.syntaxexamples.Example64_MultiplePromptTemplates; import com.microsoft.semantickernel.samples.syntaxexamples.Example69_MutableKernelPlugin; +import com.microsoft.semantickernel.samples.syntaxexamples.java.FunctionsWithinPrompts_Example; +import com.microsoft.semantickernel.samples.syntaxexamples.java.KernelFunctionYaml_Example; +import java.io.IOException; +import java.io.InputStream; import java.lang.reflect.Method; +import java.util.ArrayDeque; import java.util.Arrays; import java.util.List; +import java.util.Queue; import java.util.stream.Stream; import org.junit.jupiter.api.DynamicTest; import org.junit.jupiter.api.TestFactory; +import org.mockito.Mockito; public class WiremockExamplesIT { public static List> mains = Arrays.asList( - + FunctionsWithinPrompts_Example.class, + KernelFunctionYaml_Example.class, Example01_NativeFunctions.class, Example03_Arguments.class, Example05_InlineFunctionDefinition.class, @@ -83,7 +91,9 @@ public class WiremockExamplesIT { .usingFilesUnderDirectory(dir)); } - public static void main(String[] args) { + public static void main(String[] args) throws IOException { + mockInputStream(); + new WiremockExamplesIT() .runSamplesTest() .forEach(it -> { @@ -95,6 +105,30 @@ public class WiremockExamplesIT { }); } + private static void mockInputStream() throws IOException { + FunctionsWithinPrompts_Example.INPUT = Mockito.mock(InputStream.class); + + Queue messages = new ArrayDeque<>(); + + messages.addAll(Arrays.asList( + "Can you draft me an email to the marketing team?", + "Tell them to go ahead with the plan", + "That is all")); + + Mockito + .when(FunctionsWithinPrompts_Example.INPUT.read( + Mockito.any(byte[].class), + Mockito.anyInt(), + Mockito.anyInt())) + .then(invocation -> { + String message = messages.poll() + "\n"; + byte[] bytes = invocation.getArgument(0); + System.arraycopy(message.getBytes(), 0, bytes, 0, message.getBytes().length); + + return message.getBytes().length; + }); + } + @TestFactory public Stream runSamplesTest() { return mains 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 new file mode 100644 index 0000000000..9ba7c42e55 --- /dev/null +++ b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo-2_chat_completions-12b6744e-443f-4fe7-82e2-55cc41195ff1.json @@ -0,0 +1,17 @@ +{ + "priority": 1, + "request": { + "method": "POST", + "url": "//openai/deployments/gpt-35-turbo-2/chat/completions?api-version=2023-12-01-preview", + "bodyPatterns": [ + { + "contains": "That is all" + } + ] + }, + "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\":\"EndConversation\"},\"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}}", + "headers": {}, + "status": 200 + } +} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo-2_chat_completions-45379a29-d6d3-4613-a885-b30ccaaa6db0.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo-2_chat_completions-45379a29-d6d3-4613-a885-b30ccaaa6db0.json deleted file mode 100644 index 7026d494b6..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo-2_chat_completions-45379a29-d6d3-4613-a885-b30ccaaa6db0.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "45379a29-d6d3-4613-a885-b30ccaaa6db0", - "insertionIndex": 19, - "name": "deployments_gpt-35-turbo-2_chat_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"assistant\",\"content\":\"You are a librarian expert\"},{\"role\":\"user\",\"content\":\"Hi, I'm looking some suggestions\"},{\"role\":\"assistant\",\"content\":\"Of course! I'd be happy to help you with some suggestions. What are you looking for?\"},{\"role\":\"user\",\"content\":\"I love history and philosophy, I'd like to learn something new about Greece, any suggestion\"}],\"max_tokens\":256,\"temperature\":1.0,\"top_p\":1.0,\"logit_bias\":{\"39142\":-100,\"17422\":-100,\"35199\":-100,\"56185\":-100,\"2363\":-100,\"23763\":-100,\"35097\":-100,\"1160\":-100,\"47913\":-100,\"58162\":-100,\"1888\":-100,\"79761\":-100,\"3229\":-100,\"2536\":-100,\"12735\":-100,\"301\":-100,\"3446\":-100,\"2653\":-100,\"86831\":-100,\"56741\":-100,\"3773\":-100,\"6875\":-100,\"17649\":-100,\"5403\":-100},\"user\":\"\",\"n\":1,\"presence_penalty\":0.0,\"frequency_penalty\":0.0,\"model\":\"gpt-35-turbo-2\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/gpt-35-turbo-2/chat/completions?api-version=2023-12-01-preview" - }, - "response": { - "body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707253019,\"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\":\"length\",\"index\":0,\"message\":{\"role\":\"assistant\",\"content\":\"52dbd293-192d-4e01-8b31-e364b11a089d\"},\"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\":69,\"completion_tokens\":256,\"total_tokens\":325}}", - "headers": {}, - "status": 200 - }, - "uuid": "45379a29-d6d3-4613-a885-b30ccaaa6db0" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo-2_chat_completions-686c6f9b-7c66-41af-8b9b-86e44fcdb2b1.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo-2_chat_completions-686c6f9b-7c66-41af-8b9b-86e44fcdb2b1.json deleted file mode 100644 index 1723fddb05..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo-2_chat_completions-686c6f9b-7c66-41af-8b9b-86e44fcdb2b1.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "686c6f9b-7c66-41af-8b9b-86e44fcdb2b1", - "insertionIndex": 20, - "name": "deployments_gpt-35-turbo-2_chat_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"assistant\",\"content\":\"You are a librarian expert\"},{\"role\":\"user\",\"content\":\"Hi, I'm looking some suggestions\"}],\"max_tokens\":256,\"temperature\":1.0,\"top_p\":1.0,\"logit_bias\":{\"39142\":-100,\"17422\":-100,\"35199\":-100,\"56185\":-100,\"2363\":-100,\"23763\":-100,\"35097\":-100,\"1160\":-100,\"47913\":-100,\"58162\":-100,\"1888\":-100,\"79761\":-100,\"3229\":-100,\"2536\":-100,\"12735\":-100,\"301\":-100,\"3446\":-100,\"2653\":-100,\"86831\":-100,\"56741\":-100,\"3773\":-100,\"6875\":-100,\"17649\":-100,\"5403\":-100},\"user\":\"\",\"n\":1,\"presence_penalty\":0.0,\"frequency_penalty\":0.0,\"model\":\"gpt-35-turbo-2\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/gpt-35-turbo-2/chat/completions?api-version=2023-12-01-preview" - }, - "response": { - "body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707253018,\"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\":\"0aaf065e-3032-4d24-8d5d-10fc6b4c7eaf\"},\"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\":23,\"completion_tokens\":20,\"total_tokens\":43}}", - "headers": {}, - "status": 200 - }, - "uuid": "686c6f9b-7c66-41af-8b9b-86e44fcdb2b1" -} 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 dd6f49b4c0..9e2ac99789 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,25 +1,11 @@ { - "id": "71b07779-49a8-44e5-a60b-ee5b0a3ad697", - "insertionIndex": 7, - "name": "deployments_gpt-35-turbo-2_chat_completions", - "persistent": true, "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"user\",\"content\":\"Hello AI, what can you do for me?\"}],\"model\":\"gpt-35-turbo-2\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], "method": "POST", "url": "//openai/deployments/gpt-35-turbo-2/chat/completions?api-version=2023-12-01-preview" }, - "requiredScenarioState": "scenario-4-deployments-gpt-35-turbo-2-chat-completions-2", "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}}", "headers": {}, "status": 200 - }, - "scenarioName": "scenario-4-deployments-gpt-35-turbo-2-chat-completions", - "uuid": "71b07779-49a8-44e5-a60b-ee5b0a3ad697" + } } diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo-2_chat_completions-c9edbe4a-e60b-4796-bd01-11bafa211bab.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo-2_chat_completions-c9edbe4a-e60b-4796-bd01-11bafa211bab.json deleted file mode 100644 index 7ff593b416..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo-2_chat_completions-c9edbe4a-e60b-4796-bd01-11bafa211bab.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "id": "c9edbe4a-e60b-4796-bd01-11bafa211bab", - "insertionIndex": 8, - "name": "deployments_gpt-35-turbo-2_chat_completions", - "newScenarioState": "scenario-4-deployments-gpt-35-turbo-2-chat-completions-2", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"user\",\"content\":\"Hello AI, what can you do for me?\"}],\"model\":\"gpt-35-turbo-2\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/gpt-35-turbo-2/chat/completions?api-version=2023-12-01-preview" - }, - "requiredScenarioState": "Started", - "response": { - "body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707253054,\"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\":\"28eee7e9-28c5-47c7-90c5-44cef75fd582\"},\"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\":297,\"total_tokens\":314}}", - "headers": {}, - "status": 200 - }, - "scenarioName": "scenario-4-deployments-gpt-35-turbo-2-chat-completions", - "uuid": "c9edbe4a-e60b-4796-bd01-11bafa211bab" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-093a64da-80ba-49bf-a4fd-625224d60b3a.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-093a64da-80ba-49bf-a4fd-625224d60b3a.json deleted file mode 100644 index 03befd18ef..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-093a64da-80ba-49bf-a4fd-625224d60b3a.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "093a64da-80ba-49bf-a4fd-625224d60b3a", - "insertionIndex": 25, - "name": "deployments_gpt-35-turbo_chat_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"user\",\"content\":\"List the two planets closest to 'Jupiter', excluding moons, using bullet points.\"}],\"model\":\"gpt-35-turbo\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-12-01-preview" - }, - "response": { - "body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707253000,\"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\":\"120318d5-35af-487a-b335-7fa00c5f7dd7\"},\"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\":24,\"completion_tokens\":5,\"total_tokens\":29}}", - "headers": {}, - "status": 200 - }, - "uuid": "093a64da-80ba-49bf-a4fd-625224d60b3a" -} 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 8c045a0251..84a4c5aa3d 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,16 +1,5 @@ { - "id": "0c8046c5-74ad-4836-8aa9-09da60f367a2", - "insertionIndex": 12, - "name": "deployments_gpt-35-turbo_chat_completions", - "persistent": true, "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"user\",\"content\":\"Write a paragraph about hats\"},{\"role\":\"system\",\"content\":\"Use upper case text when responding to the prompt.\"}],\"model\":\"gpt-35-turbo\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], "method": "POST", "url": "//openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-12-01-preview" }, @@ -18,6 +7,5 @@ "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}}", "headers": {}, "status": 200 - }, - "uuid": "0c8046c5-74ad-4836-8aa9-09da60f367a2" + } } diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-252c54f4-1111-467b-b028-7687e4ed5021.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-252c54f4-1111-467b-b028-7687e4ed5021.json deleted file mode 100644 index 363c24b77b..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-252c54f4-1111-467b-b028-7687e4ed5021.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "id": "252c54f4-1111-467b-b028-7687e4ed5021", - "insertionIndex": 27, - "name": "deployments_gpt-35-turbo_chat_completions", - "newScenarioState": "scenario-6-deployments-gpt-35-turbo-chat-completions-2", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"assistant\",\"content\":\"You are a librarian, expert about books\"},{\"role\":\"user\",\"content\":\"Hi, I'm looking for book suggestions\"}],\"model\":\"gpt-35-turbo\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-12-01-preview" - }, - "requiredScenarioState": "Started", - "response": { - "body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707252992,\"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\":\"7d312938-df92-46bf-8729-8d7b92ddb026\"},\"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\":27,\"completion_tokens\":76,\"total_tokens\":103}}", - "headers": {}, - "status": 200 - }, - "scenarioName": "scenario-6-deployments-gpt-35-turbo-chat-completions", - "uuid": "252c54f4-1111-467b-b028-7687e4ed5021" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-270f9641-5867-4ca4-a738-d3b1d18faefb.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-270f9641-5867-4ca4-a738-d3b1d18faefb.json deleted file mode 100644 index a140521131..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-270f9641-5867-4ca4-a738-d3b1d18faefb.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "id": "270f9641-5867-4ca4-a738-d3b1d18faefb", - "insertionIndex": 3, - "name": "deployments_gpt-35-turbo_chat_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"user\",\"content\":\"What is Seattle?\"},{\"role\":\"system\",\"content\":\"Respond with JSON.\"}],\"model\":\"gpt-35-turbo\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-12-01-preview" - }, - "requiredScenarioState": "scenario-2-deployments-gpt-35-turbo-chat-completions-2", - "response": { - "body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707253067,\"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\":\"57e7d767-3d91-4622-8571-84710dd2e7ff\"},\"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\":19,\"completion_tokens\":151,\"total_tokens\":170}}", - "headers": {}, - "status": 200 - }, - "scenarioName": "scenario-2-deployments-gpt-35-turbo-chat-completions", - "uuid": "270f9641-5867-4ca4-a738-d3b1d18faefb" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-364efff1-b5dd-4796-8c01-936b19045de2.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-364efff1-b5dd-4796-8c01-936b19045de2.json deleted file mode 100644 index f7d797c812..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-364efff1-b5dd-4796-8c01-936b19045de2.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "id": "364efff1-b5dd-4796-8c01-936b19045de2", - "insertionIndex": 11, - "name": "deployments_gpt-35-turbo_chat_completions", - "newScenarioState": "scenario-5-deployments-gpt-35-turbo-chat-completions-2", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"user\",\"content\":\"Hello AI, what can you do for me?\"}],\"model\":\"gpt-35-turbo\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-12-01-preview" - }, - "requiredScenarioState": "Started", - "response": { - "body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707253042,\"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\":\"2fb33955-441a-429d-bbf6-603e449d21b6\"},\"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\":197,\"total_tokens\":214}}", - "headers": {}, - "status": 200 - }, - "scenarioName": "scenario-5-deployments-gpt-35-turbo-chat-completions", - "uuid": "364efff1-b5dd-4796-8c01-936b19045de2" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-36d8c189-3b93-4a19-b92f-8effb670f75a.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-36d8c189-3b93-4a19-b92f-8effb670f75a.json deleted file mode 100644 index 07c34adc1c..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-36d8c189-3b93-4a19-b92f-8effb670f75a.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "36d8c189-3b93-4a19-b92f-8effb670f75a", - "insertionIndex": 26, - "name": "deployments_gpt-35-turbo_chat_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"assistant\",\"content\":\"You are a librarian, expert about books\"},{\"role\":\"user\",\"content\":\"Hi, I'm looking for book suggestions\"},{\"role\":\"assistant\",\"content\":\"Certainly! I'd be happy to help you find some book suggestions. Could you please provide me with more information about what kind of books you enjoy? For example, do you have any favorite genres or authors? Are you looking for fiction or non-fiction books? Any specific themes or topics you're interested in? The more details you can provide, the better I can assist you.\"},{\"role\":\"user\",\"content\":\"I love history and philosophy, I'd like to learn something new about Greece, any suggestion\"}],\"model\":\"gpt-35-turbo\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-12-01-preview" - }, - "response": { - "body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707252994,\"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\":\"ace2c274-2932-4ba7-b132-6ec80ad55698\"},\"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\":129,\"completion_tokens\":308,\"total_tokens\":437}}", - "headers": {}, - "status": 200 - }, - "uuid": "36d8c189-3b93-4a19-b92f-8effb670f75a" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-3708b848-8dbe-4c2d-a057-04abcee675c0.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-3708b848-8dbe-4c2d-a057-04abcee675c0.json deleted file mode 100644 index ffec06181e..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-3708b848-8dbe-4c2d-a057-04abcee675c0.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "3708b848-8dbe-4c2d-a057-04abcee675c0", - "insertionIndex": 22, - "name": "deployments_gpt-35-turbo_chat_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"user\",\"content\":\"Hi, give me 5 book suggestions about: travel\"}],\"model\":\"gpt-35-turbo\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-12-01-preview" - }, - "response": { - "body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707253005,\"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\":\"67c9623d-7f83-432b-89e5-40ffb3c343c2\"},\"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\":18,\"completion_tokens\":281,\"total_tokens\":299}}", - "headers": {}, - "status": 200 - }, - "uuid": "3708b848-8dbe-4c2d-a057-04abcee675c0" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-4939b782-4212-435b-8d7d-c3454fe0200c.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-4939b782-4212-435b-8d7d-c3454fe0200c.json deleted file mode 100644 index d89da3ea54..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-4939b782-4212-435b-8d7d-c3454fe0200c.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "4939b782-4212-435b-8d7d-c3454fe0200c", - "insertionIndex": 16, - "name": "deployments_gpt-35-turbo_chat_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"user\",\"content\":\"Write a random paragraph about: I missed the F1 final race in the style of Seinfeld.\\nUSE SHORT, CLEAR, COMPLETE SENTENCES.\"}],\"model\":\"gpt-35-turbo\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-12-01-preview" - }, - "response": { - "body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707253027,\"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\":\"8e81b11a-5cd0-40f1-a80d-641ec60a3bc4\"},\"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\":36,\"completion_tokens\":336,\"total_tokens\":372}}", - "headers": {}, - "status": 200 - }, - "uuid": "4939b782-4212-435b-8d7d-c3454fe0200c" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-5d78a6d8-abca-488a-8752-599051a3e352.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-5d78a6d8-abca-488a-8752-599051a3e352.json deleted file mode 100644 index d111644847..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-5d78a6d8-abca-488a-8752-599051a3e352.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "id": "5d78a6d8-abca-488a-8752-599051a3e352", - "insertionIndex": 4, - "name": "deployments_gpt-35-turbo_chat_completions", - "newScenarioState": "scenario-2-deployments-gpt-35-turbo-chat-completions-2", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"user\",\"content\":\"What is Seattle?\"},{\"role\":\"system\",\"content\":\"Respond with JSON.\"}],\"model\":\"gpt-35-turbo\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-12-01-preview" - }, - "requiredScenarioState": "Started", - "response": { - "body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707253065,\"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\":\"28374b87-21d3-4506-9569-3c7c4aaf9052\"},\"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\":19,\"completion_tokens\":91,\"total_tokens\":110}}", - "headers": {}, - "status": 200 - }, - "scenarioName": "scenario-2-deployments-gpt-35-turbo-chat-completions", - "uuid": "5d78a6d8-abca-488a-8752-599051a3e352" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-604be5a5-3e55-44ee-a85f-9d9e63b1763a.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-604be5a5-3e55-44ee-a85f-9d9e63b1763a.json deleted file mode 100644 index 17c74af8bd..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-604be5a5-3e55-44ee-a85f-9d9e63b1763a.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "id": "604be5a5-3e55-44ee-a85f-9d9e63b1763a", - "insertionIndex": 2, - "name": "deployments_gpt-35-turbo_chat_completions", - "newScenarioState": "scenario-1-deployments-gpt-35-turbo-chat-completions-2", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"user\",\"content\":\"Hello AI, my name is Bob. What is the origin of my name?\"}],\"model\":\"gpt-35-turbo\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-12-01-preview" - }, - "requiredScenarioState": "Started", - "response": { - "body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707253070,\"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\":\"aed93937-6747-4092-8b1d-6a3345a63197\"},\"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\":23,\"completion_tokens\":75,\"total_tokens\":98}}", - "headers": {}, - "status": 200 - }, - "scenarioName": "scenario-1-deployments-gpt-35-turbo-chat-completions", - "uuid": "604be5a5-3e55-44ee-a85f-9d9e63b1763a" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-70facef2-7e60-49d5-8009-b38915a1b355.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-70facef2-7e60-49d5-8009-b38915a1b355.json deleted file mode 100644 index f04494d6ad..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-70facef2-7e60-49d5-8009-b38915a1b355.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "70facef2-7e60-49d5-8009-b38915a1b355", - "insertionIndex": 23, - "name": "deployments_gpt-35-turbo_chat_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"assistant\",\"content\":\"You are a librarian, expert about books\"},{\"role\":\"user\",\"content\":\"Hi, I'm looking for book suggestions\"},{\"role\":\"assistant\",\"content\":\"Of course! I'd be happy to help you find some book suggestions. What genre or type of book are you interested in?\"},{\"role\":\"user\",\"content\":\"I love history and philosophy, I'd like to learn something new about Greece, any suggestion\"}],\"model\":\"gpt-35-turbo\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-12-01-preview" - }, - "response": { - "body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707253001,\"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\":\"6fe0e3aa-5670-435c-9c90-976f97ce9c4c\"},\"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\":79,\"completion_tokens\":276,\"total_tokens\":355}}", - "headers": {}, - "status": 200 - }, - "uuid": "70facef2-7e60-49d5-8009-b38915a1b355" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-779728d0-3cfa-4374-aa56-7038de43449e.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-779728d0-3cfa-4374-aa56-7038de43449e.json deleted file mode 100644 index 8b839fd51b..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-779728d0-3cfa-4374-aa56-7038de43449e.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "id": "779728d0-3cfa-4374-aa56-7038de43449e", - "insertionIndex": 24, - "name": "deployments_gpt-35-turbo_chat_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"assistant\",\"content\":\"You are a librarian, expert about books\"},{\"role\":\"user\",\"content\":\"Hi, I'm looking for book suggestions\"}],\"model\":\"gpt-35-turbo\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-12-01-preview" - }, - "requiredScenarioState": "scenario-6-deployments-gpt-35-turbo-chat-completions-2", - "response": { - "body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707253000,\"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\":\"4772ff60-75e0-46bc-8224-6ec8ba5b9be1\"},\"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\":27,\"completion_tokens\":26,\"total_tokens\":53}}", - "headers": {}, - "status": 200 - }, - "scenarioName": "scenario-6-deployments-gpt-35-turbo-chat-completions", - "uuid": "779728d0-3cfa-4374-aa56-7038de43449e" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-79f4220d-21e6-43e2-8a2e-6a281fcbfea9.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-79f4220d-21e6-43e2-8a2e-6a281fcbfea9.json deleted file mode 100644 index ff6af76b9f..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-79f4220d-21e6-43e2-8a2e-6a281fcbfea9.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "79f4220d-21e6-43e2-8a2e-6a281fcbfea9", - "insertionIndex": 21, - "name": "deployments_gpt-35-turbo_chat_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"assistant\",\"content\":\"You are a librarian, expert about books\"},{\"role\":\"user\",\"content\":\"Hi, I'm looking for 3 different book suggestions about sci-fi\"}],\"max_tokens\":1024,\"temperature\":1.0,\"top_p\":1.0,\"logit_bias\":{},\"user\":\"\",\"n\":2,\"presence_penalty\":0.0,\"frequency_penalty\":0.0,\"model\":\"gpt-35-turbo\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-12-01-preview" - }, - "response": { - "body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707253010,\"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\":\"4949cf23-7039-4226-be78-8dd8c6e678e3\"},\"content_filter_results\":{\"hate\":{\"filtered\":false,\"severity\":\"safe\"},\"self_harm\":{\"filtered\":false,\"severity\":\"safe\"},\"sexual\":{\"filtered\":false,\"severity\":\"safe\"},\"violence\":{\"filtered\":false,\"severity\":\"safe\"}}},{\"finish_reason\":\"stop\",\"index\":1,\"message\":{\"role\":\"assistant\",\"content\":\"7c66554a-3003-467d-9ce7-9bf7e22ab921\"},\"content_filter_results\":{\"hate\":{\"filtered\":false,\"severity\":\"safe\"},\"self_harm\":{\"filtered\":false,\"severity\":\"safe\"},\"sexual\":{\"filtered\":false,\"severity\":\"safe\"},\"violence\":{\"filtered\":false,\"severity\":\"low\"}}}],\"usage\":{\"prompt_tokens\":33,\"completion_tokens\":640,\"total_tokens\":673}}", - "headers": {}, - "status": 200 - }, - "uuid": "79f4220d-21e6-43e2-8a2e-6a281fcbfea9" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-8ccdcbb2-4a82-47c4-a3da-93041481ce06.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-8ccdcbb2-4a82-47c4-a3da-93041481ce06.json deleted file mode 100644 index a5a05ec53c..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-8ccdcbb2-4a82-47c4-a3da-93041481ce06.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "8ccdcbb2-4a82-47c4-a3da-93041481ce06", - "insertionIndex": 18, - "name": "deployments_gpt-35-turbo_chat_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"user\",\"content\":\"Write a haiku about the following: Harry Potter\"}],\"model\":\"gpt-35-turbo\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-12-01-preview" - }, - "response": { - "body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707253023,\"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\":\"9043bdfe-acca-4068-8880-31f68015d800\"},\"content_filter_results\":{\"hate\":{\"filtered\":false,\"severity\":\"safe\"},\"self_harm\":{\"filtered\":false,\"severity\":\"safe\"},\"sexual\":{\"filtered\":false,\"severity\":\"safe\"},\"violence\":{\"filtered\":false,\"severity\":\"low\"}}}],\"usage\":{\"prompt_tokens\":17,\"completion_tokens\":18,\"total_tokens\":35}}", - "headers": {}, - "status": 200 - }, - "uuid": "8ccdcbb2-4a82-47c4-a3da-93041481ce06" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-bcdbf876-8b4c-4de1-99b4-deaad761fdbe.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-bcdbf876-8b4c-4de1-99b4-deaad761fdbe.json deleted file mode 100644 index 2883487c7a..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-bcdbf876-8b4c-4de1-99b4-deaad761fdbe.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "bcdbf876-8b4c-4de1-99b4-deaad761fdbe", - "insertionIndex": 14, - "name": "deployments_gpt-35-turbo_chat_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"user\",\"content\":\"Write a phrase with Cancellation.\"}],\"model\":\"gpt-35-turbo\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-12-01-preview" - }, - "response": { - "body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707253036,\"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\":\"49ec813d-2f20-4424-9a3f-b6ead6b4894f\"},\"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\":14,\"completion_tokens\":12,\"total_tokens\":26}}", - "headers": {}, - "status": 200 - }, - "uuid": "bcdbf876-8b4c-4de1-99b4-deaad761fdbe" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-c71f3ff7-70f7-4966-a752-811bf1c01382.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-c71f3ff7-70f7-4966-a752-811bf1c01382.json deleted file mode 100644 index e4985753bc..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-c71f3ff7-70f7-4966-a752-811bf1c01382.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "id": "c71f3ff7-70f7-4966-a752-811bf1c01382", - "insertionIndex": 1, - "name": "deployments_gpt-35-turbo_chat_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"user\",\"content\":\"Hello AI, my name is Bob. What is the origin of my name?\"}],\"model\":\"gpt-35-turbo\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-12-01-preview" - }, - "requiredScenarioState": "scenario-1-deployments-gpt-35-turbo-chat-completions-2", - "response": { - "body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707253072,\"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\":\"b82a811f-96d2-479f-96db-cadddfa99c1d\"},\"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\":23,\"completion_tokens\":80,\"total_tokens\":103}}", - "headers": {}, - "status": 200 - }, - "scenarioName": "scenario-1-deployments-gpt-35-turbo-chat-completions", - "uuid": "c71f3ff7-70f7-4966-a752-811bf1c01382" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-ca797b35-ef23-4628-9c6f-b1ea00ba5e3e.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-ca797b35-ef23-4628-9c6f-b1ea00ba5e3e.json deleted file mode 100644 index 36bd24780d..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-ca797b35-ef23-4628-9c6f-b1ea00ba5e3e.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "ca797b35-ef23-4628-9c6f-b1ea00ba5e3e", - "insertionIndex": 15, - "name": "deployments_gpt-35-turbo_chat_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"user\",\"content\":\"Write a paragraph about Handlers.\"}],\"model\":\"gpt-35-turbo\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-12-01-preview" - }, - "response": { - "body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707253032,\"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\":\"49c63368-9fe4-42ca-bd0c-ff1064c44eb6\"},\"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\":13,\"completion_tokens\":149,\"total_tokens\":162}}", - "headers": {}, - "status": 200 - }, - "uuid": "ca797b35-ef23-4628-9c6f-b1ea00ba5e3e" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-daf144e4-182b-4100-91f2-49b6115a1026.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-daf144e4-182b-4100-91f2-49b6115a1026.json deleted file mode 100644 index e3415ef522..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-daf144e4-182b-4100-91f2-49b6115a1026.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "id": "daf144e4-182b-4100-91f2-49b6115a1026", - "insertionIndex": 10, - "name": "deployments_gpt-35-turbo_chat_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"user\",\"content\":\"Hello AI, what can you do for me?\"}],\"model\":\"gpt-35-turbo\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-12-01-preview" - }, - "requiredScenarioState": "scenario-5-deployments-gpt-35-turbo-chat-completions-2", - "response": { - "body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707253047,\"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\":\"4aab22a1-8bb4-462e-a72d-5abeb5b91335\"},\"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\":251,\"total_tokens\":268}}", - "headers": {}, - "status": 200 - }, - "scenarioName": "scenario-5-deployments-gpt-35-turbo-chat-completions", - "uuid": "daf144e4-182b-4100-91f2-49b6115a1026" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-dc3d7bb6-815c-44fc-a15f-a6f9ce7eb012.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-dc3d7bb6-815c-44fc-a15f-a6f9ce7eb012.json deleted file mode 100644 index ca3f68c04a..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-dc3d7bb6-815c-44fc-a15f-a6f9ce7eb012.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "dc3d7bb6-815c-44fc-a15f-a6f9ce7eb012", - "insertionIndex": 13, - "name": "deployments_gpt-35-turbo_chat_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"user\",\"content\":\"Write a paragraph about hats\"}],\"model\":\"gpt-35-turbo\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-12-01-preview" - }, - "response": { - "body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707253037,\"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\":\"8dafdc23-45e2-4c72-949d-0b88c107c76e\"},\"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\":12,\"completion_tokens\":130,\"total_tokens\":142}}", - "headers": {}, - "status": 200 - }, - "uuid": "dc3d7bb6-815c-44fc-a15f-a6f9ce7eb012" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-f0070b1d-f4eb-4691-9d72-a0b935a227eb.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-f0070b1d-f4eb-4691-9d72-a0b935a227eb.json deleted file mode 100644 index ea296f3757..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_gpt-35-turbo_chat_completions-f0070b1d-f4eb-4691-9d72-a0b935a227eb.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "f0070b1d-f4eb-4691-9d72-a0b935a227eb", - "insertionIndex": 17, - "name": "deployments_gpt-35-turbo_chat_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"messages\":[{\"role\":\"user\",\"content\":\"Write a random paragraph about: I missed the F1 final race.\"}],\"model\":\"gpt-35-turbo\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-12-01-preview" - }, - "response": { - "body": "{\"id\":\"chatcmpl-xxx\",\"object\":\"chat.completion\",\"created\":1707253024,\"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\":\"97aeec5d-1555-4548-a681-cb1cc52b15c5\"},\"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\":21,\"completion_tokens\":175,\"total_tokens\":196}}", - "headers": {}, - "status": 200 - }, - "uuid": "f0070b1d-f4eb-4691-9d72-a0b935a227eb" -} 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 46455db79b..6553ee20b2 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,26 +1,11 @@ { - "id": "0215b128-4822-4368-ac3d-2f580a221f00", - "insertionIndex": 6, - "name": "deployments_text-davinci-003_completions", - "newScenarioState": "scenario-3-deployments-text-davinci-003-completions-3", - "persistent": true, "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"prompt\":[\"Hello AI, what can you do for me?\"],\"max_tokens\":256,\"temperature\":1.0,\"top_p\":1.0,\"logit_bias\":{},\"user\":\"\",\"n\":1,\"presence_penalty\":0.0,\"frequency_penalty\":0.0,\"best_of\":1,\"model\":\"text-davinci-003\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], "method": "POST", "url": "//openai/deployments/text-davinci-003/completions?api-version=2023-12-01-preview" }, - "requiredScenarioState": "scenario-3-deployments-text-davinci-003-completions-2", "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}}", "headers": {}, "status": 200 - }, - "scenarioName": "scenario-3-deployments-text-davinci-003-completions", - "uuid": "0215b128-4822-4368-ac3d-2f580a221f00" + } } diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-1296bcee-1e54-43b1-b4b3-4642dd8bd0a0.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-1296bcee-1e54-43b1-b4b3-4642dd8bd0a0.json deleted file mode 100644 index 486a8b19cb..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-1296bcee-1e54-43b1-b4b3-4642dd8bd0a0.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "id": "1296bcee-1e54-43b1-b4b3-4642dd8bd0a0", - "insertionIndex": 5, - "name": "deployments_text-davinci-003_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"prompt\":[\"Hello AI, what can you do for me?\"],\"max_tokens\":256,\"temperature\":1.0,\"top_p\":1.0,\"logit_bias\":{},\"user\":\"\",\"n\":1,\"presence_penalty\":0.0,\"frequency_penalty\":0.0,\"best_of\":1,\"model\":\"text-davinci-003\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/text-davinci-003/completions?api-version=2023-12-01-preview" - }, - "requiredScenarioState": "scenario-3-deployments-text-davinci-003-completions-3", - "response": { - "body": "{\"id\":\"cmpl-xxx\",\"object\":\"text_completion\",\"created\":1707253064,\"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\":\"f3d22bfb-13ae-41f1-ba1c-e162da7cf3ec\",\"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\":34,\"total_tokens\":44}}", - "headers": {}, - "status": 200 - }, - "scenarioName": "scenario-3-deployments-text-davinci-003-completions", - "uuid": "1296bcee-1e54-43b1-b4b3-4642dd8bd0a0" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-350fea53-3d73-4d59-b603-dba32fdc5af9.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-350fea53-3d73-4d59-b603-dba32fdc5af9.json deleted file mode 100644 index d2042ae323..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-350fea53-3d73-4d59-b603-dba32fdc5af9.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "350fea53-3d73-4d59-b603-dba32fdc5af9", - "insertionIndex": 37, - "name": "deployments_text-davinci-003_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"prompt\":[\" Generate a creative reason or excuse for the given event.\\n Be creative and be funny. Let your imagination run wild.\\n\\n Event: I am running late.\\n Excuse: I was being held ransom by giraffe gangsters.\\n\\n Event: I haven't been to the gym for a year\\n Excuse: I've been too busy training my pet dragon.\\n\\n Event: I missed the F1 final race\\n\"],\"max_tokens\":100,\"temperature\":0.4,\"top_p\":1.0,\"logit_bias\":{},\"user\":\"\",\"n\":1,\"presence_penalty\":0.0,\"frequency_penalty\":0.0,\"best_of\":1,\"model\":\"text-davinci-003\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/text-davinci-003/completions?api-version=2023-12-01-preview" - }, - "response": { - "body": "{\"id\":\"cmpl-xxx\",\"object\":\"text_completion\",\"created\":1707252975,\"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\":\"1ec9fb4c-eae2-44b4-9974-c87d452220ae\",\"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\":93,\"completion_tokens\":15,\"total_tokens\":108}}", - "headers": {}, - "status": 200 - }, - "uuid": "350fea53-3d73-4d59-b603-dba32fdc5af9" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-3ce79fbf-90ee-4575-aeb4-6f7d545d1db6.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-3ce79fbf-90ee-4575-aeb4-6f7d545d1db6.json deleted file mode 100644 index 8422dfec0e..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-3ce79fbf-90ee-4575-aeb4-6f7d545d1db6.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "3ce79fbf-90ee-4575-aeb4-6f7d545d1db6", - "insertionIndex": 32, - "name": "deployments_text-davinci-003_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"prompt\":[\"BEGIN CONTENT TO SUMMARIZE:\\nJane: I think we're almost there. Let me check.\\nJane: I have some bad news, we're only half way there.\\nJohn: Oh no, I'm not sure I can keep going. I'm getting tired.\\nJane: I'm getting tired too.\\nJohn: Maybe there is a large piece of text we can use to generate a long conversation.\\nJane: That's a good idea. Let me see if I can find one. Maybe Lorem Ipsum?\\nJohn: Yeah, that's a good idea.\\nJane: I found a Lorem Ipsum generator.\\nJane: Here's a 4096 character Lorem Ipsum text:\\nJane: Lorem ipsum dolor sit amet, con\\nJane: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod, nunc sit amet aliquam\\nJane: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod, nunc sit amet aliquam\\nJane: Darn, it's just repeating stuf now.\\nJohn: I think we're done.\\nJane: We're not though! We need like 1500 more characters.\\nJohn: Oh Cananda, our home and native land.\\nJane: True patriot love in all thy sons command.\\nJohn: With glowing hearts we see thee rise.\\nJane: The True North strong and free.\\nJohn: From far and wide, O Canada, we stand on guard for thee.\\nJane: God keep our land glorious and free.\\nJohn: O Canada, we stand on guard for thee.\\nJane: O Canada, we stand on guard for thee.\\nJane: That was fun, thank you. Let me check now.\\nJane: I think we need about 600 more characters.\\nJohn: Oh say can you see?\\nJane: By the dawn's early light.\\nJohn: What so proudly we hailed.\\nJane: At the twilight's last gleaming.\\nJohn: Whose broad stripes and bright stars.\\nJane: Through the perilous fight.\\nJohn: O'er the ramparts we watched.\\nJane: Were so gallantly streaming.\\nJohn: And the rockets' red glare.\\nJane: The bombs bursting in air.\\nJohn: Gave proof through the night.\\nJane: That our flag was still there.\\nJohn: Oh say does that star-spangled banner yet wave.\\nJane: O'er the land of the free.\\nJohn: And the home of the brave.\\nJane: Are you a Seattle Kraken Fan?\\nJohn: Yes, I am. I love going to the games.\\nJane: I'm a Seattle Kraken Fan too. Who is your favorite player?\\nJohn: I like watching all the players, but I think my favorite is Matty Beniers.\\nJane: Yeah, he's a great player. I like watching him too. I also like watching Jaden Schwartz.\\nJohn: Adam Larsson is another good one. The big cat!\\nJane: WE MADE IT! It's long enough. Thank you!\\nJohn: Can you automate generating long text next time?\\nJane: I will.\\nJohn: You're welcome. I'm glad we could help. Goodbye!\\nJane: Goodbye!\\n\\nEND CONTENT TO SUMMARIZE.\\n\\nSummarize the conversation in 'CONTENT TO SUMMARIZE', identifying main points of discussion and any conclusions that were reached.\\nDo not incorporate other general knowledge.\\nSummary is in plain text, in complete sentences, with no markup or tags.\\n\\nBEGIN SUMMARY:\\n\"],\"max_tokens\":1024,\"temperature\":0.1,\"top_p\":0.5,\"logit_bias\":{},\"user\":\"\",\"n\":1,\"presence_penalty\":0.0,\"frequency_penalty\":0.0,\"best_of\":1,\"model\":\"text-davinci-003\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/text-davinci-003/completions?api-version=2023-12-01-preview" - }, - "response": { - "body": "{\"id\":\"cmpl-xxx\",\"object\":\"text_completion\",\"created\":1707252982,\"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\":\"caf6e239-7150-4d70-b814-62cd93e7c525\",\"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\":791,\"completion_tokens\":48,\"total_tokens\":839}}", - "headers": {}, - "status": 200 - }, - "uuid": "3ce79fbf-90ee-4575-aeb4-6f7d545d1db6" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-3d48b3d9-5263-4d35-97dc-6db5b0335989.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-3d48b3d9-5263-4d35-97dc-6db5b0335989.json deleted file mode 100644 index a47a658d5d..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-3d48b3d9-5263-4d35-97dc-6db5b0335989.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "3d48b3d9-5263-4d35-97dc-6db5b0335989", - "insertionIndex": 30, - "name": "deployments_text-davinci-003_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"prompt\":[\"You are an action item extractor. You will be given chat history and need to make note of action items mentioned in the chat.\\nExtract action items from the content if there are any. If there are no action, return nothing. If a single field is missing, use an empty string.\\nReturn the action items in json.\\n\\nPossible statuses for action items are: Open, Closed, In Progress.\\n\\nEXAMPLE INPUT WITH ACTION ITEMS:\\n\\nJohn Doe said: \\\"I will record a demo for the new feature by Friday\\\"\\nI said: \\\"Great, thanks John. We may not use all of it but it's good to get it out there.\\\"\\n\\nEXAMPLE OUTPUT:\\n{\\n \\\"actionItems\\\": [\\n {\\n \\\"owner\\\": \\\"John Doe\\\",\\n \\\"actionItem\\\": \\\"Record a demo for the new feature\\\",\\n \\\"dueDate\\\": \\\"Friday\\\",\\n \\\"status\\\": \\\"Open\\\",\\n \\\"notes\\\": \\\"\\n }\\n ]\\n}\\n\\nEXAMPLE INPUT WITHOUT ACTION ITEMS:\\n\\nJohn Doe said: \\\"Hey I'm going to the store, do you need anything?\\\"\\nI said: \\\"No thanks, I'm good.\\\"\\n\\nEXAMPLE OUTPUT:\\n{\\n \\\"action_items\\\": []\\n}\\n\\nCONTENT STARTS HERE.\\n\\nJane: I think we're almost there. Let me check.\\nJane: I have some bad news, we're only half way there.\\nJohn: Oh no, I'm not sure I can keep going. I'm getting tired.\\nJane: I'm getting tired too.\\nJohn: Maybe there is a large piece of text we can use to generate a long conversation.\\nJane: That's a good idea. Let me see if I can find one. Maybe Lorem Ipsum?\\nJohn: Yeah, that's a good idea.\\nJane: I found a Lorem Ipsum generator.\\nJane: Here's a 4096 character Lorem Ipsum text:\\nJane: Lorem ipsum dolor sit amet, con\\nJane: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod, nunc sit amet aliquam\\nJane: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod, nunc sit amet aliquam\\nJane: Darn, it's just repeating stuf now.\\nJohn: I think we're done.\\nJane: We're not though! We need like 1500 more characters.\\nJohn: Oh Cananda, our home and native land.\\nJane: True patriot love in all thy sons command.\\nJohn: With glowing hearts we see thee rise.\\nJane: The True North strong and free.\\nJohn: From far and wide, O Canada, we stand on guard for thee.\\nJane: God keep our land glorious and free.\\nJohn: O Canada, we stand on guard for thee.\\nJane: O Canada, we stand on guard for thee.\\nJane: That was fun, thank you. Let me check now.\\nJane: I think we need about 600 more characters.\\nJohn: Oh say can you see?\\nJane: By the dawn's early light.\\nJohn: What so proudly we hailed.\\nJane: At the twilight's last gleaming.\\nJohn: Whose broad stripes and bright stars.\\nJane: Through the perilous fight.\\nJohn: O'er the ramparts we watched.\\nJane: Were so gallantly streaming.\\nJohn: And the rockets' red glare.\\nJane: The bombs bursting in air.\\nJohn: Gave proof through the night.\\nJane: That our flag was still there.\\nJohn: Oh say does that star-spangled banner yet wave.\\nJane: O'er the land of the free.\\nJohn: And the home of the brave.\\nJane: Are you a Seattle Kraken Fan?\\nJohn: Yes, I am. I love going to the games.\\nJane: I'm a Seattle Kraken Fan too. Who is your favorite player?\\nJohn: I like watching all the players, but I think my favorite is Matty Beniers.\\nJane: Yeah, he's a great player. I like watching him too. I also like watching Jaden Schwartz.\\nJohn: Adam Larsson is another good one. The big cat!\\nJane: WE MADE IT! It's long enough. Thank you!\\nJohn: Can you automate generating long text next time?\\nJane: I will.\\nJohn: You're welcome. I'm glad we could help. Goodbye!\\nJane: Goodbye!\\n\\nCONTENT STOPS HERE.\\n\\nOUTPUT:\\n\"],\"max_tokens\":1024,\"temperature\":0.1,\"top_p\":0.5,\"logit_bias\":{},\"user\":\"\",\"n\":1,\"presence_penalty\":0.0,\"frequency_penalty\":0.0,\"best_of\":1,\"model\":\"text-davinci-003\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/text-davinci-003/completions?api-version=2023-12-01-preview" - }, - "response": { - "body": "{\"id\":\"cmpl-xxx\",\"object\":\"text_completion\",\"created\":1707252987,\"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\":\"cab3c6e5-6681-48a0-8c56-3727299a890d\",\"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\":1018,\"completion_tokens\":62,\"total_tokens\":1080}}", - "headers": {}, - "status": 200 - }, - "uuid": "3d48b3d9-5263-4d35-97dc-6db5b0335989" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-544c72c2-de8a-407d-a319-b7c04a8c237e.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-544c72c2-de8a-407d-a319-b7c04a8c237e.json deleted file mode 100644 index 21d76e6f02..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-544c72c2-de8a-407d-a319-b7c04a8c237e.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "544c72c2-de8a-407d-a319-b7c04a8c237e", - "insertionIndex": 31, - "name": "deployments_text-davinci-003_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"prompt\":[\"You are an action item extractor. You will be given chat history and need to make note of action items mentioned in the chat.\\nExtract action items from the content if there are any. If there are no action, return nothing. If a single field is missing, use an empty string.\\nReturn the action items in json.\\n\\nPossible statuses for action items are: Open, Closed, In Progress.\\n\\nEXAMPLE INPUT WITH ACTION ITEMS:\\n\\nJohn Doe said: \\\"I will record a demo for the new feature by Friday\\\"\\nI said: \\\"Great, thanks John. We may not use all of it but it's good to get it out there.\\\"\\n\\nEXAMPLE OUTPUT:\\n{\\n \\\"actionItems\\\": [\\n {\\n \\\"owner\\\": \\\"John Doe\\\",\\n \\\"actionItem\\\": \\\"Record a demo for the new feature\\\",\\n \\\"dueDate\\\": \\\"Friday\\\",\\n \\\"status\\\": \\\"Open\\\",\\n \\\"notes\\\": \\\"\\n }\\n ]\\n}\\n\\nEXAMPLE INPUT WITHOUT ACTION ITEMS:\\n\\nJohn Doe said: \\\"Hey I'm going to the store, do you need anything?\\\"\\nI said: \\\"No thanks, I'm good.\\\"\\n\\nEXAMPLE OUTPUT:\\n{\\n \\\"action_items\\\": []\\n}\\n\\nCONTENT STARTS HERE.\\n\\nJohn: Hello, how are you?\\nJane: I'm fine, thanks. How are you?\\nJohn: I'm doing well, writing some example code.\\nJane: That's great! I'm writing some example code too.\\nJohn: What are you writing?\\nJane: I'm writing a chatbot.\\nJohn: That's cool. I'm writing a chatbot too.\\nJane: What language are you writing it in?\\nJohn: I'm writing it in C#.\\nJane: I'm writing it in Python.\\nJohn: That's cool. I need to learn Python.\\nJane: I need to learn C#.\\nJohn: Can I try out your chatbot?\\nJane: Sure, here's the link.\\nJohn: Thanks!\\nJane: You're welcome.\\nJane: Look at this poem my chatbot wrote:\\nJane: Roses are red\\nJane: Violets are blue\\nJane: I'm writing a chatbot\\nJane: What about you?\\nJohn: That's cool. Let me see if mine will write a poem, too.\\nJohn: Here's a poem my chatbot wrote:\\nJohn: The singularity of the universe is a mystery.\\nJohn: The universe is a mystery.\\nJohn: The universe is a mystery.\\nJohn: The universe is a mystery.\\nJohn: Looks like I need to improve mine, oh well.\\nJane: You might want to try using a different model.\\nJane: I'm using the GPT-3 model.\\nJohn: I'm using the GPT-2 model. That makes sense.\\nJohn: Here is a new poem after updating the model.\\nJohn: The universe is a mystery.\\nJohn: The universe is a mystery.\\nJohn: The universe is a mystery.\\nJohn: Yikes, it's really stuck isn't it. Would you help me debug my code?\\nJane: Sure, what's the problem?\\nJohn: I'm not sure. I think it's a bug in the code.\\nJane: I'll take a look.\\nJane: I think I found the problem.\\nJane: It looks like you're not passing the right parameters to the model.\\nJohn: Thanks for the help!\\nJane: I'm now writing a bot to summarize conversations. I want to make sure it works when the conversation is long.\\nJohn: So you need to keep talking with me to generate a long conversation?\\nJane: Yes, that's right.\\nJohn: Ok, I'll keep talking. What should we talk about?\\nJane: I don't know, what do you want to talk about?\\nJohn: I don't know, it's nice how CoPilot is doing most of the talking for us. But it definitely gets stuck sometimes.\\nJane: I agree, it's nice that CoPilot is doing most of the talking for us.\\nJane: But it definitely gets stuck sometimes.\\nJohn: Do you know how long it needs to be?\\nJane: I think the max length is 1024 tokens. Which is approximately 1024*4= 4096 characters.\\nJohn: That's a lot of characters.\\nJane: Yes, it is.\\nJohn: I'm not sure how much longer I can keep talking.\\n\\nCONTENT STOPS HERE.\\n\\nOUTPUT:\\n\"],\"max_tokens\":1024,\"temperature\":0.1,\"top_p\":0.5,\"logit_bias\":{},\"user\":\"\",\"n\":1,\"presence_penalty\":0.0,\"frequency_penalty\":0.0,\"best_of\":1,\"model\":\"text-davinci-003\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/text-davinci-003/completions?api-version=2023-12-01-preview" - }, - "response": { - "body": "{\"id\":\"cmpl-xxx\",\"object\":\"text_completion\",\"created\":1707252983,\"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\":\"ee5e62b0-d339-4171-b42a-664a5eb77685\",\"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\":998,\"completion_tokens\":167,\"total_tokens\":1165}}", - "headers": {}, - "status": 200 - }, - "uuid": "544c72c2-de8a-407d-a319-b7c04a8c237e" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-7441c9cd-22ef-41a0-8c0b-f050326ca99c.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-7441c9cd-22ef-41a0-8c0b-f050326ca99c.json deleted file mode 100644 index ea2b259780..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-7441c9cd-22ef-41a0-8c0b-f050326ca99c.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "id": "7441c9cd-22ef-41a0-8c0b-f050326ca99c", - "insertionIndex": 9, - "name": "deployments_text-davinci-003_completions", - "newScenarioState": "scenario-3-deployments-text-davinci-003-completions-2", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"prompt\":[\"Hello AI, what can you do for me?\"],\"max_tokens\":256,\"temperature\":1.0,\"top_p\":1.0,\"logit_bias\":{},\"user\":\"\",\"n\":1,\"presence_penalty\":0.0,\"frequency_penalty\":0.0,\"best_of\":1,\"model\":\"text-davinci-003\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/text-davinci-003/completions?api-version=2023-12-01-preview" - }, - "requiredScenarioState": "Started", - "response": { - "body": "{\"id\":\"cmpl-xxx\",\"object\":\"text_completion\",\"created\":1707253052,\"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\":\"50ea41ad-bd16-4241-bb54-c98e091dac99\",\"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\":35,\"total_tokens\":45}}", - "headers": {}, - "status": 200 - }, - "scenarioName": "scenario-3-deployments-text-davinci-003-completions", - "uuid": "7441c9cd-22ef-41a0-8c0b-f050326ca99c" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-7718fb6b-1cae-4420-8e34-126c14d00539.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-7718fb6b-1cae-4420-8e34-126c14d00539.json deleted file mode 100644 index 348670d755..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-7718fb6b-1cae-4420-8e34-126c14d00539.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "7718fb6b-1cae-4420-8e34-126c14d00539", - "insertionIndex": 29, - "name": "deployments_text-davinci-003_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"prompt\":[\"Analyze the following extract taken from a conversation transcript and extract key topics.\\n- Topics only worth remembering.\\n- Be brief. Short phrases.\\n- Can use broken English.\\n- Conciseness is very important.\\n- Topics can include names of memories you want to recall.\\n- NO LONG SENTENCES. SHORT PHRASES.\\n- Return in JSON\\n[Input]\\nMy name is Macbeth. I used to be King of Scotland, but I died. My wife's name is Lady Macbeth and we were married for 15 years. We had no children. Our beloved dog Toby McDuff was a famous hunter of rats in the forest.\\nMy tragic story was immortalized by Shakespeare in a play.\\n[Output]\\n{\\n \\\"topics\\\": [\\n \\\"Macbeth\\\",\\n \\\"King of Scotland\\\",\\n \\\"Lady Macbeth\\\",\\n \\\"Dog\\\",\\n \\\"Toby McDuff\\\",\\n \\\"Shakespeare\\\",\\n \\\"Play\\\",\\n \\\"Tragedy\\\"\\n ]\\n}\\n+++++\\n[Input]\\nJohn: Hello, how are you?\\nJane: I'm fine, thanks. How are you?\\nJohn: I'm doing well, writing some example code.\\nJane: That's great! I'm writing some example code too.\\nJohn: What are you writing?\\nJane: I'm writing a chatbot.\\nJohn: That's cool. I'm writing a chatbot too.\\nJane: What language are you writing it in?\\nJohn: I'm writing it in C#.\\nJane: I'm writing it in Python.\\nJohn: That's cool. I need to learn Python.\\nJane: I need to learn C#.\\nJohn: Can I try out your chatbot?\\nJane: Sure, here's the link.\\nJohn: Thanks!\\nJane: You're welcome.\\nJane: Look at this poem my chatbot wrote:\\nJane: Roses are red\\nJane: Violets are blue\\nJane: I'm writing a chatbot\\nJane: What about you?\\nJohn: That's cool. Let me see if mine will write a poem, too.\\nJohn: Here's a poem my chatbot wrote:\\nJohn: The singularity of the universe is a mystery.\\nJohn: The universe is a mystery.\\nJohn: The universe is a mystery.\\nJohn: The universe is a mystery.\\nJohn: Looks like I need to improve mine, oh well.\\nJane: You might want to try using a different model.\\nJane: I'm using the GPT-3 model.\\nJohn: I'm using the GPT-2 model. That makes sense.\\nJohn: Here is a new poem after updating the model.\\nJohn: The universe is a mystery.\\nJohn: The universe is a mystery.\\nJohn: The universe is a mystery.\\nJohn: Yikes, it's really stuck isn't it. Would you help me debug my code?\\nJane: Sure, what's the problem?\\nJohn: I'm not sure. I think it's a bug in the code.\\nJane: I'll take a look.\\nJane: I think I found the problem.\\nJane: It looks like you're not passing the right parameters to the model.\\nJohn: Thanks for the help!\\nJane: I'm now writing a bot to summarize conversations. I want to make sure it works when the conversation is long.\\nJohn: So you need to keep talking with me to generate a long conversation?\\nJane: Yes, that's right.\\nJohn: Ok, I'll keep talking. What should we talk about?\\nJane: I don't know, what do you want to talk about?\\nJohn: I don't know, it's nice how CoPilot is doing most of the talking for us. But it definitely gets stuck sometimes.\\nJane: I agree, it's nice that CoPilot is doing most of the talking for us.\\nJane: But it definitely gets stuck sometimes.\\nJohn: Do you know how long it needs to be?\\nJane: I think the max length is 1024 tokens. Which is approximately 1024*4= 4096 characters.\\nJohn: That's a lot of characters.\\nJane: Yes, it is.\\nJohn: I'm not sure how much longer I can keep talking.\\n[Output]\"],\"max_tokens\":1024,\"temperature\":0.1,\"top_p\":0.5,\"logit_bias\":{},\"user\":\"\",\"n\":1,\"presence_penalty\":0.0,\"frequency_penalty\":0.0,\"best_of\":1,\"model\":\"text-davinci-003\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/text-davinci-003/completions?api-version=2023-12-01-preview" - }, - "response": { - "body": "{\"id\":\"cmpl-xxx\",\"object\":\"text_completion\",\"created\":1707252988,\"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\":\"527e770d-c106-4b6d-8595-f584b0532d75\",\"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\":927,\"completion_tokens\":77,\"total_tokens\":1004}}", - "headers": {}, - "status": 200 - }, - "uuid": "7718fb6b-1cae-4420-8e34-126c14d00539" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-857195c1-97b9-4118-8c05-d25d0020f8e2.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-857195c1-97b9-4118-8c05-d25d0020f8e2.json deleted file mode 100644 index ae05b7c2f2..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-857195c1-97b9-4118-8c05-d25d0020f8e2.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "857195c1-97b9-4118-8c05-d25d0020f8e2", - "insertionIndex": 35, - "name": "deployments_text-davinci-003_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"prompt\":[\"Translate this date 1970-01-01 to French format\"],\"max_tokens\":100,\"temperature\":1.0,\"top_p\":1.0,\"logit_bias\":{},\"user\":\"\",\"n\":1,\"presence_penalty\":0.0,\"frequency_penalty\":0.0,\"best_of\":1,\"model\":\"text-davinci-003\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/text-davinci-003/completions?api-version=2023-12-01-preview" - }, - "response": { - "body": "{\"id\":\"cmpl-xxx\",\"object\":\"text_completion\",\"created\":1707252976,\"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\":\"5cfcf9bb-5adc-43ab-ac46-80009b0e3cf9\",\"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\":12,\"completion_tokens\":7,\"total_tokens\":19}}", - "headers": {}, - "status": 200 - }, - "uuid": "857195c1-97b9-4118-8c05-d25d0020f8e2" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-85f3675c-e404-4138-96c2-e49d4521e4f6.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-85f3675c-e404-4138-96c2-e49d4521e4f6.json deleted file mode 100644 index dec6a70872..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-85f3675c-e404-4138-96c2-e49d4521e4f6.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "85f3675c-e404-4138-96c2-e49d4521e4f6", - "insertionIndex": 36, - "name": "deployments_text-davinci-003_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"prompt\":[\" Generate a creative reason or excuse for the given event.\\n Be creative and be funny. Let your imagination run wild.\\n\\n Event: I am running late.\\n Excuse: I was being held ransom by giraffe gangsters.\\n\\n Event: I haven't been to the gym for a year\\n Excuse: I've been too busy training my pet dragon.\\n\\n Event: sorry I forgot your birthday\\n\"],\"max_tokens\":100,\"temperature\":0.4,\"top_p\":1.0,\"logit_bias\":{},\"user\":\"\",\"n\":1,\"presence_penalty\":0.0,\"frequency_penalty\":0.0,\"best_of\":1,\"model\":\"text-davinci-003\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/text-davinci-003/completions?api-version=2023-12-01-preview" - }, - "response": { - "body": "{\"id\":\"cmpl-xxx\",\"object\":\"text_completion\",\"created\":1707252976,\"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\":\"936e5f54-9693-4a66-bd9d-96a9fa72d314\",\"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\":91,\"completion_tokens\":14,\"total_tokens\":105}}", - "headers": {}, - "status": 200 - }, - "uuid": "85f3675c-e404-4138-96c2-e49d4521e4f6" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-990e9efb-2d61-424d-bbf6-a68e2d25552f.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-990e9efb-2d61-424d-bbf6-a68e2d25552f.json deleted file mode 100644 index 22d1bb82c9..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-990e9efb-2d61-424d-bbf6-a68e2d25552f.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "990e9efb-2d61-424d-bbf6-a68e2d25552f", - "insertionIndex": 34, - "name": "deployments_text-davinci-003_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"prompt\":[\"Today is: 2021-09-01\\nCurrent time is: 12:00:00\\n\\nAnswer to the following questions using JSON syntax, including the data used.\\n Is it morning, afternoon, evening, or night (morning/afternoon/evening/night)?\\n Is it weekend time (weekend/not weekend)?\\n\"],\"max_tokens\":100,\"temperature\":1.0,\"top_p\":1.0,\"logit_bias\":{},\"user\":\"\",\"n\":1,\"presence_penalty\":0.0,\"frequency_penalty\":0.0,\"best_of\":1,\"model\":\"text-davinci-003\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/text-davinci-003/completions?api-version=2023-12-01-preview" - }, - "response": { - "body": "{\"id\":\"cmpl-xxx\",\"object\":\"text_completion\",\"created\":1707252977,\"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\":\"c0c8de7b-5fdf-43ff-a261-380cbf4be59e\",\"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\":71,\"completion_tokens\":44,\"total_tokens\":115}}", - "headers": {}, - "status": 200 - }, - "uuid": "990e9efb-2d61-424d-bbf6-a68e2d25552f" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-a29ad1f1-2423-4dbf-a127-fd2c93998fcd.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-a29ad1f1-2423-4dbf-a127-fd2c93998fcd.json deleted file mode 100644 index ef8e9a60ab..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-a29ad1f1-2423-4dbf-a127-fd2c93998fcd.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "a29ad1f1-2423-4dbf-a127-fd2c93998fcd", - "insertionIndex": 28, - "name": "deployments_text-davinci-003_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"prompt\":[\"Analyze the following extract taken from a conversation transcript and extract key topics.\\n- Topics only worth remembering.\\n- Be brief. Short phrases.\\n- Can use broken English.\\n- Conciseness is very important.\\n- Topics can include names of memories you want to recall.\\n- NO LONG SENTENCES. SHORT PHRASES.\\n- Return in JSON\\n[Input]\\nMy name is Macbeth. I used to be King of Scotland, but I died. My wife's name is Lady Macbeth and we were married for 15 years. We had no children. Our beloved dog Toby McDuff was a famous hunter of rats in the forest.\\nMy tragic story was immortalized by Shakespeare in a play.\\n[Output]\\n{\\n \\\"topics\\\": [\\n \\\"Macbeth\\\",\\n \\\"King of Scotland\\\",\\n \\\"Lady Macbeth\\\",\\n \\\"Dog\\\",\\n \\\"Toby McDuff\\\",\\n \\\"Shakespeare\\\",\\n \\\"Play\\\",\\n \\\"Tragedy\\\"\\n ]\\n}\\n+++++\\n[Input]\\nJane: I think we're almost there. Let me check.\\nJane: I have some bad news, we're only half way there.\\nJohn: Oh no, I'm not sure I can keep going. I'm getting tired.\\nJane: I'm getting tired too.\\nJohn: Maybe there is a large piece of text we can use to generate a long conversation.\\nJane: That's a good idea. Let me see if I can find one. Maybe Lorem Ipsum?\\nJohn: Yeah, that's a good idea.\\nJane: I found a Lorem Ipsum generator.\\nJane: Here's a 4096 character Lorem Ipsum text:\\nJane: Lorem ipsum dolor sit amet, con\\nJane: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod, nunc sit amet aliquam\\nJane: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod, nunc sit amet aliquam\\nJane: Darn, it's just repeating stuf now.\\nJohn: I think we're done.\\nJane: We're not though! We need like 1500 more characters.\\nJohn: Oh Cananda, our home and native land.\\nJane: True patriot love in all thy sons command.\\nJohn: With glowing hearts we see thee rise.\\nJane: The True North strong and free.\\nJohn: From far and wide, O Canada, we stand on guard for thee.\\nJane: God keep our land glorious and free.\\nJohn: O Canada, we stand on guard for thee.\\nJane: O Canada, we stand on guard for thee.\\nJane: That was fun, thank you. Let me check now.\\nJane: I think we need about 600 more characters.\\nJohn: Oh say can you see?\\nJane: By the dawn's early light.\\nJohn: What so proudly we hailed.\\nJane: At the twilight's last gleaming.\\nJohn: Whose broad stripes and bright stars.\\nJane: Through the perilous fight.\\nJohn: O'er the ramparts we watched.\\nJane: Were so gallantly streaming.\\nJohn: And the rockets' red glare.\\nJane: The bombs bursting in air.\\nJohn: Gave proof through the night.\\nJane: That our flag was still there.\\nJohn: Oh say does that star-spangled banner yet wave.\\nJane: O'er the land of the free.\\nJohn: And the home of the brave.\\nJane: Are you a Seattle Kraken Fan?\\nJohn: Yes, I am. I love going to the games.\\nJane: I'm a Seattle Kraken Fan too. Who is your favorite player?\\nJohn: I like watching all the players, but I think my favorite is Matty Beniers.\\nJane: Yeah, he's a great player. I like watching him too. I also like watching Jaden Schwartz.\\nJohn: Adam Larsson is another good one. The big cat!\\nJane: WE MADE IT! It's long enough. Thank you!\\nJohn: Can you automate generating long text next time?\\nJane: I will.\\nJohn: You're welcome. I'm glad we could help. Goodbye!\\nJane: Goodbye!\\n[Output]\"],\"max_tokens\":1024,\"temperature\":0.1,\"top_p\":0.5,\"logit_bias\":{},\"user\":\"\",\"n\":1,\"presence_penalty\":0.0,\"frequency_penalty\":0.0,\"best_of\":1,\"model\":\"text-davinci-003\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/text-davinci-003/completions?api-version=2023-12-01-preview" - }, - "response": { - "body": "{\"id\":\"cmpl-xxx\",\"object\":\"text_completion\",\"created\":1707252990,\"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\":\"18733ff5-6af1-4bfc-98b9-a6e7cc1a5005\",\"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\":947,\"completion_tokens\":56,\"total_tokens\":1003}}", - "headers": {}, - "status": 200 - }, - "uuid": "a29ad1f1-2423-4dbf-a127-fd2c93998fcd" -} diff --git a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-fb3fd96e-de60-4e75-b551-493819766937.json b/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-fb3fd96e-de60-4e75-b551-493819766937.json deleted file mode 100644 index 73ef9f552e..0000000000 --- a/java/api-test/integration-tests/src/test/resources/wiremock/mappings/deployments_text-davinci-003_completions-fb3fd96e-de60-4e75-b551-493819766937.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "fb3fd96e-de60-4e75-b551-493819766937", - "insertionIndex": 33, - "name": "deployments_text-davinci-003_completions", - "persistent": true, - "request": { - "bodyPatterns": [ - { - "equalToJson": "{\"prompt\":[\"BEGIN CONTENT TO SUMMARIZE:\\nJohn: Hello, how are you?\\nJane: I'm fine, thanks. How are you?\\nJohn: I'm doing well, writing some example code.\\nJane: That's great! I'm writing some example code too.\\nJohn: What are you writing?\\nJane: I'm writing a chatbot.\\nJohn: That's cool. I'm writing a chatbot too.\\nJane: What language are you writing it in?\\nJohn: I'm writing it in C#.\\nJane: I'm writing it in Python.\\nJohn: That's cool. I need to learn Python.\\nJane: I need to learn C#.\\nJohn: Can I try out your chatbot?\\nJane: Sure, here's the link.\\nJohn: Thanks!\\nJane: You're welcome.\\nJane: Look at this poem my chatbot wrote:\\nJane: Roses are red\\nJane: Violets are blue\\nJane: I'm writing a chatbot\\nJane: What about you?\\nJohn: That's cool. Let me see if mine will write a poem, too.\\nJohn: Here's a poem my chatbot wrote:\\nJohn: The singularity of the universe is a mystery.\\nJohn: The universe is a mystery.\\nJohn: The universe is a mystery.\\nJohn: The universe is a mystery.\\nJohn: Looks like I need to improve mine, oh well.\\nJane: You might want to try using a different model.\\nJane: I'm using the GPT-3 model.\\nJohn: I'm using the GPT-2 model. That makes sense.\\nJohn: Here is a new poem after updating the model.\\nJohn: The universe is a mystery.\\nJohn: The universe is a mystery.\\nJohn: The universe is a mystery.\\nJohn: Yikes, it's really stuck isn't it. Would you help me debug my code?\\nJane: Sure, what's the problem?\\nJohn: I'm not sure. I think it's a bug in the code.\\nJane: I'll take a look.\\nJane: I think I found the problem.\\nJane: It looks like you're not passing the right parameters to the model.\\nJohn: Thanks for the help!\\nJane: I'm now writing a bot to summarize conversations. I want to make sure it works when the conversation is long.\\nJohn: So you need to keep talking with me to generate a long conversation?\\nJane: Yes, that's right.\\nJohn: Ok, I'll keep talking. What should we talk about?\\nJane: I don't know, what do you want to talk about?\\nJohn: I don't know, it's nice how CoPilot is doing most of the talking for us. But it definitely gets stuck sometimes.\\nJane: I agree, it's nice that CoPilot is doing most of the talking for us.\\nJane: But it definitely gets stuck sometimes.\\nJohn: Do you know how long it needs to be?\\nJane: I think the max length is 1024 tokens. Which is approximately 1024*4= 4096 characters.\\nJohn: That's a lot of characters.\\nJane: Yes, it is.\\nJohn: I'm not sure how much longer I can keep talking.\\n\\nEND CONTENT TO SUMMARIZE.\\n\\nSummarize the conversation in 'CONTENT TO SUMMARIZE', identifying main points of discussion and any conclusions that were reached.\\nDo not incorporate other general knowledge.\\nSummary is in plain text, in complete sentences, with no markup or tags.\\n\\nBEGIN SUMMARY:\\n\"],\"max_tokens\":1024,\"temperature\":0.1,\"top_p\":0.5,\"logit_bias\":{},\"user\":\"\",\"n\":1,\"presence_penalty\":0.0,\"frequency_penalty\":0.0,\"best_of\":1,\"model\":\"text-davinci-003\"}", - "ignoreArrayOrder": true, - "ignoreExtraElements": true - } - ], - "method": "POST", - "url": "//openai/deployments/text-davinci-003/completions?api-version=2023-12-01-preview" - }, - "response": { - "body": "{\"id\":\"cmpl-xxx\",\"object\":\"text_completion\",\"created\":1707252979,\"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\":\"daed202a-7933-40ce-941a-4f17954f3e8d\",\"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\":771,\"completion_tokens\":91,\"total_tokens\":862}}", - "headers": {}, - "status": 200 - }, - "uuid": "fb3fd96e-de60-4e75-b551-493819766937" -} diff --git a/java/samples/sample-code/src/main/java/com/microsoft/semantickernel/samples/syntaxexamples/java/FunctionsWithinPrompts_Example.java b/java/samples/sample-code/src/main/java/com/microsoft/semantickernel/samples/syntaxexamples/java/FunctionsWithinPrompts_Example.java new file mode 100644 index 0000000000..7436780e09 --- /dev/null +++ b/java/samples/sample-code/src/main/java/com/microsoft/semantickernel/samples/syntaxexamples/java/FunctionsWithinPrompts_Example.java @@ -0,0 +1,169 @@ +// Copyright (c) Microsoft. All rights reserved. +package com.microsoft.semantickernel.samples.syntaxexamples.java; + +import com.azure.ai.openai.OpenAIAsyncClient; +import com.azure.ai.openai.OpenAIClientBuilder; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.credential.KeyCredential; +import com.microsoft.semantickernel.Kernel; +import com.microsoft.semantickernel.exceptions.ConfigurationException; +import com.microsoft.semantickernel.orchestration.ToolCallBehavior; +import com.microsoft.semantickernel.plugin.KernelPlugin; +import com.microsoft.semantickernel.plugin.KernelPluginFactory; +import com.microsoft.semantickernel.samples.plugins.ConversationSummaryPlugin; +import com.microsoft.semantickernel.semanticfunctions.KernelFunctionArguments; +import com.microsoft.semantickernel.semanticfunctions.KernelFunctionFromPrompt; +import com.microsoft.semantickernel.services.chatcompletion.AuthorRole; +import com.microsoft.semantickernel.services.chatcompletion.ChatCompletionService; +import com.microsoft.semantickernel.services.chatcompletion.ChatHistory; +import com.microsoft.semantickernel.services.chatcompletion.ChatMessageContent; +import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; +import java.util.List; +import java.util.Scanner; +import java.util.stream.Collectors; + +public class FunctionsWithinPrompts_Example { + + private static final String CLIENT_KEY = System.getenv("CLIENT_KEY"); + private static final String AZURE_CLIENT_KEY = System.getenv("AZURE_CLIENT_KEY"); + + // Only required if AZURE_CLIENT_KEY is set + private static final String CLIENT_ENDPOINT = System.getenv("CLIENT_ENDPOINT"); + private static final String MODEL_ID = System.getenv() + .getOrDefault("MODEL_ID", "gpt-35-turbo-2"); + + public static InputStream INPUT = System.in; + + public static void main(String[] args) throws ConfigurationException, IOException { + + OpenAIAsyncClient client; + + if (AZURE_CLIENT_KEY != null) { + client = new OpenAIClientBuilder() + .credential(new AzureKeyCredential(AZURE_CLIENT_KEY)) + .endpoint(CLIENT_ENDPOINT) + .buildAsyncClient(); + } else { + client = new OpenAIClientBuilder() + .credential(new KeyCredential(CLIENT_KEY)) + .buildAsyncClient(); + } + + ChatCompletionService chatCompletionService = ChatCompletionService.builder() + .withOpenAIAsyncClient(client) + .withModelId(MODEL_ID) + .build(); + + KernelPlugin plugin = KernelPluginFactory.createFromObject( + new ConversationSummaryPlugin(), "ConversationSummaryPlugin"); + + Kernel kernel = Kernel.builder() + .withAIService(ChatCompletionService.class, chatCompletionService) + .withPlugin(plugin) + .build(); + + List choices = Arrays.asList("ContinueConversation", "EndConversation"); + + // Create few-shot examples + List fewShotExamples = Arrays.asList( + new ChatHistory( + Arrays.asList( + new ChatMessageContent(AuthorRole.USER, + "Can you send a very quick approval to the marketing team?"), + new ChatMessageContent(AuthorRole.SYSTEM, "Intent:"), + new ChatMessageContent(AuthorRole.ASSISTANT, + "ContinueConversation"))), + + new ChatHistory( + Arrays.asList( + new ChatMessageContent(AuthorRole.USER, + "Can you send the full update to the marketing team?"), + new ChatMessageContent(AuthorRole.SYSTEM, "Intent:"), + new ChatMessageContent(AuthorRole.ASSISTANT, "EndConversation")))); + + // Create handlebars template for intent + // + var getIntent = KernelFunctionFromPrompt + .createFromPrompt( + """ + Instructions: What is the intent of this request? + Do not explain the reasoning, just reply back with the intent. If you are unsure, reply with {{choices.[0]}}. + Choices: {{choices}}. + + {{#each fewShotExamples}} + {{#each this}} + {{content}} + {{/each}} + {{/each}} + + {{ConversationSummaryPlugin-SummarizeConversation history}} + + {{request}} + Intent: + """ + .stripIndent()) + .withTemplateFormat("handlebars") + .build(); + // + + // Create a Semantic Kernel template for chat + // + var chat = KernelFunctionFromPrompt.createFromPrompt(""" + {{ConversationSummaryPlugin.SummarizeConversation $history}} + User: {{$request}} + Assistant: + """.stripIndent()).build(); + // + + Scanner scanner = new Scanner(INPUT); + + ChatHistory history = new ChatHistory(); + // Start the chat loop + while (true) { + // Get user input + System.out.println("User > "); + var request = scanner.nextLine(); + + // Invoke handlebars prompt + var intent = kernel.invokeAsync(getIntent) + .withArguments( + KernelFunctionArguments.builder() + .withVariable("request", request) + .withVariable("choices", choices) + .withVariable("history", history) + .withVariable("fewShotExamples", fewShotExamples) + .build()) + .withToolCallBehavior( + new ToolCallBehavior() + .enableKernelFunctions(true) + .enableFunction(plugin.get("SummarizeConversation"), true)) + .block(); + + // End the chat if the intent is "Stop" + if ("EndConversation".equalsIgnoreCase(intent.getResult())) { + break; + } + + // Get chat response + var chatResult = kernel.invokeAsync(chat) + .withArguments( + KernelFunctionArguments.builder() + .withVariable("request", request) + .withVariable("history", history.getMessages().stream() + .map(it -> it.getAuthorRole() + ": " + it.getContent()) + .collect(Collectors.joining("\n"))) + .build()) + .block(); + + String message = chatResult.getResult(); + System.out.println("Assistant: " + message); + System.out.println(); + + // Append to history + history.addUserMessage(request); + history.addAssistantMessage(message); + } + } +} diff --git a/java/semantickernel-api/src/main/java/com/microsoft/semantickernel/contextvariables/ContextVariableTypes.java b/java/semantickernel-api/src/main/java/com/microsoft/semantickernel/contextvariables/ContextVariableTypes.java index 4b4ed52bc1..fde972f416 100644 --- a/java/semantickernel-api/src/main/java/com/microsoft/semantickernel/contextvariables/ContextVariableTypes.java +++ b/java/semantickernel-api/src/main/java/com/microsoft/semantickernel/contextvariables/ContextVariableTypes.java @@ -4,6 +4,7 @@ package com.microsoft.semantickernel.contextvariables; import com.microsoft.semantickernel.contextvariables.converters.BooleanVariableContextVariableTypeConverter; import com.microsoft.semantickernel.contextvariables.converters.CharacterVariableContextVariableTypeConverter; import com.microsoft.semantickernel.contextvariables.converters.ChatHistoryVariableContextVariableTypeConverter; +import com.microsoft.semantickernel.contextvariables.converters.CollectionVariableContextVariableTypeConverter; import com.microsoft.semantickernel.contextvariables.converters.CompletionUsageContextVariableTypeConverter; import com.microsoft.semantickernel.contextvariables.converters.DateTimeContextVariableTypeConverter; import com.microsoft.semantickernel.contextvariables.converters.InstantContextVariableTypeConverter; @@ -32,6 +33,7 @@ public class ContextVariableTypes { new ChatHistoryVariableContextVariableTypeConverter(), new TextContentVariableContextVariableTypeConverter(), new StringVariableContextVariableTypeConverter(), + new CollectionVariableContextVariableTypeConverter(), new VoidVariableContextVariableTypeConverter(), new ContextVariableTypeConverter<>(void.class, s -> null, s -> null, s -> null), new DateTimeContextVariableTypeConverter(), diff --git a/java/semantickernel-api/src/main/java/com/microsoft/semantickernel/contextvariables/converters/CollectionVariableContextVariableTypeConverter.java b/java/semantickernel-api/src/main/java/com/microsoft/semantickernel/contextvariables/converters/CollectionVariableContextVariableTypeConverter.java new file mode 100644 index 0000000000..38d3eb0b53 --- /dev/null +++ b/java/semantickernel-api/src/main/java/com/microsoft/semantickernel/contextvariables/converters/CollectionVariableContextVariableTypeConverter.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft. All rights reserved. +package com.microsoft.semantickernel.contextvariables.converters; + +import static com.microsoft.semantickernel.contextvariables.ContextVariableTypes.convert; + +import com.microsoft.semantickernel.contextvariables.ContextVariable; +import com.microsoft.semantickernel.contextvariables.ContextVariableTypeConverter; +import com.microsoft.semantickernel.contextvariables.ContextVariableTypes; +import java.util.Collection; +import java.util.stream.Collectors; + +/** + * A {@link ContextVariableTypeConverter} for {@code java.util.Collection} variables. Use + * {@code ContextVariableTypes.getGlobalVariableTypeForClass(String.class)} to get an instance of + * this class. + * + * @see ContextVariableTypes#getGlobalVariableTypeForClass(Class) + */ +public class CollectionVariableContextVariableTypeConverter extends + ContextVariableTypeConverter { + + /** + * Creates a new instance of the {@link CollectionVariableContextVariableTypeConverter} class. + */ + public CollectionVariableContextVariableTypeConverter() { + super( + Collection.class, + s -> convert(s, Collection.class), + CollectionVariableContextVariableTypeConverter::getString, + s -> { + throw new UnsupportedOperationException(); + }); + } + + private static String getString(Collection c) { + return c.stream() + .map(t -> { + if (t instanceof ContextVariable) { + return ((ContextVariable) t).toPromptString(); + } else { + return t.toString(); + } + }) + .collect(Collectors.joining(",")); + } +} diff --git a/java/semantickernel-api/src/main/java/com/microsoft/semantickernel/orchestration/ToolCallBehavior.java b/java/semantickernel-api/src/main/java/com/microsoft/semantickernel/orchestration/ToolCallBehavior.java index f6709cb532..0cb6d75ef2 100644 --- a/java/semantickernel-api/src/main/java/com/microsoft/semantickernel/orchestration/ToolCallBehavior.java +++ b/java/semantickernel-api/src/main/java/com/microsoft/semantickernel/orchestration/ToolCallBehavior.java @@ -42,7 +42,7 @@ public class ToolCallBehavior { enabledFunctions.addAll(toolCallBehavior.enabledFunctions); } - static String getKey(@Nullable String pluginName, String functionName) { + public static String formFullFunctionName(@Nullable String pluginName, String functionName) { if (pluginName == null) { pluginName = ""; } @@ -109,7 +109,7 @@ public class ToolCallBehavior { */ public ToolCallBehavior enableFunction(KernelFunction function, boolean enable) { if (function != null) { - String key = getKey(function.getPluginName(), function.getName()); + String key = formFullFunctionName(function.getPluginName(), function.getName()); if (enable) { enabledFunctions.add(key); } else { @@ -165,7 +165,7 @@ public class ToolCallBehavior { * @return Whether the function is enabled. */ public boolean functionEnabled(@Nullable String pluginName, String functionName) { - String key = getKey(pluginName, functionName); + String key = formFullFunctionName(pluginName, functionName); return enabledFunctions.contains(key); } diff --git a/java/semantickernel-api/src/main/java/com/microsoft/semantickernel/templateengine/handlebars/HandlebarsPromptTemplate.java b/java/semantickernel-api/src/main/java/com/microsoft/semantickernel/templateengine/handlebars/HandlebarsPromptTemplate.java index ec6b5aa4a3..48951c5ae7 100644 --- a/java/semantickernel-api/src/main/java/com/microsoft/semantickernel/templateengine/handlebars/HandlebarsPromptTemplate.java +++ b/java/semantickernel-api/src/main/java/com/microsoft/semantickernel/templateengine/handlebars/HandlebarsPromptTemplate.java @@ -3,16 +3,19 @@ package com.microsoft.semantickernel.templateengine.handlebars; import com.github.jknack.handlebars.Context; import com.github.jknack.handlebars.Handlebars; +import com.github.jknack.handlebars.Helper; import com.github.jknack.handlebars.Options; import com.github.jknack.handlebars.ValueResolver; import com.microsoft.semantickernel.Kernel; import com.microsoft.semantickernel.contextvariables.ContextVariable; +import com.microsoft.semantickernel.contextvariables.ContextVariableType; +import com.microsoft.semantickernel.contextvariables.ContextVariableTypes; import com.microsoft.semantickernel.exceptions.SKException; import com.microsoft.semantickernel.orchestration.InvocationContext; +import com.microsoft.semantickernel.orchestration.ToolCallBehavior; import com.microsoft.semantickernel.plugin.KernelPlugin; import com.microsoft.semantickernel.semanticfunctions.KernelFunction; import com.microsoft.semantickernel.semanticfunctions.KernelFunctionArguments; -import com.microsoft.semantickernel.semanticfunctions.KernelParameterMetadata; import com.microsoft.semantickernel.semanticfunctions.PromptTemplate; import com.microsoft.semantickernel.semanticfunctions.PromptTemplateConfig; import com.microsoft.semantickernel.services.chatcompletion.ChatHistory; @@ -20,7 +23,6 @@ import com.microsoft.semantickernel.services.chatcompletion.ChatMessageContent; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.IOException; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -61,6 +63,7 @@ public class HandlebarsPromptTemplate implements PromptTemplate { String.format("No prompt template was provided for the prompt %s.", promptTemplate.getName()))); } + HandleBarsPromptTemplateHandler handler = new HandleBarsPromptTemplateHandler(kernel, template); @@ -106,34 +109,6 @@ public class HandlebarsPromptTemplate implements PromptTemplate { } } - private static class KernelPluginResolver implements ValueResolver { - - @Override - public Object resolve(Object context, String name) { - if (context instanceof KernelFunction) { - KernelFunction function = (KernelFunction) context; - if ("pluginname".equalsIgnoreCase(name)) { - if (function.getPluginName() != null) { - return function.getPluginName(); - } - } else if ("name".equalsIgnoreCase(name)) { - return function.getName(); - } - } - return UNRESOLVED; - } - - @Override - public Object resolve(Object context) { - return UNRESOLVED; - } - - @Override - public Set> propertySet(Object context) { - return new HashSet<>(); - } - } - private static class ContextVariableResolver implements ValueResolver { @Override @@ -183,48 +158,20 @@ public class HandlebarsPromptTemplate implements PromptTemplate { private final Handlebars handlebars; @SuppressFBWarnings("CT_CONSTRUCTOR_THROW") // Think this is a false positive - public HandleBarsPromptTemplateHandler(Kernel kernel, String template) { + public HandleBarsPromptTemplateHandler( + Kernel kernel, + String template) { this.template = template; this.handlebars = new Handlebars(); this.handlebars .registerHelper("message", HandleBarsPromptTemplateHandler::handleMessage) - .registerHelper("each", HandleBarsPromptTemplateHandler::handleEach) - .registerHelper("functions", (context, options) -> handleFunctions(kernel, options)) - .registerHelper("function", - (context, options) -> handleFunction((KernelFunction) context)); + .registerHelper("each", HandleBarsPromptTemplateHandler::handleEach); + + addFunctionHelpers(kernel, this.handlebars); + // TODO: 1.0 Add more helpers } - private static Handlebars.SafeString handleFunction(KernelFunction context) { - KernelFunction function = context; - String pluginName = function.getPluginName(); - String functionName = function.getName(); - String description = function.getDescription(); - StringBuilder sb = new StringBuilder( - String.format( - "", - pluginName, functionName, description)); - List> parameters = function.getMetadata().getParameters(); - parameters.forEach(p -> { - sb.append(String.format( - "", - p.getName(), p.getDescription(), p.getDefaultValue(), p.isRequired(), - p.getType())); - }); - sb.append(""); - return new Handlebars.SafeString(sb.toString()); - } - - private static Handlebars.SafeString handleFunctions(Kernel kernel, Options options) - throws IOException { - StringBuilder sb = new StringBuilder(""); - Collection plugins = kernel.getPlugins(); - sb.append(options.fn(plugins)); - sb.append(""); - - return new Handlebars.SafeString(sb.toString()); - } - private static CharSequence handleEach(Object context, Options options) throws IOException { if (context instanceof ChatHistory) { @@ -247,6 +194,8 @@ public class HandlebarsPromptTemplate implements PromptTemplate { KernelFunction function = functions.next(); sb.append(options.fn(function)); } + } else { + sb.append(options.fn(element)); } } return new Handlebars.SafeString(sb.toString()); @@ -282,7 +231,6 @@ public class HandlebarsPromptTemplate implements PromptTemplate { try { ArrayList resolvers = new ArrayList<>(); resolvers.add(new MessageResolver()); - resolvers.add(new KernelPluginResolver()); resolvers.add(new ContextVariableResolver()); // resolvers.addAll(ValueResolver.defaultValueResolvers()); @@ -299,4 +247,44 @@ public class HandlebarsPromptTemplate implements PromptTemplate { } } } + + @SuppressWarnings("StringSplitter") + private static void addFunctionHelpers(Kernel kernel, Handlebars handlebars) { + kernel + .getPlugins() + .forEach(plugin -> { + plugin + .iterator() + .forEachRemaining(kernelFunction -> { + String functionName = kernelFunction.getName(); + String pluginName = plugin.getName(); + handlebars.registerHelper( + ToolCallBehavior.formFullFunctionName(pluginName, functionName), + functionInvokeHelper(kernel, kernelFunction)); + }); + + }); + } + + private static Helper functionInvokeHelper(Kernel kernel, + KernelFunction kernelFunction) { + return (context, options) -> { + + ContextVariableType converter = ContextVariableTypes + .getGlobalVariableTypeForClass( + context.getClass()); + + String promptString = converter.getConverter().toPromptString(context); + + // TODO Figure out if possible to do async render + return kernelFunction + .invokeAsync(kernel) + .withArguments( + KernelFunctionArguments.builder() + .withInput(promptString) + .build()) + .block() + .getResult(); + }; + } }