using System.Text; using System.Text.RegularExpressions; namespace LinkToolAddin.host.prompt; public class PromptServer { public string Name { get; set; } public string Description { get; set; } public string Arguments { get; set; } public string Content { get; set; } public PromptServer(string name, string description, string content) { Name = name; Description = description; Content = content; string pattern = "{{([\\s\\S]*?)}}"; var matches = Regex.Matches(content, pattern); StringBuilder args = new StringBuilder(); foreach (var match in matches) { string variableName = match.ToString().Replace("{{","").Replace("}}",""); string arg = "{ \"" + variableName + "\" : \"type\" : \" string \" }"; args.Append(arg); } if (args.ToString() != string.Empty) { Arguments = "{\"type\":\"object\",\"properties\":" + args.ToString() + "}"; } } }