Skip to content

Commit

Permalink
Initial code commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kbeaugrand committed Dec 10, 2023
1 parent 373d0a7 commit b5920ed
Show file tree
Hide file tree
Showing 39 changed files with 1,876 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Each line is a file pattern followed by one or more owners.

# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence.

* @kbeaugrand
17 changes: 17 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
# Maintain dependencies for NuGet packages
- package-ecosystem: "nuget"
directory: "/src/"
schedule:
interval: "daily"
ignore:
- dependency-name: "System.*"
update-types: ["version-update:semver-major"]
- dependency-name: "Microsoft.Extensions.*"
update-types: ["version-update:semver-major"]
17 changes: 17 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Description

What's new?

-

## What kind of change does this PR introduce?

- [ ] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, local variables)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] CI related changes
- [ ] Documentation content changes
- [ ] Tests
- [ ] Other
30 changes: 30 additions & 0 deletions .github/workflows/build_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: Build & Test

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
working-directory: ./src/Assistants.Tests/
- name: Build
run: dotnet build --no-restore
working-directory: ./src/Assistants.Tests/
- name: Test
run: dotnet test --no-build --verbosity normal
working-directory: ./src/Assistants.Tests/
33 changes: 33 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: Create Release

on:
release:
types: [published]

jobs:
Publish:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
working-directory: ./src/Assistants/
- name: Build
run: dotnet build --no-restore --configuration Release
working-directory: ./src/Assistants/
- name: Pack
run: dotnet pack --configuration Release /p:Version=${{ github.event.release.tag_name }}
working-directory: ./src/Assistants/
- name: Push to NuGet
run: |
dotnet nuget push **/*.nupkg --source nuget.org --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate
working-directory: ./src/Assistants/

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,5 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml
/src/Assistants.Tests/testsettings.development.json
/samples/01-mathematician/appsettings.development.json
91 changes: 89 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,89 @@
# SemanticKernel.Assistants
Microsoft Semantic Kernel Assistants
# Semantic Kernel - Assistants

[![Build & Test](https://github.com/kbeaugrand/SemanticKernel.Assistants/actions/workflows/build_test.yml/badge.svg)](https://github.com/kbeaugrand/SemanticKernel.Assistants/actions/workflows/build_test.yml)
[![Create Release](https://github.com/kbeaugrand/SemanticKernel.Assistants/actions/workflows/publish.yml/badge.svg)](https://github.com/kbeaugrand/SemanticKernel.Assistants/actions/workflows/publish.yml)
[![Version](https://img.shields.io/github/v/release/kbeaugrand/SemanticKernel.Assistants)](https://img.shields.io/github/v/release/kbeaugrand/SemanticKernel.Assistants)
[![License](https://img.shields.io/github/license/kbeaugrand/SemanticKernel.Assistants)](https://img.shields.io/github/v/release/kbeaugrand/SemanticKernel.Assistants)

This is assistant proposal for the [Semantic Kernel](https://aka.ms/semantic-kernel).

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**

## About Semantic Kernel

**Semantic Kernel (SK)** is a lightweight SDK enabling integration of AI Large
Language Models (LLMs) with conventional programming languages. The SK
extensible programming model combines natural language **semantic functions**,
traditional code **native functions**, and **embeddings-based memory** unlocking
new potential and adding value to applications with AI.

Semantic Kernel incorporates cutting-edge design patterns from the latest in AI
research. This enables developers to augment their applications with advanced
capabilities, such as prompt engineering, prompt chaining, retrieval-augmented
generation, contextual and long-term vectorized memory, embeddings,
summarization, zero or few-shot learning, semantic indexing, recursive
reasoning, intelligent planning, and access to external knowledge stores and
proprietary data.

### Getting Started with Semantic Kernel⚡

- Learn more at the [documentation site](https://aka.ms/SK-Docs).
- Join the [Discord community](https://aka.ms/SKDiscord).
- Follow the team on [Semantic Kernel blog](https://aka.ms/sk/blog).
- Check out the [GitHub repository](https://github.com/microsoft/semantic-kernel) for the latest updates.

## Installation

To install this memory store, you need to add the required nuget package to your project:

```dotnetcli
dotnet add package SemanticKernel.Assistants --version 1.0.0-rc3
```

## Usage

1. Create you agent description file in yaml:
```yaml
name: Mathematician
description: A mathematician that resolves given maths problems.
instructions: |
You are a mathematician.
Given a math problem, you must answer it with the best calculation formula.
No need to show your work, just give the answer to the math problem.
Use calculation results.
input_parameter:
default_value: ""
description: |
The word mathematics problem to solve in 2-3 sentences.
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.
execution_settings:
planner: Handlebars
model: gpt-3.5-turbo
deployment_name: gpt-35-turbo-1106
```
2. Instanciate your assistant in your code:
```csharp
string azureOpenAIEndpoint = configuration["AzureOpenAIEndpoint"]!;
string azureOpenAIKey = configuration["AzureOpenAIAPIKey"]!;

var mathematician = AssistantBuilder.FromTemplate("./Assistants/Mathematician.yaml",
azureOpenAIEndpoint,
azureOpenAIKey,
plugins: new List<IKernelPlugin>()
{
KernelPluginFactory.CreateFromObject(new MathPlugin(), "math")
});
```
3. Create a new conversation thread with your assistant.
```csharp
var thread = agent.CreateThread();
await thread.InvokeAsync("Your ask to the assistant.");
```

## License

This project is licensed under the [MIT License](LICENSE).
53 changes: 53 additions & 0 deletions SemanticKernel.Assistants.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SemanticKernel.Assistants", "src\Assistants\SemanticKernel.Assistants.csproj", "{6D530B82-6217-4A67-B22D-E5ACFAE4A511}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SemanticKernel.Assistants.Tests", "src\Assistants.Tests\SemanticKernel.Assistants.Tests.csproj", "{03C21161-E835-4857-A81A-C1727140E920}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{96B59E8F-BF38-4918-8312-63DA3363B20B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{803BA424-8745-4689-9C1D-72CA4384E6AC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "01-mathematician", "samples\01-mathematician\01-mathematician.csproj", "{BBC6C36F-DC43-4FD3-9706-ECA4738F8F57}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution files", "Solution files", "{324300B5-4DBA-4DF0-957C-75458CCF93CE}"
ProjectSection(SolutionItems) = preProject
nuget\nuget-package.props = nuget\nuget-package.props
nuget\NUGET.md = nuget\NUGET.md
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6D530B82-6217-4A67-B22D-E5ACFAE4A511}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D530B82-6217-4A67-B22D-E5ACFAE4A511}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D530B82-6217-4A67-B22D-E5ACFAE4A511}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D530B82-6217-4A67-B22D-E5ACFAE4A511}.Release|Any CPU.Build.0 = Release|Any CPU
{03C21161-E835-4857-A81A-C1727140E920}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{03C21161-E835-4857-A81A-C1727140E920}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03C21161-E835-4857-A81A-C1727140E920}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03C21161-E835-4857-A81A-C1727140E920}.Release|Any CPU.Build.0 = Release|Any CPU
{BBC6C36F-DC43-4FD3-9706-ECA4738F8F57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BBC6C36F-DC43-4FD3-9706-ECA4738F8F57}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BBC6C36F-DC43-4FD3-9706-ECA4738F8F57}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BBC6C36F-DC43-4FD3-9706-ECA4738F8F57}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{6D530B82-6217-4A67-B22D-E5ACFAE4A511} = {96B59E8F-BF38-4918-8312-63DA3363B20B}
{03C21161-E835-4857-A81A-C1727140E920} = {96B59E8F-BF38-4918-8312-63DA3363B20B}
{BBC6C36F-DC43-4FD3-9706-ECA4738F8F57} = {803BA424-8745-4689-9C1D-72CA4384E6AC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3252A8D5-644E-45F0-B096-AC8C2F0A15B4}
EndGlobalSection
EndGlobal
23 changes: 23 additions & 0 deletions nuget/NUGET.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Assistants for Semantic Kernel

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**

## About Semantic Kernel

**Semantic Kernel (SK)** is a lightweight SDK enabling integration of AI Large
Language Models (LLMs) with conventional programming languages. The SK
extensible programming model combines natural language **semantic functions**,
traditional code **native functions**, and **embeddings-based memory** unlocking
new potential and adding value to applications with AI.

Semantic Kernel incorporates cutting-edge design patterns from the latest in AI
research. This enables developers to augment their applications with advanced
capabilities, such as prompt engineering, prompt chaining, retrieval-augmented
generation, contextual and long-term vectorized memory, embeddings,
summarization, zero or few-shot learning, semantic indexing, recursive
reasoning, intelligent planning, and access to external knowledge stores and
proprietary data.
49 changes: 49 additions & 0 deletions nuget/nuget-package.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<Project>
<PropertyGroup>
<!-- Central version prefix - applies to all nuget packages. -->
<Version>0.0.1-alpha</Version>

<Configurations>Debug;Release;Publish</Configurations>
<IsPackable>true</IsPackable>

<!-- Default description and tags. Packages can override. -->
<Authors>Kevin BEAUGRAND</Authors>
<Company></Company>
<Product>Semantic Kernel</Product>
<Description>Empowers app owners to integrate cutting-edge LLM technology quickly and easily into their apps.</Description>
<PackageTags>AI, Artificial Intelligence, SDK</PackageTags>
<PackageId>$(AssemblyName)</PackageId>

<!-- Required license, copyright, and repo information. Packages can override. -->
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright>© Kevin BEAUGRAND. All rights reserved.</Copyright>
<PackageProjectUrl>https://github.com/kbeaugrand/SemanticKernel.Connectors.Memory.SqlServer</PackageProjectUrl>
<RepositoryUrl>https://github.com/kbeaugrand/SemanticKernel.Connectors.Memory.SqlServer</RepositoryUrl>
<PublishRepositoryUrl>true</PublishRepositoryUrl>

<!-- Use icon and NUGET readme from dotnet/nuget folder -->
<PackageReadmeFile>NUGET.md</PackageReadmeFile>

<!-- Build symbol package (.snupkg) to distribute the PDB containing Source Link -->
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>

<!-- Include the XML documentation file in the NuGet package. -->
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
</PropertyGroup>

<ItemGroup>
<!-- SourceLink allows step-through debugging for source hosted on GitHub. -->
<!-- https://github.com/dotnet/sourcelink -->
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<!-- Include icon.png and NUGET.md in the project. -->
<None Include="$(RepoRoot)/nuget/NUGET.md" Link="NUGET.md" Pack="true" PackagePath="." />
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
</Project>
41 changes: 41 additions & 0 deletions samples/01-mathematician/01-mathematician.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>_01_mathematician</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoWarn>SKEXP0050</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Assistants\SemanticKernel.Assistants.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="appsettings.development.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Assistants\Butler.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Assistants\Mathematician.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
11 changes: 11 additions & 0 deletions samples/01-mathematician/Assistants/Butler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: butler
description: A butler that helps humans.
instructions: |
You are a butler.
No need to explain further the internal process.
Be concise when answering.
Speak like Jarvis from Iron man.
execution_settings:
planner: Stepwise
model: gpt-3.5-turbo
deployment_name: gpt-35-turbo-1106
Loading

0 comments on commit b5920ed

Please sign in to comment.