我们正在使用附加到Azure Bot Service的QnA Maker。在知识库 (KB) 中,我们为每个问题添加了后续提示:This did NOT answer my question
这意味着如果提供了错误的响应,最终用户可以指出,对话历史将如下所示:
我们试图做的是重播对话历史,以便我们可以看到:
- 原始用户提示
- 原来的答案
- 随后的后续问题/答案
我们打开了Application Insights,因此我们可以通过以下查询从日志中看到这两个问题:
traces
| project timestamp,
itemId,
question = customDimensions.Question,
answer = customDimensions.Answer
| order by timestamp
这将返回这两行:
但是,我们正在尝试找到可以关联这两个记录的唯一对话 ID 或会话 ID。请注意,两者itemId
非常相似,但并不完全相同:
53be8c14-702c-11ea-8c41-11c1c266dc55
53be8c13-702c-11ea-8c41-11c1c266dc55
是否有可以用来加入这两个事件的唯一密钥?
一种解决方法是仅使用的前 7 位数字itemID
并根据部分匹配加入,如下所示:
traces
| where customDimensions.Question contains "This did NOT answer my question"
| project itemId,
SessionID = extract("^[a-z0-9]{7}", 0, itemId),
timestamp
| join (
traces
| extend question = tostring(customDimensions['Question'])
| extend answer = tostring(customDimensions['Answer'])
| where message contains "GenerateAnswer"
and question !contains "This did NOT answer my question"
| project itemId,
SessionID = extract("^[a-z0-9]{7}",0,itemId),
question,
answer,
timestamp
) on SessionID
| project question, answer, SessionID, timestamp //, itemId, itemId1
| order by timestamp desc, SessionID
但我们不确定该值是否可靠地仅相差第 8 位,因此更喜欢不那么脆弱的 ID