我正在尝试 Bot Framework SDK V4 Python GA。使用 LUIS 检测到意图后,我希望能够处理一些业务逻辑并做出响应。我希望能够在业务逻辑的同时发送消息,因为我想让用户知道逻辑正在处理并且需要他稍等片刻。我知道机器人通常不用于长时间运行的进程,但我有一个需要这样做的用例。我正在尝试将 turncontext 传递给业务逻辑并从那里发送消息,但它会引发以下错误。
不能腌制协程对象
我是异步编程的新手,不确定这里到底发生了什么。以下是我尝试过的。我尝试通过将业务逻辑完全放在不同的类中来做同样的事情,但遇到了同样的问题。来自 on_message_activity 的初始消息运行良好,但是当尝试从业务发送消息时,它会抛出上述错误。我在这里错过了什么?
async def someUseCase(self,turncontext: TurnContext):
await turncontext.send_activity(MessageFactory.text("Processing your query. Give me a moment."))
output = someLongRunningBusinessLogic()
return MessageFactory.text(output)
async def on_message_activity(self, turn_context: TurnContext):
luisResult = await self.LuisRecog.recognize(turn_context)
print(luisResult.get_top_scoring_intent())
intent = LuisRecognizer.top_intent(luisResult,min_score=0.40)
if intent != "None":
await turn_context.send_activity("processing your query...")
return await turn_context.send_activity(self.someUseCase(turn_context))
else:
await turn_context.send_activity(MessageFactory.text("No intent detected."))
慕标琳琳
相关分类