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

.Net: How to get Rendered prompt alone without invoking the model

Open ddramireddy opened this issue 1 year ago • 3 comments

Hi Team,

We have few plugins defined with each prompt provides data + instructions to analyze this data. We are using function.InvokeAsync() to invoke this plugin.

This function call is invoking the model after getting the data + instructions. But we don't want to invoke the model. Instead wants to get the rendered prompt alone. Is there any function/approach to get rendered prompt alone without invoking the model?

Thank you.

ddramireddy avatar Sep 23 '24 10:09 ddramireddy

@ddramireddy Here is a unit test which shows how to do this: https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/SemanticKernel.UnitTests/PromptTemplate/KernelPromptTemplateTests.cs#L105-L128

markwallace-microsoft avatar Sep 23 '24 15:09 markwallace-microsoft

Hi @markwallace-microsoft ,

We were overriding the method: "GetChatCompletionsAsync()" method. When I call, RenderAsync() method, We can see that it's internally calling the GetChatCompletionsAsync() method and which in turn is calling the model.

ddramireddy avatar Sep 25 '24 10:09 ddramireddy

Hi @ddramireddy if your prompt contains a function call, then rendering the prompt will invoke the function as the rendered prompt includes the return value from the function. Can you provide a reproducible scenario and more details on what you are trying to achieve?

markwallace-microsoft avatar Sep 26 '24 10:09 markwallace-microsoft

@ddramireddy please create a new issue if you need further assistance

markwallace-microsoft avatar Oct 07 '24 06:10 markwallace-microsoft