简体   繁体   English

如何通过V2将变量作为上下文传递给IBM Cloud Watson Assistant?

[英]How to pass variables as context to IBM Cloud Watson Assistant with V2?

I am trying to use the new API version V2 for IBM Cloud Watson Assistant . 我正在尝试将新的API版本V2用于IBM Cloud Watson Assistant Instead of sending a message for a workspace I need to send a message to an assistant. 我不需要向工作空间发送消息,而是需要向助手发送消息。 The context structure has global and skill-related sections now. 上下文结构现在具有全局和与技能相关的部分。

How would my app pass in values as context variables? 我的应用程序如何将值作为上下文变量传递? Where in the structure would they need to be placed? 需要将它们放置在结构中的什么位置? I am using the Python SDK. 我正在使用Python SDK。 I am interested in sending information as part of client dialog actions . 我有兴趣在客户端对话操作中发送信息。

Based on testing the Python SDK and the API V2 using a tool , I came to the following conclusion. 基于使用工具测试Python SDK和API V2,我得出以下结论。 Context is provided by the assistant if it is requested as part of the input options . 如果请求将上下文作为输入选项的一部分,则由助手提供。

  "context": {
    "skills": {
      "main skill": {
        "user_defined": {
          "topic": "some chatbot talk", 
          "skip_user_input": true
        }
      }
    }, 
    "global": {
      "system": {
        "turn_count": 2
      }
    }
  }

To pass back values from my client / app to the assistant, I could use the context parameter. 要将值从客户端/应用程序传递回助手,我可以使用context参数。 However, in contrast to the V1 API I needed to place the key / value pairs "down below" in the user_defined part: 但是,与V1 API相比,我需要将键/值对“向下放置”在user_defined部分中:

context['skills']['main skill']['user_defined'].update({'mydateOUT':'2018-10-08'})

The above is a code snippet from this sample file for a client action. 上面是此示例文件中用于客户端操作的代码段。 With that placement of my context variables everything works and I can implement client actions using the API Version 2. 通过放置上下文变量,一切正常,我可以使用API​​版本2实施客户端操作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ibm watson 助手设置上下文变量 - Ibm watson Assistant setting context variables 如何打印IBM Watson Assistant返回的答案? - How to print the answer returned by IBM Watson Assistant? 如何使用python通过V1 API向Watson Assistant技能发送和附加新的上下文变量? - How to send and append new context variable to Watson Assistant skills via V1 API using python? IBM Watson Assistant,电报和Python - IBM Watson Assistant, Telegram and Python 我们可以使用 python(ibm_watson sdk)从“ibm 云函数”调用其他 Watson 服务(如助手、发现等)吗? - Can we call other Watson services(like assistant, discovery etc.,) from 'ibm cloud functions' using python( ibm_watson sdk)? 如何使IBM Watson Assistant欢迎节点启动与Node.js或Python的对话? - How to make IBM Watson Assistant welcome node starts the conversation with Node.js or Python? 如何删除模型-IBM Watson - How to delete model - IBM Watson 如何从桌面导入 Watson Studio[IBM 云] 中的 csv 文件? - How do I import .csv file in Watson studio[IBM cloud] from desktop? 尝试在 Python 中制作 Watson IBM 助手。 在没有音频文件的情况下,如何修复我的代码以在 IDE Pycharm 中说出答案。 使用 VLC - Trying to make a Watson IBM assistant in Python. How can I fix my code to say the answer within the IDE Pycharm without the audio file. Using VLC IBM Cloud Object 存储连接问题 Watson studio Python 笔记本 - IBM Cloud Object Storage Connection issue Watson studio Python notebook
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM