compare core and sdk version upon action request
@@ -13,6 +13,7 @@ from flask_cors import CORS, cross_origin
from gevent.pywsgi import WSGIServer
from rasa_core_sdk.executor import ActionExecutor
from rasa_core_sdk import ActionExecutionRejection
+from rasa_core_sdk.version import __version__ as sdk_version
DEFAULT_SERVER_PORT = 5055
@@ -79,6 +80,7 @@ def endpoint_app(cors_origins=None,
def webhook():
"""Webhook to retrieve action calls."""
action_call = request.json
+ check_version_compatibility(action_call.get("version"))
try:
response = executor.run(action_call)
except ActionExecutionRejection as e:
@@ -93,6 +95,32 @@ def endpoint_app(cors_origins=None,
return app
+def check_version_compatibility(core_version):
+ """Compare the versions of rasa_core and rasa_core_sdk and raise
+ a warning if they are not compatible.
+ The version check relies on the version string being of the form
+ 'x.y.z' and compared whether the numbers x and y are the same for both
+ rasa_core and rasa_core_sdk.
+ Args:
+ core_version - string containing the version of rasa_core that
+ is making the call to the action server.
+ Returns:
+ Nothing
+ """
+ if not core_version==sdk_version:
+ for core_c, sdk_c in zip(core_version.split('.')[:-1],
+ sdk_version.split('.')[:-1]):
+ if core_c != sdk_c:
+ logger.warning("Your version of rasa_core and rasa_core_sdk "
+ "might not be compatible. You are current running rasa_core "
+ "version {} and rasa_core_sdk version {}.\n"
+ "To ensure compatibility use the same version for both "
+ "modulo the last number, i.e. using version A.B.x the numbers "
+ "A and B should be identical for both rasa_core and "
+ "rasa_core_sdk.".format(core_version, sdk_version))
+ break
+
+
if __name__ == '__main__':
# Running as standalone python application
arg_parser = create_argument_parser()
