python - 消息 Microsoft Bot 对模拟器的回复过于不一致和不同
问题描述
该机器人是用 python 开发的,并部署在谷歌应用引擎上。对话机器人在模拟器上流畅运行。但是当我在团队客户端上部署并测试它时,机器人会重复消息或没有收到响应。然后,这会使机器人偏离正题,因为它错过了对某些问题的某些答复。有什么帮助吗?
我的 GAE app.yaml 文件:
runtime: custom
env: flex
entrypoint: gunicorn app:app --bind :8080 --worker-class aiohttp.GunicornWebWorker --timeout 300
service: mma2d
runtime_config:
python_version: 3
handlers:
- url: /*
script: auto
我的 app.py 文件:(从顶部删除了依赖项)
CONVERSATION_REFERENCES: Dict[str, ConversationReference] = dict()
# Create MemoryStorage - UserState and ConversationState both stored in memory
MEMORY = MemoryStorage()
CONVERSATION_STATE = ConversationState(MEMORY)
USER_STATE = UserState(MEMORY)
# Create dialog
DIALOG = Dialog(USER_STATE,CONFIG.CONNECTION_NAME)
# Create Bot
BOT = DialogAndWelcomeBot(CONVERSATION_REFERENCES,CONVERSATION_STATE, USER_STATE, DIALOG)
# Application settings defined here. Provides the ID to the adapter which sends the messages.
SETTINGS = BotFrameworkAdapterSettings(CONFIG.APP_ID, CONFIG.APP_PASSWORD)
ADAPTER = BotFrameworkAdapter(SETTINGS)
APP_ID = SETTINGS.app_id if SETTINGS.app_id else uuid.uuid4()
LOOP = asyncio.get_event_loop()
async def index(request):
return web.Response(text="Hello!")
async def messages(req: Request) -> Response:
#Main bot message handler.
if "application/json" in req.headers["Content-Type"]:
body = await req.json()
else:
return Response(status=HTTPStatus.UNSUPPORTED_MEDIA_TYPE)
activity = Activity().deserialize(body)
print(activity)
auth_header = req.headers["Authorization"] if "Authorization" in req.headers else ""
response = await ADAPTER.process_activity(activity, auth_header, BOT.on_turn)
if response:
return json_response(data=response.body, status=response.status)
return Response(status=HTTPStatus.OK)
app = web.Application(middlewares=[aiohttp_error_middleware])
app.router.add_post("/api/calling", messages)
app.router.add_get('/', index)
if __name__ == "__main__":
# app.run()
try:
web.run_app(app)
except Exception as error:
raise error
解决方案
推荐阅读
- excel - 通过宏格式化 UserForm 对象并保留格式
- python - 访问嵌套字典时的代码差异
- javascript - 动态更新 ref Vuejs 和 Vuefire
- python-3.x - 使用 tkinter 将图像添加到 Gui 时遇到问题
- python - django 2.0.5 中 urls.py 中的 path() 问题
- codacy - Codacy API:发送 API 代码进行分析
- r - rstudio 通过比较其他两列(alphebet)创建一个新列
- dart - Dart 2 和解析 json
- html - 是否可以使用 For 循环订阅动态填充 Angular 2 材质选项卡?
- ios - CFNotificationCenter 重复事件语句