Merge pull request #414 from iceljc/features/refine-save-state-by-args
refine save state by args
This commit is contained in:
commit
02be7532c9
|
|
@ -127,6 +127,8 @@ public class ConversationStateService : IConversationStateService, IDisposable
|
|||
_historyStates = _db.GetConversationStates(conversationId);
|
||||
var dialogs = _db.GetConversationDialogs(conversationId);
|
||||
var userDialogs = dialogs.Where(x => x.MetaData?.Role == AgentRole.User || x.MetaData?.Role == UserRole.Client)
|
||||
.GroupBy(x => x.MetaData?.MessageId)
|
||||
.Select(g => g.First())
|
||||
.OrderBy(x => x.MetaData?.CreateTime)
|
||||
.ToList();
|
||||
var curMsgIndex = userDialogs.FindIndex(x => !string.IsNullOrEmpty(curMsgId) && x.MetaData?.MessageId == curMsgId);
|
||||
|
|
@ -342,9 +344,17 @@ public class ConversationStateService : IConversationStateService, IDisposable
|
|||
{
|
||||
foreach (JsonProperty property in root.EnumerateObject())
|
||||
{
|
||||
if (!string.IsNullOrEmpty(property.Value.ToString()))
|
||||
var propertyValue = property.Value;
|
||||
var stateValue = propertyValue.ToString();
|
||||
if (!string.IsNullOrEmpty(stateValue))
|
||||
{
|
||||
SetState(property.Name, property.Value, source: StateSource.Application);
|
||||
if (propertyValue.ValueKind == JsonValueKind.True ||
|
||||
propertyValue.ValueKind == JsonValueKind.False)
|
||||
{
|
||||
stateValue = stateValue?.ToLower();
|
||||
}
|
||||
|
||||
SetState(property.Name, stateValue, source: StateSource.Application);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue