{"id":4127,"date":"2025-02-05T12:00:53","date_gmt":"2025-02-05T20:00:53","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/semantic-kernel\/?p=4127"},"modified":"2025-02-05T12:02:19","modified_gmt":"2025-02-05T20:02:19","slug":"guest-blog-let-your-copilot-declarative-agent-think-deep-with-deepseek-r1","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/agent-framework\/guest-blog-let-your-copilot-declarative-agent-think-deep-with-deepseek-r1\/","title":{"rendered":"Guest Blog: Let your Copilot Declarative Agent think deep with DeepSeek-R1"},"content":{"rendered":"<p>Today we&#8217;d like to feature a guest author on our Semantic Kernel blog, Mahmoud Hassan, a Microsoft Valuable Professional (MVP) focused on AI. We&#8217;ll turn it over to him to dive into his work below.<\/p>\n<p>&nbsp;<\/p>\n<p>In recent days, there has been significant attention in the AI community regarding DeepSeek-R1 and its capabilities.<\/p>\n<p>Many people are playing with it. For instance, <a href=\"https:\/\/www.linkedin.com\/in\/fabiangwilliams\/\">Fabian Williams<\/a> yesterday shared his experiment here: <a href=\"https:\/\/lnkd.in\/dgZ8hjgB\">https:\/\/lnkd.in\/dgZ8hjgB<\/a> of running it locally. I thought, maybe today is my turn!<\/p>\n<p>However, I also thought it is an excellent opportunity to show a plugin design pattern I previously shared with you \u201cThe Intelligent Plugin Design Pattern\u201d<\/p>\n<p>\u2728 The Intelligent Plugin Design Pattern\nA 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).<\/p>\n<p>\ud83d\udd17 More information here: <a href=\"https:\/\/lnkd.in\/dSBTzh2y\">https:\/\/lnkd.in\/dSBTzh2y<\/a><\/p>\n<p>\ud83d\udd25 The Think Deep Declarative Agent with DeepSeek-R1\nTo summarize, I created a simple declarative agent with one action, &#8220;Think Deep Action&#8221;, which connects via Dev Tunnel to my local workstation and call the &#8220;Think Deep API&#8221; powered by Semantic Kernel to access Ollama&#8217;s local deployment of DeepSeek-R1.<\/p>\n<h3><strong>The Agent Architecture:<\/strong><\/h3>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2025\/02\/Think-Deep-Agent.png\"><img decoding=\"async\" class=\"alignnone wp-image-4130 size-full\" src=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2025\/02\/Think-Deep-Agent.png\" alt=\"Image Think Deep Agent\" width=\"1280\" height=\"720\" srcset=\"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/02\/Think-Deep-Agent.png 1280w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/02\/Think-Deep-Agent-300x169.png 300w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/02\/Think-Deep-Agent-1024x576.png 1024w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/02\/Think-Deep-Agent-768x432.png 768w\" sizes=\"(max-width: 1280px) 100vw, 1280px\" \/><\/a><\/p>\n<h3>The Semantic Kernel Code:<\/h3>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">using var ollamaClient = new OllamaApiClient(\r\n            uriString: \"http:\/\/localhost:11434\",\r\n            defaultModel: \"deepseek-r1:1.5b\");\r\nvar chatService = ollamaClient.AsChatCompletionService();\r\nChatMessageContent replyMessage = await chatService.GetChatMessageContentAsync(userQuery);\r\nreturn replyMessage.ToString();<\/code><\/pre>\n<p>\u2757I also tested another architecture for hosting the DeepSeek-R1 on Azure AI Foundry (Available since <strong>Jan 29, 2025<\/strong>). Just 3 lines of code, and we&#8217;re in the cloud. I \u2764\ufe0f <a href=\"https:\/\/www.linkedin.com\/search\/results\/all\/?keywords=%23semantickernel&amp;origin=HASH_TAG_FROM_FEED\">#SemanticKernel<\/a> &amp; <a href=\"https:\/\/www.linkedin.com\/search\/results\/all\/?keywords=%23azureaifoundry&amp;origin=HASH_TAG_FROM_FEED\">#AzureAIFoundry<\/a> <a href=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2025\/02\/Think-Deep-Agent-v2.png\"><img decoding=\"async\" class=\"alignnone wp-image-4129 size-full\" src=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2025\/02\/Think-Deep-Agent-v2.png\" alt=\"Image Think Deep Agent v2\" width=\"1280\" height=\"720\" srcset=\"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/02\/Think-Deep-Agent-v2.png 1280w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/02\/Think-Deep-Agent-v2-300x169.png 300w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/02\/Think-Deep-Agent-v2-1024x576.png 1024w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/02\/Think-Deep-Agent-v2-768x432.png 768w\" sizes=\"(max-width: 1280px) 100vw, 1280px\" \/><\/a><\/p>\n<h3>The Semantic Kernel Code:<\/h3>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">var azureAIchatService = new ChatCompletionsClient(\r\n                endpoint: new Uri(\"https:\/\/DeepSeek-R1-ochnw.eastus.models.ai.azure.com\"),\r\n                credential: new Azure.AzureKeyCredential(\"&lt;Add Key&gt;\"))\r\n            .AsChatClient(\"DeepSeek-R1\")\r\n            .AsChatCompletionService();\r\nChatMessageContent replyMessage = await azureAIchatService.GetChatMessageContentAsync(userQuery);\r\nreturn replyMessage.ToString();\r\n<\/code><\/pre>\n<p>\ud83d\udca1[Bonus] The API plugin function states (Reasoning &amp; responding)\nThe API plugin Function states is a hidden gem of the API plugin:\n\u2728 The Reasoning instructions let you control the orchestrator&#8217;s actions when calling your function.\n\u2728 The Responding instructions control how the orchestrator processes your function response and presents it to the user.<\/p>\n<p>Documentation Link: <a href=\"https:\/\/learn.microsoft.com\/en-us\/microsoft-365-copilot\/extensibility\/api-plugin-manifest-2.2\">API plugin manifest schema 2.2 for Microsoft 365 Copilot<\/a><\/p>\n<p>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 &lt;think \/&gt; section of DeepSeek-R1.<\/p>\n<p><iframe title=\"Embedded post\" src=\"https:\/\/www.linkedin.com\/embed\/feed\/update\/urn:li:ugcPost:7290467444203163648\" width=\"504\" height=\"1570\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>From the Semantic Kernel team, we want to thank Mahmoud for being our guest author today and sharing out his amazing work!<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today we&#8217;d like to feature a guest author on our Semantic Kernel blog, Mahmoud Hassan, a Microsoft Valuable Professional (MVP) focused on AI. We&#8217;ll turn it over to him to dive into his work below. &nbsp; In recent days, there has been significant attention in the AI community regarding DeepSeek-R1 and its capabilities. Many people [&hellip;]<\/p>\n","protected":false},"author":149071,"featured_media":2302,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[48,63,9],"class_list":["post-4127","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-semantic-kernel","tag-ai","tag-microsoft-semantic-kernel","tag-semantic-kernel"],"acf":[],"blog_post_summary":"<p>Today we&#8217;d like to feature a guest author on our Semantic Kernel blog, Mahmoud Hassan, a Microsoft Valuable Professional (MVP) focused on AI. We&#8217;ll turn it over to him to dive into his work below. &nbsp; In recent days, there has been significant attention in the AI community regarding DeepSeek-R1 and its capabilities. Many people [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/4127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/users\/149071"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/comments?post=4127"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/4127\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media\/2302"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media?parent=4127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/categories?post=4127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/tags?post=4127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}