EmitExternalEventAsync Method does not have data parameter ( Process Framework) #10570
Unanswered
lovedeepatsgit
asked this question in
Q&A
Replies: 1 comment
-
Tagging @alliscode for visibility. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The Above is Definition EmitExternalEventAsync Method I am currently using Microsoft.Semantic Kernel 1.37.0, and While referring to the documentation of the Process Framework (https://learn.microsoft.com/en-us/semantic-kernel/frameworks/process/examples/example-human-in-loop?pivots=programming-language-csharp), there is one step that mentions that "await context.EmitExternalEventAsync("HumanApprovalRequired", data: documentation);", But as shown in the Screen Captures There is No option to use data attribute, Below is the screen capture of the Documentation:
Below is the Code which I am using:
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel;
using Microsoft.Extensions.Configuration;
using static GenerateDocumentationStep;
using Microsoft.SemanticKernel.Connectors.AzureOpenAI;
using System.ComponentModel;
using System.Text.Json;
///Below i have defined the steps that are needed in the process, Next I will define the process flow, how these steps will be executed.
ProcessBuilder processBuilder = new("DocumentationGeneration");
//Addig the steps to the process
var infogatheringstep = processBuilder.AddStepFromType();
var generatedocsstep = processBuilder.AddStepFromType();
var docsProofreadStep = processBuilder.AddStepFromType();
var publishdocstep = processBuilder.AddStepFromType();
//Orchestrating the steps
processBuilder
.OnInputEvent("Start")
.SendEventTo(new(infogatheringstep));
processBuilder
.OnInputEvent("HumanApprovalResponse")
.SendEventTo(new(publishdocstep, parameterName: "isApproved"));
infogatheringstep
.OnFunctionResult()
.SendEventTo(new(generatedocsstep, functionName: "GenerateDocumentationAsync"));
generatedocsstep
.OnEvent("DocumentationGenerated")
.SendEventTo(new(docsProofreadStep));
docsProofreadStep
.OnEvent("DocumentationRejected")
.SendEventTo(new(generatedocsstep, functionName: "ApplySuggestionsAsync"));
docsProofreadStep
.OnEvent("DocumentationApproved")
.SendEventTo(new(publishdocstep, parameterName: "docs"));
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.Build();
// Register Kernel and Agents
string? AZURE_OPEN_AI_ENDPOINT = configuration["LlmModels:AiFoundryEndpoint"];
string? AZURE_OPEN_AI_KEY = configuration["LlmModels:AiFoundryApiKey"];
string? DEPLOYMENT_MODEL = configuration["LlmModels:GPT-4o-2"];
Kernel kernel = Kernel.CreateBuilder()
.AddAzureOpenAIChatCompletion(DEPLOYMENT_MODEL!, AZURE_OPEN_AI_ENDPOINT!, AZURE_OPEN_AI_KEY!)
.Build();
var process = processBuilder.Build();
await process.StartAsync(kernel, new KernelProcessEvent { Id = "Start", Data = "Tata Tea" });
await process.StartAsync(kernel, new KernelProcessEvent { Id = "HumanApprovalResponse", Data = true });
//Definig a process to gather information about a product
public class GatherProductInfoStep : KernelProcessStep
{
[KernelFunction]
public string GatherProductInfo(string productName)
{
Console.WriteLine($"{nameof(GatherProductInfoStep)}:\n\t Gathering Trial Info About: {productName}");
return
$"""
The Information about the product: {productName}
""";
}
}
public class GenerateDocumentationStep : KernelProcessStep
{
private GenerateDocumentationStepState _state = new();
}
public class ProofReadingStep : KernelProcessStep
{
[KernelFunction]
public async Task ProofReadDocumentationAsync(Kernel kernel, KernelProcessStepContext context, string documentation)
{
Console.WriteLine($"{nameof(ProofReadingStep)}:\n\tProofreading the documentation...");
}
public class PublishDocumentationStep : KernelProcessStep
{
[KernelFunction]
public void PublishDocumentation(string docs, bool isApproved)
{
if (isApproved)
{
Console.WriteLine($"{nameof(PublishDocumentationStep)}:\n\tPublishing product documentation:\n\n{docs}");
}
}
}
The output I am receiving is Below:
Here, the Program exits without my consent, How I can resolve this Issue.
Beta Was this translation helpful? Give feedback.
All reactions