From c5c85c462fd3a73e9f85695251f37cca9dbfae8a Mon Sep 17 00:00:00 2001 From: Milder Hernandez Date: Tue, 14 May 2024 06:04:28 -0500 Subject: [PATCH] Java: Add chat resources for learn docs (#6243) ### 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: --- .../SerializingPrompts.java | 2 +- .../Plugins/Prompts/Chat/config.json | 33 +++++++++++++++ .../Plugins/Prompts/Chat/skprompt.txt | 3 ++ .../Plugins/Prompts/getIntent.prompt.yaml | 42 +++++++++++++++++++ 4 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 java/samples/semantickernel-learn-resources/src/main/resources/Plugins/Prompts/Chat/config.json create mode 100644 java/samples/semantickernel-learn-resources/src/main/resources/Plugins/Prompts/Chat/skprompt.txt create mode 100644 java/samples/semantickernel-learn-resources/src/main/resources/Plugins/Prompts/getIntent.prompt.yaml diff --git a/java/samples/semantickernel-learn-resources/src/main/java/com/microsoft/semantickernel/samples/documentationexamples/SerializingPrompts.java b/java/samples/semantickernel-learn-resources/src/main/java/com/microsoft/semantickernel/samples/documentationexamples/SerializingPrompts.java index a8b2a5f80f..38f18f04f0 100644 --- a/java/samples/semantickernel-learn-resources/src/main/java/com/microsoft/semantickernel/samples/documentationexamples/SerializingPrompts.java +++ b/java/samples/semantickernel-learn-resources/src/main/java/com/microsoft/semantickernel/samples/documentationexamples/SerializingPrompts.java @@ -39,7 +39,7 @@ public class SerializingPrompts { private static final String MODEL_ID = System.getenv() .getOrDefault("MODEL_ID", "gpt-3.5-turbo"); - private static final String PLUGINS_DIR = "java/samples/semantickernel-syntax-examples/src/main/resources/Plugins"; + private static final String PLUGINS_DIR = "java/samples/semantickernel-learn-resources/src/main/resources/Plugins"; public static void main(String[] args) throws IOException { System.out.println("======== Serializing Prompts ========"); diff --git a/java/samples/semantickernel-learn-resources/src/main/resources/Plugins/Prompts/Chat/config.json b/java/samples/semantickernel-learn-resources/src/main/resources/Plugins/Prompts/Chat/config.json new file mode 100644 index 0000000000..93e812d184 --- /dev/null +++ b/java/samples/semantickernel-learn-resources/src/main/resources/Plugins/Prompts/Chat/config.json @@ -0,0 +1,33 @@ +{ + "schema": 1, + "type": "completion", + "description": "Creates a chat response to the user", + "execution_settings": { + "default": { + "max_tokens": 1000, + "temperature": 0 + }, + "gpt-3.5-turbo": { + "model_id": "gpt-3.5-turbo-0613", + "max_tokens": 4000, + "temperature": 0.1 + }, + "gpt-4": { + "model_id": "gpt-4-1106-preview", + "max_tokens": 8000, + "temperature": 0.3 + } + }, + "input_variables": [ + { + "name": "request", + "description": "The user's request.", + "required": true + }, + { + "name": "history", + "description": "The history of the conversation.", + "required": true + } + ] +} \ No newline at end of file diff --git a/java/samples/semantickernel-learn-resources/src/main/resources/Plugins/Prompts/Chat/skprompt.txt b/java/samples/semantickernel-learn-resources/src/main/resources/Plugins/Prompts/Chat/skprompt.txt new file mode 100644 index 0000000000..82ae0242ca --- /dev/null +++ b/java/samples/semantickernel-learn-resources/src/main/resources/Plugins/Prompts/Chat/skprompt.txt @@ -0,0 +1,3 @@ +{{ConversationSummaryPlugin.SummarizeConversation $history}} +User: {{$request}} +Assistant: \ No newline at end of file diff --git a/java/samples/semantickernel-learn-resources/src/main/resources/Plugins/Prompts/getIntent.prompt.yaml b/java/samples/semantickernel-learn-resources/src/main/resources/Plugins/Prompts/getIntent.prompt.yaml new file mode 100644 index 0000000000..3fa1dfbc55 --- /dev/null +++ b/java/samples/semantickernel-learn-resources/src/main/resources/Plugins/Prompts/getIntent.prompt.yaml @@ -0,0 +1,42 @@ +name: getIntent +description: Gets the intent of the user. +template: | + 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}} + + Summary of conversation so far: + {{ConversationSummaryPlugin-SummarizeConversation history}} + + + {{request}} + Intent: +template_format: handlebars +input_variables: + - name: choices + description: The choices for the AI to choose from + default: ContinueConversation, EndConversation + - name: fewShotExamples + description: Few shot examples for the AI to learn from + is_required: true + - name: request + description: The user's request + is_required: true +execution_settings: + default: + max_tokens: 10 + temperature: 0 + gpt-3.5-turbo: + model_id: gpt-35-turbo-2 + max_tokens: 10 + temperature: 0.2 + gpt-4: + model_id: gpt-4-1106-preview + max_tokens: 10 + temperature: 0.2