Merge pull request #13 from microsoft/elsa3new

add workflows app
This commit is contained in:
Ryan Sweet 2023-07-10 15:59:42 -07:00 committed by GitHub
commit e17345b044
9 changed files with 152 additions and 1 deletions

View File

@ -110,7 +110,7 @@ public class SemanticKernelSkill : CodeActivity<string>
var context = new ContextVariables();
context.Set("input", prompt);
context.Set("wafContext", wafContext);
//context.Set("wafContext", wafContext);
var answer = await kernel.RunAsync(context, function).ConfigureAwait(false);
var result = typeof(T) != typeof(string) ? JsonSerializer.Deserialize<T>(answer.ToString()) : (T)(object)answer.ToString();

10
WorkflowsApp/NuGet.Config Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear/>
<add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
<add key="Jint prereleases" value="https://www.myget.org/F/jint/api/v3/index.json" />
<add key="Elsa prereleases" value="https://f.feedz.io/elsa-workflows/elsa-3/nuget/index.json" />
</packageSources>
</configuration>

View File

@ -0,0 +1,22 @@
@page "/"
@{
var serverUrl = $"{Request.Scheme}://{Request.Host}{Request.PathBase}{Request.Path}";
var apiUrl = serverUrl + "elsa/api";
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Elsa Workflows 3.0</title>
<link rel="stylesheet" href="https://rsms.me/inter/inter.css">
<link rel="stylesheet" href="_content/Elsa.Workflows.Designer/elsa-workflows-designer/elsa-workflows-designer.css">
<script src="_content/Elsa.Workflows.Designer/monaco-editor/min/vs/loader.js"></script>
<script type="module" src="_content/Elsa.Workflows.Designer/elsa-workflows-designer/elsa-workflows-designer.esm.js"></script>
</head>
<body>
<elsa-studio server="@apiUrl" monaco-lib-path="/_content/Elsa.Workflows.Designer/monaco-editor/min"></elsa-studio>
</body>
</html>

View File

@ -0,0 +1,2 @@
@namespace WorkflowsApp.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

49
WorkflowsApp/Program.cs Normal file
View File

@ -0,0 +1,49 @@
using Elsa.EntityFrameworkCore.Extensions;
using Elsa.EntityFrameworkCore.Modules.Management;
using Elsa.Extensions;
using Elsa.Identity.Features;
using Elsa.SemanticKernel;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddElsa(elsa =>
{
// Configure management feature to use EF Core.
elsa.UseWorkflowManagement(management => management.UseEntityFrameworkCore(ef => ef.UseSqlite()));
// Expose API endpoints.
elsa.UseWorkflowsApi();
// Add services for HTTP activities and workflow middleware.
elsa.UseHttp();
// Configure identity so that we can create a default admin user.
elsa.UseIdentity(identity =>
{
identity.UseAdminUserProvider();
identity.TokenOptions = options => options.SigningKey = "secret-token-signing-key";
});
// Use default authentication (JWT + API Key).
elsa.UseDefaultAuthentication(auth => auth.UseAdminApiKey());
// Add Semantic Kernel skill.
elsa.AddActivity<SemanticKernelSkill>();
});
// Add Razor pages.
builder.Services.AddRazorPages();
var app = builder.Build();
// Configure the HTTP request pipeline.
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseAuthentication();
app.UseAuthorization();
app.UseWorkflowsApi();
app.UseWorkflows();
app.MapRazorPages();
app.Run();

View File

@ -0,0 +1,37 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:10492",
"sslPort": 44312
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5181",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7077;http://localhost:5181",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Elsa" Version="3.0.0-rc1" />
<PackageReference Include="Elsa.EntityFrameworkCore" Version="3.0.0-rc1" />
<PackageReference Include="Elsa.EntityFrameworkCore.Sqlite" Version="3.0.0-rc1" />
<PackageReference Include="Elsa.Http" Version="3.0.0-rc1" />
<PackageReference Include="Elsa.Identity" Version="3.0.0-rc1" />
<PackageReference Include="Elsa.Workflows.Api" Version="3.0.0-rc1" />
<PackageReference Include="Elsa.Workflows.Designer" Version="3.0.0-rc1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Elsa.SemanticKernel\Elsa.SemanticKernel.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

BIN
WorkflowsApp/elsa.sqlite.db Normal file

Binary file not shown.