Closed bbence84 closed 4 months ago
Adding @glahaye who's working on a sample like this as we speak :)
@glahaye when we can expect sample code visible on github?
@Xyloto There's a PR for an example app: #4940
It isn't a WebAPI example per se but it should be a good starting point.
Any update on this? I would ideally like to have a simple WebAPI endpoint which could expose my existing SK POC, even if does not support streaming. I am unsure what the best approach would be: should the conversation history be kept on client side (as seen in many OpenAI chat examples), or should be kept on the server side, e.g. maybe using KernelMemory?
I would really appreciate some help with this to get me started. :)
@bbence84 You can take a look at https://github.com/microsoft/semantic-kernel/tree/main/dotnet/samples/HomeAutomation and its associated blog post: https://devblogs.microsoft.com/semantic-kernel/using-semantic-kernel-with-dependency-injection/
Just use WebApplication.CreateBuilder() instead of HostApplicationBuilder.CreateApplicationBuilder().
Then you can inject transient or session instances of Kernel into your controller.
I hope this helps.
Is there maybe a simple example how I could expose a working SK app via ASP.NET Core WebAPI / using WebApplication? I can create a simple endpoint that works with the regular Azure OpenAI APIs, but I am unsure what is the best practice for exposing an SK Kernel, which is supposed to be stateful. I know about the chat-copilot github repository, but that seems way too excessive for a simple prototype. :) Ideally the Chat endpoint should support streaming responses, which I could consume on the client side. And somehow (maybe using kernel-memory?) it should support user sessions. Thanks!