Botframework 在对话状态属性中存储数据与在对话的上下文序列化中存储数据有什么区别
当我为bot framework v4项目查看其他人的代码库时,我注意到许多状态数据存储在该特定对话框实例的私有成员中,而不是存储在它自己的StateProperty中。例如,开发人员试图在私有成员中的WaterWallSteps之间存储数据,并希望在新回合内的后续步骤中使用数据(而不是使用Botframework 在对话状态属性中存储数据与在对话的上下文序列化中存储数据有什么区别,botframework,Botframework,当我为bot framework v4项目查看其他人的代码库时,我注意到许多状态数据存储在该特定对话框实例的私有成员中,而不是存储在它自己的StateProperty中。例如,开发人员试图在私有成员中的WaterWallSteps之间存储数据,并希望在新回合内的后续步骤中使用数据(而不是使用stepContext.Next(result))推送结果) 与v3不同(我记得很快),在v4中,对话框本身没有序列化,因此这些私有成员在新建时被“重置” 当我的许多同事开始使用botframeworkv4时
stepContext.Next(result)
)推送结果)
与v3不同(我记得很快),在v4中,对话框本身没有序列化,因此这些私有成员在新建时被“重置”
当我的许多同事开始使用botframeworkv4时,我看到了这种“尝试”,因为他们觉得这很自然
因此,我的问题更多是出于好奇,具体如下:
如文档所述,bot通过调用对话框集上的createcontext来初始化对话框子系统,该对话框集返回一个对话框上下文。该对话框上下文包含该对话框所需的必要信息
由于对话集是用ConversationState初始化的,我问自己“必要的信息”到底是什么意思。特定的对话框实例的哪些信息实际上已恢复
在恢复的对话框(如瀑布式步骤索引)周围是否有或实际上只是上下文
根据对这个问题的回答,人们可能会问,为什么选择使用专用状态属性来存储它,而不是使用其成员集序列化对话框实例,这对于大多数人来说似乎是一种更自然的方式
为什么在v3和v4之间的行为发生了变化?最主要的原因是什么?在Bot Builder v4和v3中,对话框堆栈存储在状态中。V3序列化和反序列化对话框字段是正确的。然而,这种“魔力”往往是有问题的。V3二进制序列化方法只允许sdk以netframework为目标,而整个对话框堆栈更加脆弱。重新设计了V4对话框堆栈,并合并了来自V3的反馈。现在,状态不再那么自动化,而是更多地“掌握在开发人员手中” 下面是一个包含对话框堆栈的会话状态示例:
"document": {
"$type": "System.Collections.Concurrent.ConcurrentDictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Collections.Concurrent",
"DialogState": {
"$type": "Microsoft.Bot.Builder.Dialogs.DialogState, Microsoft.Bot.Builder.Dialogs",
"DialogStack": {
"$type": "System.Collections.Generic.List`1[[Microsoft.Bot.Builder.Dialogs.DialogInstance, Microsoft.Bot.Builder.Dialogs]], System.Private.CoreLib",
"$values": [
{
"$type": "Microsoft.Bot.Builder.Dialogs.DialogInstance, Microsoft.Bot.Builder.Dialogs",
"Id": "GreetingDialog",
"State": {
"$type": "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Private.CoreLib",
"dialogs": {
"$type": "Microsoft.Bot.Builder.Dialogs.DialogState, Microsoft.Bot.Builder.Dialogs",
"DialogStack": {
"$type": "System.Collections.Generic.List`1[[Microsoft.Bot.Builder.Dialogs.DialogInstance, Microsoft.Bot.Builder.Dialogs]], System.Private.CoreLib",
"$values": [
{
"$type": "Microsoft.Bot.Builder.Dialogs.DialogInstance, Microsoft.Bot.Builder.Dialogs",
"Id": "namePrompt",
"State": {
"$type": "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Private.CoreLib",
"options": {
"$type": "Microsoft.Bot.Builder.Dialogs.PromptOptions, Microsoft.Bot.Builder.Dialogs",
"Prompt": {
"$type": "Microsoft.Bot.Schema.Activity, Microsoft.Bot.Schema",
"type": "message",
"id": "3Md4r2ECwdEJnnPshesDe1-g|0000009",
"timestamp": null,
"localTimestamp": null,
"localTimezone": null,
"serviceUrl": "https://webchat.botframework.com/",
"channelId": "webchat",
"from": {
"$type": "Microsoft.Bot.Schema.ChannelAccount, Microsoft.Bot.Schema",
"id": "BotHealthTest@6hiZPWXn5jc",
"name": "BotHealthTest",
"aadObjectId": null,
"role": null
},
"conversation": {
"$type": "Microsoft.Bot.Schema.ConversationAccount, Microsoft.Bot.Schema",
"isGroup": null,
"conversationType": null,
"id": "3Md4r2ECwdEJnnPshesDe1-g",
"name": null,
"aadObjectId": null,
"role": null,
"tenantId": null
},
"recipient": {
"$type": "Microsoft.Bot.Schema.ChannelAccount, Microsoft.Bot.Schema",
"id": "EGnHowki8Se",
"name": "You",
"aadObjectId": null,
"role": null
},
"textFormat": null,
"attachmentLayout": null,
"membersAdded": null,
"membersRemoved": null,
"reactionsAdded": null,
"reactionsRemoved": null,
"topicName": null,
"historyDisclosed": null,
"locale": null,
"text": "What is your name?",
"speak": null,
"inputHint": "expectingInput",
"summary": null,
"suggestedActions": null,
"attachments": null,
"entities": null,
"channelData": null,
"action": null,
"replyToId": "3Md4r2ECwdEJnnPshesDe1-g|0000007",
"label": null,
"valueType": null,
"value": null,
"name": null,
"relatesTo": null,
"code": null,
"expiration": null,
"importance": null,
"deliveryMode": null,
"listenFor": null,
"textHighlights": null,
"semanticAction": null
},
"RetryPrompt": null,
"Choices": null,
"Validations": null
},
"state": {
"$type": "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Private.CoreLib"
}
}
},
{
"$type": "Microsoft.Bot.Builder.Dialogs.DialogInstance, Microsoft.Bot.Builder.Dialogs",
"Id": "profileDialog",
"State": {
"$type": "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Private.CoreLib",
"options": null,
"values": {
"$type": "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Private.CoreLib"
},
"instanceId": "9b48b35f-3fa5-431d-bb4d-9a512491aca4",
"stepIndex": 1
}
}
]
}
}
}
}
]
}
}
}
这就是说,Bot BuilderAdaptive Dialog遵循了一个更接近V3实现的模型。可以在此分支中找到预览位:请检查它,并提供有关Github存储库的反馈。在Bot Builder V4和V3中,对话框堆栈存储为状态。V3序列化和反序列化对话框字段是正确的。然而,这种“魔力”往往是有问题的。V3二进制序列化方法只允许sdk以netframework为目标,而整个对话框堆栈更加脆弱。重新设计了V4对话框堆栈,并合并了来自V3的反馈。现在,状态不再那么自动化,而是更多地“掌握在开发人员手中” 下面是一个包含对话框堆栈的会话状态示例:
"document": {
"$type": "System.Collections.Concurrent.ConcurrentDictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Collections.Concurrent",
"DialogState": {
"$type": "Microsoft.Bot.Builder.Dialogs.DialogState, Microsoft.Bot.Builder.Dialogs",
"DialogStack": {
"$type": "System.Collections.Generic.List`1[[Microsoft.Bot.Builder.Dialogs.DialogInstance, Microsoft.Bot.Builder.Dialogs]], System.Private.CoreLib",
"$values": [
{
"$type": "Microsoft.Bot.Builder.Dialogs.DialogInstance, Microsoft.Bot.Builder.Dialogs",
"Id": "GreetingDialog",
"State": {
"$type": "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Private.CoreLib",
"dialogs": {
"$type": "Microsoft.Bot.Builder.Dialogs.DialogState, Microsoft.Bot.Builder.Dialogs",
"DialogStack": {
"$type": "System.Collections.Generic.List`1[[Microsoft.Bot.Builder.Dialogs.DialogInstance, Microsoft.Bot.Builder.Dialogs]], System.Private.CoreLib",
"$values": [
{
"$type": "Microsoft.Bot.Builder.Dialogs.DialogInstance, Microsoft.Bot.Builder.Dialogs",
"Id": "namePrompt",
"State": {
"$type": "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Private.CoreLib",
"options": {
"$type": "Microsoft.Bot.Builder.Dialogs.PromptOptions, Microsoft.Bot.Builder.Dialogs",
"Prompt": {
"$type": "Microsoft.Bot.Schema.Activity, Microsoft.Bot.Schema",
"type": "message",
"id": "3Md4r2ECwdEJnnPshesDe1-g|0000009",
"timestamp": null,
"localTimestamp": null,
"localTimezone": null,
"serviceUrl": "https://webchat.botframework.com/",
"channelId": "webchat",
"from": {
"$type": "Microsoft.Bot.Schema.ChannelAccount, Microsoft.Bot.Schema",
"id": "BotHealthTest@6hiZPWXn5jc",
"name": "BotHealthTest",
"aadObjectId": null,
"role": null
},
"conversation": {
"$type": "Microsoft.Bot.Schema.ConversationAccount, Microsoft.Bot.Schema",
"isGroup": null,
"conversationType": null,
"id": "3Md4r2ECwdEJnnPshesDe1-g",
"name": null,
"aadObjectId": null,
"role": null,
"tenantId": null
},
"recipient": {
"$type": "Microsoft.Bot.Schema.ChannelAccount, Microsoft.Bot.Schema",
"id": "EGnHowki8Se",
"name": "You",
"aadObjectId": null,
"role": null
},
"textFormat": null,
"attachmentLayout": null,
"membersAdded": null,
"membersRemoved": null,
"reactionsAdded": null,
"reactionsRemoved": null,
"topicName": null,
"historyDisclosed": null,
"locale": null,
"text": "What is your name?",
"speak": null,
"inputHint": "expectingInput",
"summary": null,
"suggestedActions": null,
"attachments": null,
"entities": null,
"channelData": null,
"action": null,
"replyToId": "3Md4r2ECwdEJnnPshesDe1-g|0000007",
"label": null,
"valueType": null,
"value": null,
"name": null,
"relatesTo": null,
"code": null,
"expiration": null,
"importance": null,
"deliveryMode": null,
"listenFor": null,
"textHighlights": null,
"semanticAction": null
},
"RetryPrompt": null,
"Choices": null,
"Validations": null
},
"state": {
"$type": "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Private.CoreLib"
}
}
},
{
"$type": "Microsoft.Bot.Builder.Dialogs.DialogInstance, Microsoft.Bot.Builder.Dialogs",
"Id": "profileDialog",
"State": {
"$type": "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Private.CoreLib",
"options": null,
"values": {
"$type": "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Private.CoreLib"
},
"instanceId": "9b48b35f-3fa5-431d-bb4d-9a512491aca4",
"stepIndex": 1
}
}
]
}
}
}
}
]
}
}
}
这就是说,Bot BuilderAdaptive Dialog遵循了一个更接近V3实现的模型。预览位可以在这个分支中找到:请检查它,并在Github存储库中提供反馈