我拼命尝试在
dialogflow.types.EventInput
Run Code Online (Sandbox Code Playgroud)
在python中。
该doc说参数必须是type Struct。
我在这里读到,参数必须是google.protobuf.Struct。但这对我不起作用。
Structpython中是否还有另一个等效的类型?
如果我发送EventInput不带参数,则可以正确检测到意图。
到目前为止,我已经尝试过了:
import dialogflow_v2 as dialogflow
session_client = dialogflow.SessionsClient()
session = session_client.session_path(project_id, session_id)
parameters = struct_pb2.Struct()
parameters['given-name'] = 'Jeff'
parameters['last-name'] = 'Bridges'
event_input = dialogflow.types.EventInput(
name='greetPerson',
language_code='de',
parameters=parameters)
query_input = dialogflow.types.QueryInput(event=event_input)
response = session_client.detect_intent(
session=session, query_input=query_input)
Run Code Online (Sandbox Code Playgroud)
有人对此用例有经验吗?
我也尝试过的事情:
传递一个class名为p的产量:
MergeFrom()的参数必须是同一类的实例:预期的Struct得到p。用于字段EventInput.parameters
传递命令:
parameters = {
'given-name': 'Jeff',
'last-name': 'Bridges'}
Run Code Online (Sandbox Code Playgroud)
产量:
协议消息Struct没有“给定名称”字段。
用构造函数生成Struct:
from google.protobuf.struct_pb2 import Struct, Value
parameters = Struct(fields={
'given-name':Value(string_value='Jeff'),
'last-name':Value(string_value='Bidges')
})
Run Code Online (Sandbox Code Playgroud)
有时会产生: …