gpt4 book ai didi

dialogflow-es - Dialog Flow (API.ai) 中的数据上下文在哪里

转载 作者:行者123 更新时间:2023-12-05 00:14:03 25 4
gpt4 key购买 nike

我一直在阅读有关 Dialog Flow 的文章,但有一件事对我来说仍然不清楚。我会试着举一个例子。

我想实现如下转换:

User: Hello Google, what are some interesting cities?
Bot: Hello there! Sydney, New York and Berlin are nice.
User: Could you tell more about the second city?
Bot: Sure. New York is amazing. In New York, you can ...

如您所见,我正在构建数据上下文。在第一个问题之后,我们应该记得我们回答了 Sydney, New York and Berlin ,所以我们明白了什么 the second city实际上意味着在第二个问题中。

我们应该将此数据存储在 webhook 服务中还是存储在 Dialog Flow 的上下文中?如果我们必须将这些数据存储在 webhook 服务中,我们如何区分不同的正在进行的对话?

最佳答案

将它存储在 Dialogflow Context 中是一个理想的解决方案 - 这正是 Contexts 的目的!您使用相同的术语表达了您的问题,这并非巧合。

从概念上讲,您可以使用如下设置来执行此操作:

User: What are some interesting cities?

Dialogflow sees no contexts and matches an Intent asking for cities.

Agent replies: Sydney, New York, and Berlin are nice.
Agent sets context "cities" with parameter "cities" -> "Sydney, New York, Berlin"

User: Tell me more about the second one?

Dialogflow has an Intent that expects an incoming context of "cities" with a text pattern like "Tell me more about the (number index) one?" It sends the request to that Intent along with the currently active contexts.

Agent get a parameter with the index and the context "cities". It looks up the parameter for it, turns the string into an array, and gets the city based on the index.
Agent replies: New York is a fun place to visit!
Agent sets context "city" with parameter "current" -> "New York"

User: Tell me more!

Dialogflow matches this phrase and that the "city" context is still active and sends it to an event that reports more.

Agent says: More awesome stuff about New York.

User: Tell me about that first city instead.

Dialogflow matches it against the same intent as before.

Agent says: Sydney is pretty cool.
Agent changes the "city" context so the parameter "current" -> "Sydney" and "previous" -> "New York".

您现在可以创建其他意图来处理诸如“比较这两个”或“告诉我有关另一个的更多信息”之类的短语。

更新

此设置在 Dialogflow 擅长的方面(解析消息并确定对话的当前状态)和您的 webhook 擅长的方面(确定这些问题的最佳答案)之间取得了良好的平衡。

您可能可以在 Dialogflow 中完成大部分工作,但很快就会开始变得非常非常困惑。您需要创建多个 Intent 来单独处理每个值的结果,这不会扩展。您还需要为每个城市创建一个上下文(因此您将拥有“city_ny”和“city_sydney”上下文),因为您只能匹配上下文的存在,而不是它可能具有的参数。

使用 webhook(甚至我们现在拥有的内置履行系统)可能会更好地工作。

关于dialogflow-es - Dialog Flow (API.ai) 中的数据上下文在哪里,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47591980/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com