Support editor in rich content.
This commit is contained in:
parent
a6e34b8dbb
commit
6cc63913d4
|
|
@ -0,0 +1,20 @@
|
|||
namespace BotSharp.Abstraction.Messaging.Enums;
|
||||
|
||||
public static class EditorTypeEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// Disable user input freeform text
|
||||
/// </summary>
|
||||
public const string None = "none";
|
||||
public const string Text = "text";
|
||||
public const string Address = "address";
|
||||
public const string Phone = "phone";
|
||||
public const string DateTimePicker = "datetime-picker";
|
||||
public const string DateTimeRangePicker = "datetime-range-picker";
|
||||
public const string Email = "email";
|
||||
|
||||
/// <summary>
|
||||
/// Regex, set the expression in editor_attributes
|
||||
/// </summary>
|
||||
public const string Regex = "regex";
|
||||
}
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
using BotSharp.Abstraction.Messaging.Enums;
|
||||
|
||||
namespace BotSharp.Abstraction.Messaging.Models.RichContent;
|
||||
|
||||
public class RichContent<T> where T : IRichMessage
|
||||
|
|
@ -16,6 +18,14 @@ public class RichContent<T> where T : IRichMessage
|
|||
[JsonPropertyName("fill_postback")]
|
||||
public bool FillPostback { get; set; }
|
||||
|
||||
[JsonPropertyName("editor")]
|
||||
public string Editor { get; set; } = EditorTypeEnum.Text;
|
||||
|
||||
[JsonPropertyName("editor_attributes")]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? EditorAttributes { get; set; }
|
||||
|
||||
|
||||
public RichContent()
|
||||
{
|
||||
|
||||
|
|
@ -25,4 +35,9 @@ public class RichContent<T> where T : IRichMessage
|
|||
{
|
||||
Message = message;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{MessagingType} {typeof(T).Name}";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ using BotSharp.Abstraction.Messaging;
|
|||
using BotSharp.Abstraction.Messaging.JsonConverters;
|
||||
using BotSharp.Abstraction.Messaging.Models.RichContent;
|
||||
using BotSharp.Abstraction.Options;
|
||||
using BotSharp.Abstraction.Repositories;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace BotSharp.Core.Conversations.Services;
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ public class StreamingLogHook : ConversationHookBase, IContentGeneratingHook, IR
|
|||
{
|
||||
var agent = await _agentService.LoadAgent(message.CurrentAgentId);
|
||||
var log = $"{message.Content}";
|
||||
if (message.RichContent != null && message.RichContent.Message.RichType != "text")
|
||||
if (message.RichContent != null)
|
||||
{
|
||||
var richContent = JsonSerializer.Serialize(message.RichContent, _options.JsonSerializerOptions);
|
||||
log += $"\r\n```json\r\n{richContent}\r\n```";
|
||||
|
|
|
|||
Loading…
Reference in a new issue