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

[Feature Request] Allow arguments to be passed to the prompt when calling AskAsync

Open stavroskasidis opened this issue 10 months ago • 2 comments

Context / Scenario

I would like to be able to pass parameters to a custom prompt when calling the AskAsync method.

For example: I want to conditionally instruct the LLM to automatically translate the response to a specific language that is selected by the user at runtime.

The problem

Cannot pass arguments to a customized prompt when asking.

Proposed solution

Lets say I add a custom prompt provider as shown here that has the following prompt:

"""
Facts:
{{$facts}}
======
Given only the facts above, provide a comprehensive/detailed answer.
You don't know where the knowledge comes from, just answer.
If you don't have sufficient information, reply with '{{$notFound}}'.
The answer must be translated in {{$translateLanguage}}
Question: {{$input}}
Answer: 
"""

I would like to be able to pass a Dictionary<string,string> with arguments to the AskAsync method that contains the translateLanguage argument, for example

var result = await memory.AskAsync(question, 
promptArguments: new { { "translateLanguage", userLanguage } });

Importance

would be great to have

stavroskasidis avatar Apr 05 '24 16:04 stavroskasidis