microsoft / kernel-memory

RAG architecture: index and query any data using LLM and natural language, track sources, show citations, asynchronous memory patterns.

Home Page:https://microsoft.github.io/kernel-memory

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Semantic Kernel plugin - sample with reference

rosieks opened this issue · 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.

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.