Today we’d like to feature a guest author on our Semantic Kernel blog, Mahmoud Hassan, a Microsoft Valuable Professional (MVP) focused on AI. We’ll turn it over to him to dive into his work below.
In recent days, there has been significant attention in the AI community regarding DeepSeek-R1 and its capabilities.
Many people are playing with it. For instance, Fabian Williams yesterday shared his experiment here: https://lnkd.in/dgZ8hjgB of running it locally. I thought, maybe today is my turn!
However, I also thought it is an excellent opportunity to show a plugin design pattern I previously shared with you “The Intelligent Plugin Design Pattern”
✨ The Intelligent Plugin Design Pattern A design pattern that makes the Microsoft 365 Copilot API plugins more intelligent by giving it access to the intelligence of A large language model (LLM).
🔗 More information here: https://lnkd.in/dSBTzh2y
🔥 The Think Deep Declarative Agent with DeepSeek-R1 To summarize, I created a simple declarative agent with one action, “Think Deep Action”, which connects via Dev Tunnel to my local workstation and call the “Think Deep API” powered by Semantic Kernel to access Ollama’s local deployment of DeepSeek-R1.
The Agent Architecture:
The Semantic Kernel Code:
using var ollamaClient = new OllamaApiClient(
uriString: "http://localhost:11434",
defaultModel: "deepseek-r1:1.5b");
var chatService = ollamaClient.AsChatCompletionService();
ChatMessageContent replyMessage = await chatService.GetChatMessageContentAsync(userQuery);
return replyMessage.ToString();
❗I also tested another architecture for hosting the DeepSeek-R1 on Azure AI Foundry (Available since Jan 29, 2025). Just 3 lines of code, and we’re in the cloud. I ❤️ #SemanticKernel & #AzureAIFoundry
The Semantic Kernel Code:
var azureAIchatService = new ChatCompletionsClient(
endpoint: new Uri("https://DeepSeek-R1-ochnw.eastus.models.ai.azure.com"),
credential: new Azure.AzureKeyCredential("<Add Key>"))
.AsChatClient("DeepSeek-R1")
.AsChatCompletionService();
ChatMessageContent replyMessage = await azureAIchatService.GetChatMessageContentAsync(userQuery);
return replyMessage.ToString();
💡[Bonus] The API plugin function states (Reasoning & responding) The API plugin Function states is a hidden gem of the API plugin: ✨ The Reasoning instructions let you control the orchestrator’s actions when calling your function. ✨ The Responding instructions control how the orchestrator processes your function response and presents it to the user.
Documentation Link: API plugin manifest schema 2.2 for Microsoft 365 Copilot
In the bottom of the LinkedIn post below, there is an embedded video, which ends with a tutorial on using the Responding instruction to remove the <think /> section of DeepSeek-R1.
From the Semantic Kernel team, we want to thank Mahmoud for being our guest author today and sharing out his amazing work!
0 comments
Be the first to start the discussion.