{"id":21062306,"url":"https://github.com/kbeaugrand/semantickernel.assistants","last_synced_at":"2025-04-12T21:19:23.196Z","repository":{"id":211719673,"uuid":"729748696","full_name":"kbeaugrand/SemanticKernel.Assistants","owner":"kbeaugrand","description":"Microsoft Semantic Kernel Assistants This enables the usage of assistants for the Semantic Kernel.  It provides different scenarios for the usage of assistants such as:  Assistant with Semantic Kernel plugins Multi-Assistant conversation","archived":false,"fork":false,"pushed_at":"2025-02-26T09:11:43.000Z","size":644,"stargazers_count":101,"open_issues_count":1,"forks_count":10,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-26T09:35:47.321Z","etag":null,"topics":["assistants","llm","semantic-kernel"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kbeaugrand.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-10T08:20:51.000Z","updated_at":"2025-02-26T09:11:44.000Z","dependencies_parsed_at":"2024-01-03T11:28:29.340Z","dependency_job_id":"e5781072-ad5f-49db-b04c-f2beb877be39","html_url":"https://github.com/kbeaugrand/SemanticKernel.Assistants","commit_stats":null,"previous_names":["kbeaugrand/semantickernel.assistants"],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbeaugrand%2FSemanticKernel.Assistants","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbeaugrand%2FSemanticKernel.Assistants/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbeaugrand%2FSemanticKernel.Assistants/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbeaugrand%2FSemanticKernel.Assistants/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kbeaugrand","download_url":"https://codeload.github.com/kbeaugrand/SemanticKernel.Assistants/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631966,"owners_count":21136599,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assistants","llm","semantic-kernel"],"created_at":"2024-11-19T17:38:20.490Z","updated_at":"2025-04-12T21:19:23.177Z","avatar_url":"https://github.com/kbeaugrand.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# Semantic Kernel - Assistants\n\n[![Build \u0026 Test](https://github.com/kbeaugrand/SemanticKernel.Assistants/actions/workflows/build_tests.yml/badge.svg)](https://github.com/kbeaugrand/SemanticKernel.Assistants/actions/workflows/build_test.yml)\n[![Create Release](https://github.com/kbeaugrand/SemanticKernel.Assistants/actions/workflows/publish.yml/badge.svg)](https://github.com/kbeaugrand/SemanticKernel.Assistants/actions/workflows/publish.yml)\n[![Version](https://img.shields.io/github/v/release/kbeaugrand/SemanticKernel.Assistants)](https://img.shields.io/github/v/release/kbeaugrand/SemanticKernel.Assistants)\n[![License](https://img.shields.io/github/license/kbeaugrand/SemanticKernel.Assistants)](https://img.shields.io/github/v/release/kbeaugrand/SemanticKernel.Assistants)\n\nThis is assistant proposal for the [Semantic Kernel](https://aka.ms/semantic-kernel).\n\nThis enables the usage of assistants for the Semantic Kernel **without relying on OpenAI Assistant APIs**.\nIt runs locally planners and plugins for the assistants.\n\nIt provides different scenarios for the usage of assistants such as:\n- **Assistant with Semantic Kernel plugins**\n- **Multi-Assistant conversation**\n- **AutoGen conversation** (see [AutoGen](#autogen) for more details)\n\nAs the assistants are using the Semantic Kernel, you can use your own model for the assistants and host them locally (see: [Bring you own model](#bring-you-own-model-) for more details.).\n\n## About Semantic Kernel\n\n**Semantic Kernel (SK)** is a lightweight SDK enabling integration of AI Large\nLanguage Models (LLMs) with conventional programming languages. The SK\nextensible programming model combines natural language **semantic functions**,\ntraditional code **native functions**, and **embeddings-based memory** unlocking\nnew potential and adding value to applications with AI.\n\nSemantic Kernel incorporates cutting-edge design patterns from the latest in AI\nresearch. This enables developers to augment their applications with advanced\ncapabilities, such as prompt engineering, prompt chaining, retrieval-augmented\ngeneration, contextual and long-term vectorized memory, embeddings,\nsummarization, zero or few-shot learning, semantic indexing, recursive\nreasoning, intelligent planning, and access to external knowledge stores and\nproprietary data.\n\n### Getting Started with Semantic Kernel⚡\n\n- Learn more at the [documentation site](https://aka.ms/SK-Docs).\n- Join the [Discord community](https://aka.ms/SKDiscord).\n- Follow the team on [Semantic Kernel blog](https://aka.ms/sk/blog).\n- Check out the [GitHub repository](https://github.com/microsoft/semantic-kernel) for the latest updates.\n\n## Installation\n\nTo install the assistant Framework, you need to add the required nuget package to your project:\n\n```dotnetcli\ndotnet add package SemanticKernel.Assistants\n```\n\n## Usage\n\n1. Create you agent description file in yaml: \n    ```yaml\n    name: Mathematician\n    description: A mathematician that resolves given maths problems.\n    instructions: |\n      You are a mathematician.\n      Given a math problem, you must answer it with the best calculation formula.\n      No need to show your work, just give the answer to the math problem.\n      Use calculation results.\n    input_parameters: \n      - name: input\n        is_required: True\n        default_value: \"\"\n        description: |\n           The word financial problem to solve in 2-3 sentences.\n           Make sure to include all the input variables needed along with their values and units otherwise the math function will not be able to solve it.\n    execution_settings:\n      planner: Handlebars\n      prompt_settings: \n        temperature: 0.0\n        top_p: 1\n        max_tokens: 2000\n    ```\n2. Instanciate your assistant in your code: \n   ```csharp\n    string azureOpenAIChatCompletionDeployment = configuration[\"AzureOpenAIDeploymentName\"]!;\n    string azureOpenAIEndpoint = configuration[\"AzureOpenAIEndpoint\"]!;\n    string azureOpenAIKey = configuration[\"AzureOpenAIAPIKey\"]!;\n \n    var mathKernel = Kernel.CreateBuilder()\n                                        .AddAzureOpenAIChatCompletion(azureOpenAIChatCompletionDeployment, azureOpenAIEndpoint, azureOpenAIKey)\n                                        .Build();\n\n    mathKernel.ImportPluginFromObject(new MathPlugin());\n\n    var mathematician = AssistantBuilder.FromTemplate(\"./Assistants/Mathematician.yaml\")\n                                        .WithKernel(mathKernel)\n                                        .Build();\n   ```\n3. Create a new conversation thread with your assistant.\n   ```csharp\n   var thread = mathematician.CreateThread();\n   await thread.InvokeAsync(\"Your ask to the assistant.\");\n   ```\n\n## Bring you own model ?\n\nAs the assistants are using the Semantic Kernel, you can use your own model for the assistants.\nFor example, you can use the Ollama model for the assistants.\n\nThis could be achieved by using the [Ollama connector for the Semantic Kernel](https://github.com/BLaZeKiLL/Codeblaze.SemanticKernel): \n\n```csharp\nusing Codeblaze.SemanticKernel.Connectors.Ollama;\n\nstring ollamaEndpoint = configuration[\"OllamaEndpoint\"]!;\n\nvar butlerKernel = Kernel.CreateBuilder()\n                    .AddOllamaChatCompletion(\"phi:latest\", ollamaEndpoint)\n                    .Build();\n\nassistant = AssistantBuilder.FromTemplate(\"./Assistants/Butler.yaml\")\n        .WithKernel(butlerKernel)\n        .Build();\n```\n\n## AutoGen\n\nAutoGen is based on the approach proposed by [Microsoft's Auto-Gen](https://github.com/microsoft/autogen).\n\nIt is realized through 2 assistants working together to code and execute the code needed to respond to user requests.\n\n- __AssistantAgent (NL 2 Code)__: this agent takes charge of the user's request and produces Python code to respond to the user's request.\n- __CodeInterpreter__: This agent takes as input the various parameters required to execute the Python code supplied by the AssistantAgent. \n\n\u003e Note: \n\u003e Through its native plugin, the CodeInterpreter interacts with Docker to start a container, install the necessary dependencies and execute the Python code in this container, then returns the result.\n\n```csharp\nstring azureOpenAIEndpoint = configuration[\"AzureOpenAIEndpoint\"]!;\nstring azureOpenAIGPT4DeploymentName = configuration[\"AzureOpenAIGPT4DeploymentName\"]!;\nstring azureOpenAIGPT35DeploymentName = configuration[\"AzureOpenAIGPT35DeploymentName\"]!;\nstring azureOpenAIKey = configuration[\"AzureOpenAIAPIKey\"]!;\nstring ollamaEndpoint = configuration[\"OllamaEndpoint\"]!;\n\nvar codeInterpretionOptions = new CodeInterpretionPluginOptions();\nconfiguration!.Bind(\"CodeInterpreter\", codeInterpretionOptions);\n\nIAssistant CreateCodeInterpreter(CodeInterpretionPluginOptions codeInterpretionOptions, string azureOpenAIDeploymentName, string azureOpenAIEndpoint, string azureOpenAIKey)\n{\n    var kernel = Kernel.CreateBuilder()\n                        .AddAzureOpenAIChatCompletion(azureOpenAIDeploymentName, azureOpenAIEndpoint, azureOpenAIKey)\n                        .Build();\n\n    kernel.ImportPluginFromObject(new CodeInterpretionPlugin(codeInterpretionOptions, loggerFactory), \"code\");\n\n    return CodeInterpreterBuilder.CreateBuilder()\n                                .WithKernel(kernel)\n                                .Build();\n}\n\nIAssistant CreateAssistantAgent()\n{\n    var codeInterpretionOptions = new CodeInterpretionPluginOptions();\n    configuration!.Bind(\"CodeInterpreter\", codeInterpretionOptions);\n\n    var butlerKernel = Kernel.CreateBuilder()\n                            .AddAzureOpenAIChatCompletion(azureOpenAIGPT4DeploymentName, azureOpenAIEndpoint, azureOpenAIKey)\n                            .Build();\n\n    butlerKernel.ImportPluginFromObject(new FileAccessPlugin(codeInterpretionOptions.OutputFilePath, loggerFactory), \"file\");\n    butlerKernel.ImportPluginFromAssistant(CreateCodeInterpreter(codeInterpretionOptions, azureOpenAIGPT35DeploymentName, azureOpenAIEndpoint, azureOpenAIKey));\n\n    assistant = AssistantAgentBuilder.CreateBuilder()\n        .WithKernel(butlerKernel)\n        .Build();\n}\n\nvar thread = CreateAssistantAgent().CreateThread();\n\nvar answer = await thread.InvokeAsync(prompt).ConfigureAwait(true);\n```\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkbeaugrand%2Fsemantickernel.assistants","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkbeaugrand%2Fsemantickernel.assistants","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkbeaugrand%2Fsemantickernel.assistants/lists"}