add program code template
This commit is contained in:
parent
249fd09675
commit
894237c416
|
|
@ -1,7 +1,7 @@
|
|||
using BotSharp.Abstraction.Messaging.Models.RichContent.Template;
|
||||
using BotSharp.Abstraction.Messaging.Models.RichContent;
|
||||
using System.Text.Json;
|
||||
using System.Reflection;
|
||||
using BotSharp.Abstraction.Messaging.Models.RichContent.Template;
|
||||
using BotSharp.Abstraction.Messaging.Models.RichContent;
|
||||
|
||||
namespace BotSharp.Abstraction.Messaging;
|
||||
|
||||
|
|
@ -38,9 +38,9 @@ public static class BotSharpMessageParser
|
|||
{
|
||||
targetType = typeof(TextMessage);
|
||||
}
|
||||
else if (richType == RichTypeEnum.JsCode)
|
||||
else if (richType == RichTypeEnum.ProgramCode)
|
||||
{
|
||||
targetType = typeof(JsCodeTemplateMessage);
|
||||
targetType = typeof(ProgramCodeTemplateMessage);
|
||||
}
|
||||
else if (richType == RichTypeEnum.GenericTemplate)
|
||||
{
|
||||
|
|
@ -88,9 +88,9 @@ public static class BotSharpMessageParser
|
|||
{
|
||||
targetType = typeof(CouponTemplateMessage);
|
||||
}
|
||||
else if (templateType == TemplateTypeEnum.Product)
|
||||
else if (templateType == TemplateTypeEnum.ProgramCode)
|
||||
{
|
||||
targetType = typeof(ProductTemplateMessage);
|
||||
targetType = typeof(ProgramCodeTemplateMessage);
|
||||
}
|
||||
else if (templateType == TemplateTypeEnum.Generic)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,6 +9,5 @@ public static class RichTypeEnum
|
|||
public const string QuickReply = "quick_reply";
|
||||
public const string Text = "text";
|
||||
public const string Attachment = "attachment";
|
||||
|
||||
public const string JsCode = "js_code";
|
||||
public const string ProgramCode = "program_code";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,5 +6,5 @@ public static class TemplateTypeEnum
|
|||
public const string Coupon = "coupon";
|
||||
public const string Generic = "generic";
|
||||
public const string MultiSelect = "multi-select";
|
||||
public const string Product = "product";
|
||||
public const string ProgramCode = "program_code";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
namespace BotSharp.Abstraction.Messaging.Models.RichContent.Template;
|
||||
|
||||
public class JsCodeTemplateMessage : IRichMessage
|
||||
{
|
||||
[JsonPropertyName("rich_type")]
|
||||
public string RichType => RichTypeEnum.JsCode;
|
||||
|
||||
[JsonPropertyName("text")]
|
||||
public string Text { get; set; } = string.Empty;
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
namespace BotSharp.Abstraction.Messaging.Models.RichContent.Template;
|
||||
|
||||
public class ProductTemplateMessage : IRichMessage, ITemplateMessage
|
||||
{
|
||||
[JsonPropertyName("rich_type")]
|
||||
public string RichType => RichTypeEnum.GenericTemplate;
|
||||
|
||||
[JsonPropertyName("text")]
|
||||
[Translate]
|
||||
public string Text { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("template_type")]
|
||||
public string TemplateType => TemplateTypeEnum.Product;
|
||||
}
|
||||
|
||||
public class ProductElement
|
||||
{
|
||||
public string Id { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
namespace BotSharp.Abstraction.Messaging.Models.RichContent.Template;
|
||||
|
||||
public class ProgramCodeTemplateMessage : IRichMessage, ITemplateMessage
|
||||
{
|
||||
[JsonPropertyName("rich_type")]
|
||||
public string RichType => RichTypeEnum.ProgramCode;
|
||||
|
||||
[JsonPropertyName("text")]
|
||||
public string Text { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("template_type")]
|
||||
public virtual string TemplateType { get; set; } = TemplateTypeEnum.ProgramCode;
|
||||
|
||||
[JsonPropertyName("language")]
|
||||
public string Language { get; set; } = string.Empty;
|
||||
}
|
||||
|
|
@ -49,13 +49,14 @@ public class PlotChartFn : IFunctionCallback
|
|||
]);
|
||||
|
||||
var obj = response.JsonContent<LlmContextOut>();
|
||||
message.Content = obj?.GreetingMessage.IfNullOrEmptyAs("Here is the chart you ask for:");
|
||||
message.Content = obj?.GreetingMessage ?? "Here is the chart you ask for:";
|
||||
message.RichContent = new RichContent<IRichMessage>
|
||||
{
|
||||
Recipient = new Recipient { Id = convService.ConversationId },
|
||||
Message = new JsCodeTemplateMessage
|
||||
Message = new ProgramCodeTemplateMessage
|
||||
{
|
||||
Text = obj?.JsCode ?? string.Empty
|
||||
Text = obj?.JsCode ?? string.Empty,
|
||||
Language = "javascript"
|
||||
}
|
||||
};
|
||||
message.StopCompletion = true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue