Process Framework: executing task and returning an output (C#) #11569
Answered
by
vicperdana
vicperdana
asked this question in
Q&A
-
Hi is there any way we can get the value of In my case, I'd like to be able to get a custom class object that was returned from a step. Step that I'd like to get the return value frompublic class CompletionStep : KernelProcessStep
{
[KernelFunction]
public VideoProcessingResponse CompleteProcessing(string transcript, List<Chapter> chapters, string blogPost, string videoPath, Action<VideoProcessingProgress> progressCallback, KernelProcessStepContext context)
{
void UpdateProgress(string status, int percentage, string currentOperation = "", string? error = null)
{
progressCallback?.Invoke(new VideoProcessingProgress
{
Status = status,
Percentage = percentage,
CurrentOperation = currentOperation,
Error = error
});
}
UpdateProgress("Completed", 100, "Processing complete");
// Clean up video file
if (!string.IsNullOrEmpty(videoPath) && File.Exists(videoPath))
{
try
{
File.Delete(videoPath);
}
catch
{
// Ignore cleanup errors
}
}
VideoProcessingResponse videoProcessingResponse = new VideoProcessingResponse
{
Status = "Completed",
Transcript = transcript,
Chapters = chapters,
BlogPost = blogPost
};
context.EmitEventAsync("Completed", videoProcessingResponse);
return videoProcessingResponse; // this is the value I am trying to get.
}
} The executing taskpublic async Task<VideoProcessingResponse> ProcessVideoAsync(VideoProcessingRequest request){
// Create a new Semantic Kernel process
#pragma warning disable SKEXP0080
ProcessBuilder processBuilder = new("VideoProcessingWorkflow");
// Add the processing steps
var aStep = processBuilder.AddStepFromType<AStep>();
var bStep = processBuilder.AddStepFromType<BStep>();
var process = processBuilder.Build();
// Execute the workflow
var initialResult = await process.StartAsync(_kernel, new KernelProcessEvent{Id = "Start", Data = null});
var finalState = await initialResult.GetStateAsync();
var finalCompletion = finalState.ToProcessStateMetadata();
// ====>> this returns NULL
return (VideoProcessingResponse)finalCompletion.State;
} |
Beta Was this translation helpful? Give feedback.
Answered by
vicperdana
Apr 16, 2025
Replies: 3 comments 1 reply
-
Tagging @alliscode |
Beta Was this translation helpful? Give feedback.
0 replies
-
Tried this too but no luck. |
Beta Was this translation helpful? Give feedback.
0 replies
-
@vicperdana we connected offline. Are you still blocked? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks @moonbox3. Yes it's resolved. For reference, I made the following modifications.