In SemanticKernel I want to see what are the final rendered prompts that are being sent to OpenAI. I've found the PromptRendered
event:
kernel.PromptRendered += (sender, args) => Console.WriteLine(args.RenderedPrompt);
But unfortunately, it can't be used anymore in 1.0.0-rc4
.
How can I intercept the final rendered prompts for versions later than 1.0.0-rc4?
As of now,
PromptRendered
is still available in the latest Semantic Kernel version 1.0.1. However, pre and post hooks (FunctionInvoked, PromptRendering, PromptRendered) are marked as Experimental. To use them, you'll need to suppress the Error SKEXP0004. You can do this by adding the following line of codeIf your goal is solely to capture the rendered prompt, setting the logging to trace level will achieve this for you. I've put together a quick demo for reference.
output