Skip to content

.Net: Added dotnet starter project for Process Framework #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ dotnet_diagnostic.CA2007.severity = none # Do not directly await a Task
dotnet_diagnostic.CA2225.severity = none # Operator overloads have named alternates
dotnet_diagnostic.CA2227.severity = none # Change to be read-only by removing the property setter
dotnet_diagnostic.CA2253.severity = none # Named placeholders in the logging message template should not be comprised of only numeric characters
dotnet_diagnostic.CA1515.severity = none # Because an application's API isn't typically referenced from outside the assembly, types can be made internal
dotnet_diagnostic.CA1861.severity = none # Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array
dotnet_diagnostic.VSTHRD111.severity = none # Use .ConfigureAwait(bool) is hidden by default, set to none to prevent IDE from changing on autosave

# Diagnostics elevated as warnings
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
env:
NUGET_AUTH_TOKEN: ${{ secrets.GPR_READ_TOKEN }}

Expand Down
4 changes: 1 addition & 3 deletions sk-csharp-azure-functions/ExecuteFunctionEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,11 @@ public async Task<HttpResponseData> ExecuteFunctionAsync(
}

var skill = this._kernel.ImportSemanticSkillFromDirectory(skillsDirectory, skillName);
if (!skill.ContainsKey(functionName))
if (!skill.TryGetValue(functionName, out var function))
{
return await CreateResponseAsync(requestData, HttpStatusCode.NotFound, new ErrorResponse() { Message = $"Unable to find {skillName}.{functionName}" }).ConfigureAwait(false);
}

var function = skill[functionName];

var context = new ContextVariables();
foreach (var v in functionRequest.Variables)
{
Expand Down
2 changes: 1 addition & 1 deletion sk-csharp-azure-functions/sk-csharp-azure-functions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace></RootNamespace>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace></RootNamespace>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ private static string GenerateClassSource(string rootNamespace, string folderNam

namespace {rootNamespace};

#pragma warning disable CA1515
public class {folderName}
{{
private readonly ILogger _logger;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoWarn>SKEXP0080</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SemanticKernel.Process.Core" Version="1.47.0-alpha" />
</ItemGroup>

</Project>
45 changes: 45 additions & 0 deletions sk-process-framework/ProductDocumentationDotnet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Process Framework: Product Documentation application example

This project example demonstrates how to define, preview, and execute a process of generating product documentation.

Note: it is recommended to work with this example using [Semantic Kernel Tools](https://marketplace.visualstudio.com/items?itemName=ms-semantic-kernel.semantic-kernel) VS Code extension.

## Prerequisites

- Install [.NET 8](https://dotnet.microsoft.com/download/dotnet/8.0).

## Setup

1. Open a terminal in the project directory.
2. Run `dotnet build` command to build the logic of the process nodes.

## Getting Started

1. Open the [product-documentation.process.yaml](./product-documentation.process.yaml) file in VS Code to start working with processes.

## Features

### Preview a Process

To preview a process:
- Open the [product-documentation.process.yaml](./product-documentation.process.yaml) file.
- Click the **Preview Process** button in the top bar of the process file.

![Preview Process](images/preview-process.jpeg)

### Execute a Process

To execute a process:
- Open the [product-documentation.process.yaml](./product-documentation.process.yaml) file.
- Click the **Execute Process** button in the top bar of the process file.

![Execute Process](images/execute-process.jpeg)

### Process Node Logic

- The source code for each process node's logic is located in the [Steps](./Steps/) folder.
- Explore this folder to review or modify the logic for individual process steps.

## Reporting Issues

If you encounter any issues or have suggestions, please report them on our [GitHub repository](https://github.com/microsoft/semantic-kernel).
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;

namespace ProductDocumentation.Steps;

public sealed class GenerateDocumentationStep : KernelProcessStep<GeneratedDocumentationState>
{
private GeneratedDocumentationState _state = new();

private const string SystemPrompt =
"""
Your job is to write high quality and engaging customer facing documentation for a new product from Contoso. You will be provide with information
about the product in the form of internal documentation, specs, and troubleshooting guides and you must use this information and
nothing else to generate the documentation. If suggestions are provided on the documentation you create, take the suggestions into account and
rewrite the documentation. Make sure the product sounds amazing.
""";

public override ValueTask ActivateAsync(KernelProcessStepState<GeneratedDocumentationState> state)
{
this._state = state.State!;
this._state.ChatHistory ??= new ChatHistory(SystemPrompt);

return base.ActivateAsync(state);
}

[KernelFunction]
public async Task<string?> GenerateDocumentationAsync(Kernel kernel, KernelProcessStepContext context, string productInfo)
{
// Add the new product info to the chat history
this._state.ChatHistory!.AddUserMessage($"Product Info:\n\n{productInfo}");

// Get a response from the LLM
IChatCompletionService chatCompletionService = kernel.GetRequiredService<IChatCompletionService>();
var generatedDocumentationResponse = await chatCompletionService.GetChatMessageContentAsync(this._state.ChatHistory!);

var documentationString = generatedDocumentationResponse.Content!.ToString();

await context.EmitEventAsync("DocumentationGenerated", documentationString);

return documentationString;
}
}

public class GeneratedDocumentationState
{
public ChatHistory? ChatHistory { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Microsoft.SemanticKernel;

namespace ProductDocumentation.Steps;

public sealed class GetProductInfoStep : KernelProcessStep
{
[KernelFunction]
public string GetProductInfo()
{
return
"""
Product Description:
GlowBrew is a revolutionary AI driven coffee machine with industry leading number of LEDs and programmable light shows. The machine is also capable of brewing coffee and has a built in grinder.

Product Features:
1. **Luminous Brew Technology**: Customize your morning ambiance with programmable LED lights that sync with your brewing process.
2. **AI Taste Assistant**: Learns your taste preferences over time and suggests new brew combinations to explore.
3. **Gourmet Aroma Diffusion**: Built-in aroma diffusers enhance your coffee's scent profile, energizing your senses before the first sip.

Troubleshooting:
- **Issue**: LED Lights Malfunctioning
- **Solution**: Reset the lighting settings via the app. Ensure the LED connections inside the GlowBrew are secure. Perform a factory reset if necessary.
""";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Microsoft.SemanticKernel;

namespace ProductDocumentation.Steps;

public sealed class PublishDocumentationStep : KernelProcessStep
{
[KernelFunction]
public string PublishDocumentation()
{
return "Publishing product documentation...";
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
workflow:
name: ProductDocumentation
nodes:
- id: GetProductInfoStep
description: Gather information about the product
implementation: GetProductInfoStep
on_complete:
- on_condition:
type: default
emits:
- event_type: GetProductInfo.OnResult
- id: GenerateDocumentationStep
description: Generate documentation for the product with LLM
implementation: GenerateDocumentationStep
on_complete:
- on_condition:
type: default
emits:
- event_type: GenerateDocumentation.OnResult
- event_type: DocumentationGenerated
- id: PublishDocumentationStep
description: Publish the documentation
implementation: PublishDocumentationStep
on_complete:
- on_condition:
type: default
emits:
- event_type: ProcessCompleted
orchestration:
- listen_for:
event: InputMessageReceived
then:
- node: GetProductInfoStep
- listen_for:
event: GetProductInfo.OnResult
from: GetProductInfoStep
then:
- node: GenerateDocumentationStep
- listen_for:
event: DocumentationGenerated
from: GenerateDocumentationStep
then:
- node: PublishDocumentationStep
8 changes: 7 additions & 1 deletion sk-starters.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ VisualStudioVersion = 17.5.33530.505
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sk-csharp-azure-functions", "sk-csharp-azure-functions\sk-csharp-azure-functions.csproj", "{A3C12DC4-9448-4DFC-A8BA-6841F6236156}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sk-csharp-chatgpt-plugin", "sk-csharp-chatgpt-plugin\azure-function\sk-chatgpt-azure-function.csproj", "{2E21E690-D091-4116-BD9B-2B2049C84DFF}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sk-chatgpt-azure-function", "sk-csharp-chatgpt-plugin\azure-function\sk-chatgpt-azure-function.csproj", "{2E21E690-D091-4116-BD9B-2B2049C84DFF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "semantic-functions-generator", "sk-csharp-chatgpt-plugin\semantic-functions-generator\semantic-functions-generator.csproj", "{6F9921F1-CDD6-4173-8AE7-6416FF4EB847}"
EndProject
Expand All @@ -17,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sk_csharp_apim_demo", "sk_c
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sk-typescript-console-chat", "sk-typescript-console-chat\sk-typescript-console-chat.csproj", "{9FEE5A32-69C2-4DEF-9179-BBCD80AB8317}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProductDocumentation", "sk-process-framework\ProductDocumentationDotnet\ProductDocumentation.csproj", "{AE3384DA-93B2-613B-911B-01B595DE0B42}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -51,6 +53,10 @@ Global
{9FEE5A32-69C2-4DEF-9179-BBCD80AB8317}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9FEE5A32-69C2-4DEF-9179-BBCD80AB8317}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9FEE5A32-69C2-4DEF-9179-BBCD80AB8317}.Release|Any CPU.Build.0 = Release|Any CPU
{AE3384DA-93B2-613B-911B-01B595DE0B42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AE3384DA-93B2-613B-911B-01B595DE0B42}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AE3384DA-93B2-613B-911B-01B595DE0B42}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AE3384DA-93B2-613B-911B-01B595DE0B42}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 2 additions & 2 deletions sk-typescript-console-chat/sk-typescript-console-chat.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<OutDir>bin</OutDir>
<NodeApiAssemblyJSModuleType>esm</NodeApiAssemblyJSModuleType>
<GenerateNodeApiTypeDefinitionsForReferences>true</GenerateNodeApiTypeDefinitionsForReferences>
<RestorePackagesPath>$(MSBuildThisFileDirectory)/pkg</RestorePackagesPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.4.4" />
<PackageReference Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.9.11" />
<PackageReference Include="Microsoft.SemanticKernel" Version="0.24.230912.2-preview" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions sk_csharp_apim_demo/sk_csharp_apim_demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.9.0" />
<PackageReference Include="Azure.Identity" Version="1.13.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="6.0.0" />
<PackageReference Include="Microsoft.SemanticKernel" Version="0.19.230804.2-preview" />
Expand Down
Loading