Pass Kernel instance when starting Dapr process in C# #11540
-
Hi, LocalKernelProcessContext: var localProcessContext = await _kernelProcess.StartAsync(
kernel,
new KernelProcessEvent()
{
Id = "StartProcess",
Data = userMessage
}); DaprKernelProcessContext var daprProcessContext = await _kernelProcess.StartAsync(
new KernelProcessEvent()
{
Id = "StartProcess",
Data = userMessage
},
accountNumber.ToString()); I'm trying to do something similar to the discussion here #10234, where a Kernel instance can be passed in using Python. I don't know if I'm going mad - I'm sure the overload did exist until I foolishly did a bulk-update or all the NuGet packages to 1.45.0 without backing up first! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Adding @alliscode |
Beta Was this translation helpful? Give feedback.
-
Hi @chris-coop, you are correct, there is no way to directly pass a Kernel instance to the process when using Dapr. The reason for this is that Dapr is intended to run as a distributed multi server system and there is no way to pass Kernel instances around between servers. When using the Dapr runtime, the Kernel instance needs to be configured via dependency injection. An example of configuring the Kernel in DI for Dapr can be seen here: https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/Demos/ProcessWithCloudEvents/ProcessWithCloudEvents.Grpc/Program.cs#L26 |
Beta Was this translation helpful? Give feedback.
Hi @chris-coop, you are correct, there is no way to directly pass a Kernel instance to the process when using Dapr. The reason for this is that Dapr is intended to run as a distributed multi server system and there is no way to pass Kernel instances around between servers.
When using the Dapr runtime, the Kernel instance needs to be configured via dependency injection. An example of configuring the Kernel in DI for Dapr can be seen here: https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/Demos/ProcessWithCloudEvents/ProcessWithCloudEvents.Grpc/Program.cs#L26