mahenzon / aioalice Goto Github PK
View Code? Open in Web Editor NEWAsynchronous library for Yandex Dialogs (Alice) API
License: MIT License
Asynchronous library for Yandex Dialogs (Alice) API
License: MIT License
The project needs pyproject.toml
file for easier development and deployment
Example of changed request:
{'meta': {'client_id': 'MailRu-VC/1.0', 'locale': 'ru_RU', 'timezone': 'Europe/Moscow', 'interfaces': {'screen': {}}, '_city_ru': 'Москва'}, 'request': {'command': '', 'original_utterance': 'Включи навык лала, 'type': 'SimpleUtterance', 'nlu': {'tokens': ['включи', 'навык', 'лала'], 'entities': []}}, 'session': {'session_id': 'a6dcdc02-92b8-4076-9bae-fced146bb1b2', 'user_id': 'f67490185d2080870a55390310dcd14007ddad00eb330dd4e3356a8b0c77d13f', 'skill_id': 'cfe83c82-c63e-4135-afa4-80ebed097ad8', 'new': True, 'message_id': 0, 'user': {'user_id': 'bfe750f47d3548d13d46fa35a461dcdb49c5ab300e6f62097a77b2e023c7a4af'}, 'application': {'application_id': 'f67490185d2080870a55490310dcd14007ddad00eb330ad4e3356a8bac77d13f', 'application_type': 'mobile'}}, 'state': {'session': {}, 'user': {}}, 'version': '1.0'}
Traceback:
2021-02-24_19:57:42.53255 Traceback (most recent call last):
2021-02-24_19:57:42.53255 File "/usr/local/lib/python3.6/dist-packages/aioalice/dispatcher/webhook.py", line 60, in parse_request
2021-02-24_19:57:42.53257 return AliceRequest(self.request, **data)
2021-02-24_19:57:42.53257 TypeError: init() got an unexpected keyword argument 'state'
2021-02-24_19:57:42.53334 Error handling request
2021-02-24_19:57:42.53335 Traceback (most recent call last):
2021-02-24_19:57:42.53335 File "/usr/local/lib/python3.6/dist-packages/aiohttp/web_protocol.py", line 418, in start
2021-02-24_19:57:42.53335 resp = await task
2021-02-24_19:57:42.53336 File "/usr/local/lib/python3.6/dist-packages/aiohttp/web_app.py", line 458, in _handle
2021-02-24_19:57:42.53336 resp = await handler(request)
2021-02-24_19:57:42.53336 File "/usr/local/lib/python3.6/dist-packages/aiohttp/web_urldispatcher.py", line 892, in _iter
2021-02-24_19:57:42.53337 resp = await method()
2021-02-24_19:57:42.53337 File "/usr/local/lib/python3.6/dist-packages/aioalice/dispatcher/webhook.py", line 169, in post
2021-02-24_19:57:42.53337 request = await self.parse_request()
2021-02-24_19:57:42.53337 File "/usr/local/lib/python3.6/dist-packages/aioalice/dispatcher/webhook.py", line 60, in parse_request
2021-02-24_19:57:42.53338 return AliceRequest(self.request, **data)
2021-02-24_19:57:42.53338 TypeError: init() got an unexpected keyword argument 'state'
Не работает FSM для новых сессий.
Не работает выход из навыка.
Например, запустим навык, выберем игру, удалим сессию в Алисе, создадим новую - скрипт ответит старым состоянием.
Нажатие кнопки "прекрати" ничего не делает.
Как сделать хэндлер, который будет доступен из любого состояния? Допустим на команду прекрати, навык должен незамедлительно устанавливать свою работу, но это работает, только на конкретном состоянии, то есть на другом уже не работает. В примере про машину состояний также не работает
Example
from aiohttp import web
from aioalice import Dispatcher, get_new_configured_app
WEBHOOK_URL_PATH = '/my-alice-webhook/' # webhook endpoint
WEBAPP_HOST = 'localhost'
WEBAPP_PORT = 3001
dp = Dispatcher()
@dp.request_handler()
async def handle_all_requests(alice_request):
return alice_request.response('Привет этому миру!')
if __name__ == '__main__':
app = get_new_configured_app(dispatcher=dp, path=WEBHOOK_URL_PATH)
web.run_app(app, host=WEBAPP_HOST, port=WEBAPP_PORT)
Error
======== Running on http://localhost:3001 ========
(Press CTRL+C to quit)
Error handling request
Traceback (most recent call last):
File "/user/simple-alice/venv/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
resp = await request_handler(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/user/simple-alice/venv/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
resp = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/user/simple-alice/venv/lib/python3.11/site-packages/aiohttp/web_urldispatcher.py", line 954, in _iter
resp = await method()
^^^^^^^^^^^^^^
File "/user/simple-alice/venv/lib/python3.11/site-packages/aioalice/dispatcher/webhook.py", line 183, in post
result = await self.process_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/user/simple-alice/venv/lib/python3.11/site-packages/aioalice/dispatcher/webhook.py", line 101, in process_request
await waiter
RuntimeError: Task <Task pending name='Task-5' coro=<RequestHandler._handle_request() running at /user/simple-alice/venv/lib/python3.11/site-packages/aiohttp/web_protocol.py:433> cb=[Task.task_wakeup()]> got Future <Future pending> attached to a different loop
Предлагаю во всех объектах добавить игнорирование дополнительных параметров при парсинге JSON
__comment
В связи со спецификой разработки навыков (обычно это пет-проекты) при ближайшем расширении API протокола некоторая часть навыков просто умрет навсегда
Теперь таймаут можно увеличить =)
There’s a backward-incompatible change in attrs 19.2.0 (2019-10-01): Removed deprecated Attribute attribute convert per scheduled removal on 2019/1.
https://www.attrs.org/en/stable/changelog.html
Now 18.1.0 is used
So we need to upgrade version and all dependent code that uses convert
keyword
Tests may require an upgrade too (needs investigation)
More tests are welcome
Intents, saved sessions and more
https://yandex.ru/blog/dialogs/vesennee-obnovlenie-platformy-dialogov
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.