mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 02:19:06 +00:00
Java: use id instead of range in markdown (#5614)
Updates to documentationexamples to add xml tags for referencing in Microsoft learn markdown
This commit is contained in:
+8
-2
@@ -42,21 +42,27 @@ public class AIServices {
|
||||
System.out.println("No client key found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// <CreateChatCompletionService>
|
||||
ChatCompletionService chatCompletionService = ChatCompletionService.builder()
|
||||
.withModelId(CHAT_MODEL_ID)
|
||||
.withOpenAIAsyncClient(client)
|
||||
.build();
|
||||
|
||||
// </CreateChatCompletionService>
|
||||
|
||||
// <CreateTextGenerationService>
|
||||
TextGenerationService textGenerationService = TextGenerationService.builder()
|
||||
.withModelId(TEXT_MODEL_ID)
|
||||
.withOpenAIAsyncClient(client)
|
||||
.build();
|
||||
// </CreateTextGenerationService>
|
||||
|
||||
// <CreateKernel>
|
||||
Kernel kernel = Kernel.builder()
|
||||
.withAIService(ChatCompletionService.class, chatCompletionService)
|
||||
.withAIService(TextGenerationService.class, textGenerationService)
|
||||
.build();
|
||||
// </CreateKernel>
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -46,15 +46,20 @@ public class ConfiguringPrompts {
|
||||
return;
|
||||
}
|
||||
|
||||
// <CreateChatCompletionService>
|
||||
ChatCompletionService chatCompletionService = ChatCompletionService.builder()
|
||||
.withModelId(CHAT_MODEL_ID)
|
||||
.withOpenAIAsyncClient(client)
|
||||
.build();
|
||||
// </CreateChatCompletionService>
|
||||
|
||||
// <CreateKernel>
|
||||
Kernel kernel = Kernel.builder()
|
||||
.withAIService(ChatCompletionService.class, chatCompletionService)
|
||||
.build();
|
||||
// </CreateKernel>
|
||||
|
||||
// <CreateFromPrompt
|
||||
KernelFunction<String> chat = KernelFunction.<String>createFromPrompt(
|
||||
PromptTemplateConfig.builder()
|
||||
.withName("Chat")
|
||||
@@ -91,5 +96,6 @@ public class ConfiguringPrompts {
|
||||
})
|
||||
.build())
|
||||
.build();
|
||||
// <CreateFromPrompt
|
||||
}
|
||||
}
|
||||
|
||||
+15
-2
@@ -1,6 +1,9 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
package com.microsoft.semantickernel.samples.documentationexamples;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.azure.ai.openai.OpenAIAsyncClient;
|
||||
import com.azure.ai.openai.OpenAIClientBuilder;
|
||||
import com.azure.core.credential.AzureKeyCredential;
|
||||
@@ -16,8 +19,6 @@ import com.microsoft.semantickernel.semanticfunctions.KernelFunctionArguments;
|
||||
import com.microsoft.semantickernel.services.chatcompletion.AuthorRole;
|
||||
import com.microsoft.semantickernel.services.chatcompletion.ChatCompletionService;
|
||||
import com.microsoft.semantickernel.services.chatcompletion.ChatHistory;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class FunctionsWithinPrompts {
|
||||
|
||||
@@ -52,18 +53,24 @@ public class FunctionsWithinPrompts {
|
||||
return;
|
||||
}
|
||||
|
||||
// <CreateChatCompletionService>
|
||||
ChatCompletionService chatCompletionService = ChatCompletionService.builder()
|
||||
.withModelId(MODEL_ID)
|
||||
.withOpenAIAsyncClient(client)
|
||||
.build();
|
||||
// </CreateChatCompletionService>
|
||||
|
||||
// <CreatePluginFromObject>
|
||||
KernelPlugin plugin = KernelPluginFactory.createFromObject(
|
||||
new ConversationSummaryPlugin(), "ConversationSummaryPlugin");
|
||||
// </CreatePluginFromObject>
|
||||
|
||||
// <CreateKernel>
|
||||
Kernel kernel = Kernel.builder()
|
||||
.withAIService(ChatCompletionService.class, chatCompletionService)
|
||||
.withPlugin(plugin)
|
||||
.build();
|
||||
// </CreateKernel>
|
||||
|
||||
List<String> choices = Arrays.asList("ContinueConversation", "EndConversation");
|
||||
|
||||
@@ -88,6 +95,7 @@ public class FunctionsWithinPrompts {
|
||||
});
|
||||
|
||||
// Create handlebars template for intent
|
||||
// <IntentFunction>
|
||||
KernelFunction<String> getIntent = KernelFunction.<String>createFromPrompt(
|
||||
"""
|
||||
<message role="system">Instructions: What is the intent of this request?
|
||||
@@ -107,8 +115,10 @@ public class FunctionsWithinPrompts {
|
||||
""")
|
||||
.withTemplateFormat("handlebars")
|
||||
.build();
|
||||
// </IntentFunction>
|
||||
|
||||
// Create a Semantic Kernel template for chat
|
||||
// <CreateFunctionFromPrompt>
|
||||
KernelFunction<String> chat = KernelFunction.<String>createFromPrompt(
|
||||
"""
|
||||
{{ConversationSummaryPlugin.SummarizeConversation $history}}
|
||||
@@ -116,11 +126,13 @@ public class FunctionsWithinPrompts {
|
||||
Assistant:
|
||||
""")
|
||||
.build();
|
||||
// </CreateFunctionFromPrompt>
|
||||
|
||||
// Create chat history
|
||||
ChatHistory history = new ChatHistory();
|
||||
|
||||
// Start the chat loop
|
||||
// <ChatLoop>
|
||||
while (true) {
|
||||
// Get user input
|
||||
System.console().printf("User > ");
|
||||
@@ -162,6 +174,7 @@ public class FunctionsWithinPrompts {
|
||||
history.addUserMessage(request);
|
||||
history.addAssistantMessage(message);
|
||||
}
|
||||
// </ChatLoop>
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user