fix to string
This commit is contained in:
parent
7470953a8e
commit
98e0142fc3
|
|
@ -3,7 +3,7 @@ namespace BotSharp.Abstraction.Models;
|
|||
public class MessageState
|
||||
{
|
||||
public string Key { get; set; }
|
||||
public string Value { get; set; }
|
||||
public object Value { get; set; }
|
||||
|
||||
[JsonPropertyName("active_rounds")]
|
||||
public int ActiveRounds { get; set; } = -1;
|
||||
|
|
@ -13,7 +13,7 @@ public class MessageState
|
|||
|
||||
}
|
||||
|
||||
public MessageState(string key, string value, int activeRounds = -1)
|
||||
public MessageState(string key, object value, int activeRounds = -1)
|
||||
{
|
||||
Key = key;
|
||||
Value = value;
|
||||
|
|
|
|||
|
|
@ -108,4 +108,27 @@ public static class StringExtensions
|
|||
uint.TryParse(value, out _) ||
|
||||
ulong.TryParse(value, out _);
|
||||
}
|
||||
|
||||
|
||||
public static string ConvertToString<T>(this T? value, JsonSerializerOptions? jsonOptions = null)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
if (value is string s)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
if (value is JsonElement elem
|
||||
&& elem.ValueKind == JsonValueKind.String)
|
||||
{
|
||||
return elem.ToString();
|
||||
}
|
||||
|
||||
var str = JsonSerializer.Serialize(value, jsonOptions);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public partial class AgentService
|
|||
hook.OnSamplesLoaded(agent.Samples);
|
||||
}
|
||||
|
||||
if (loadUtility)
|
||||
if (loadUtility && !agent.Utilities.IsNullOrEmpty())
|
||||
{
|
||||
hook.OnAgentUtilityLoaded(agent);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
******************************************************************************/
|
||||
|
||||
using BotSharp.Abstraction.Conversations.Enums;
|
||||
using BotSharp.Abstraction.Options;
|
||||
using BotSharp.Abstraction.SideCar;
|
||||
|
||||
namespace BotSharp.Core.Conversations.Services;
|
||||
|
|
@ -69,9 +70,11 @@ public class ConversationStateService : IConversationStateService
|
|||
return this;
|
||||
}
|
||||
|
||||
var options = _services.GetRequiredService<BotSharpOptions>();
|
||||
|
||||
var defaultRound = -1;
|
||||
var preValue = string.Empty;
|
||||
var currentValue = value.ToString();
|
||||
var currentValue = value.ConvertToString(options.JsonSerializerOptions);
|
||||
var curActive = true;
|
||||
StateKeyValue? pair = null;
|
||||
StateValue? prevLeafNode = null;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class ConversationController : ControllerBase
|
|||
var conv = new Conversation
|
||||
{
|
||||
AgentId = agentId,
|
||||
Channel = channel == default ? ConversationChannel.OpenAPI : channel.Value,
|
||||
Channel = channel == default ? ConversationChannel.OpenAPI : channel.Value.ToString(),
|
||||
Tags = config.Tags ?? new(),
|
||||
TaskId = config.TaskId
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue