41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
using LinkToolAddin.host;
|
|
using LinkToolAddin.host.prompt;
|
|
|
|
namespace LinkToolAddin.client.prompt;
|
|
|
|
public class DynamicPrompt
|
|
{
|
|
public static string GetPrompt(string name,Dictionary<string,string> args = null)
|
|
{
|
|
PromptServerList promptServerList = new PromptServerList();
|
|
string template = promptServerList.GetPromptServer(name).Content;
|
|
if (args == null)
|
|
{
|
|
return template;
|
|
}
|
|
foreach (KeyValuePair<string,string> pair in args)
|
|
{
|
|
string replaceKey = "{{"+pair.Key+"}}";
|
|
template = template.Replace(replaceKey, pair.Value.ToString());
|
|
}
|
|
return template;
|
|
}
|
|
|
|
public static List<UserPrompt> GetAllPrompts()
|
|
{
|
|
PromptServerList promptServerList = new PromptServerList();
|
|
List<UserPrompt> prompts = new List<UserPrompt>();
|
|
Dictionary<string, PromptServer> promptDefinitions = promptServerList.GetPromptsDict();
|
|
foreach (KeyValuePair<string, PromptServer> pair in promptDefinitions)
|
|
{
|
|
prompts.Add(new UserPrompt()
|
|
{
|
|
Name = pair.Value.Name,
|
|
Description = pair.Value.Description,
|
|
Arguments = pair.Value.Arguments
|
|
});
|
|
}
|
|
return prompts;
|
|
}
|
|
} |