gpt4 book ai didi

ios - 如何在 iOS Swift 中使用 Watson Conversation?

转载 作者:行者123 更新时间:2023-11-28 15:07:49 24 4
gpt4 key购买 nike

我将根据 Build a home assistant mobile application with Watson and IoT Platform services 更新我的自定义示例

在这段代码中我得到消息:

无法将类型“String”的值转换为预期的参数类型“InputData?”

如何解决这个问题?documentation of developer cloud/conversation/api里面我可以找到 InputData 的定义,但是没有示例如何在 Swift iOS 中实现它?

    // Based on API Changes
// ====================
// Incorrect argument label in call (have 'text:context:', expected 'input:context:')
// Cannot convert value of type 'String' to expected argument type 'InputData?'
let request = MessageRequest(input: text, context: self.context)
self.conversation?.message(workspaceID: Credentials.ConversationWorkspaceID,
request: request,
failure: failure) {
response in
print(response.output.text)
self.didReceiveConversationResponse(response.output.text)
self.context = response.context
// issue command based on intents and entities
// Additional Properties:
// response.context.json -> response.context.additionalProperties
print("appl_action: \(response.context.additionalProperties["appl_action"])")
self.issueCommand(intents: response.intents, entities: response.entities)
}

最佳答案

MessageRequest 构造函数的input 参数采用InputData 对象,该对象很容易从文本字符串构造。尝试

let input = InputData(text: text)
let request = MessageRequest(input: input, context: self.context)
self.conversation?.message(workspaceID: Credentials.ConversationWorkspaceID,
request: request,
failure: failure) {

关于ios - 如何在 iOS Swift 中使用 Watson Conversation?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48223371/

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