kernel-memory icon indicating copy to clipboard operation
kernel-memory copied to clipboard

Semantic Kernel plugin - sample with reference

Open rosieks opened this issue 2 years ago • 1 comments

Could you provide sample how to use Semantic Kernel plugin to answer question in a way that also provide reference to reference document? Something similar what is availably already while using Azure Open AI with own data.

rosieks avatar Jan 02 '24 20:01 rosieks

I've hit a similar issue - wanting to retain RelevantSources from MemoryAnswer but still getting the benefit of further prompt instructions controlling output formatting, etc from Semantic Kernel.

The workaround I've found is to simply not use the 'plugin' model at all and invoke both operations independently.

  1. Call IKernelMemory.AskAsync() independently (Instead of something like {{memory.ask $input}} inside a Semantic Kernel prompt)
  2. Pass MemoryAnswer.Result into my Semantic Function as an input variable in KernelArguments
  3. Call Kernel.InvokeAsync()
  4. Construct a custom Result class combining MemoryAnswer.RelevantSources and Semantic Kernel's FunctionResult.Value

I'm not sure if there is a way to do this with the plugin as it stands today.

drewrelmas avatar Jan 04 '24 17:01 drewrelmas