rasa-pro 3.10.7.dev2__py3-none-any.whl → 3.10.7.dev4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rasa-pro might be problematic. Click here for more details.

@@ -37,7 +37,11 @@ class SocketBlueprint(Blueprint):
37
37
  :param options: Options to be used while registering the
38
38
  blueprint into the app.
39
39
  """
40
- self.ctx.sio.attach(app, self.ctx.socketio_path)
40
+ if self.ctx.socketio_path:
41
+ path = self.ctx.socketio_path
42
+ else:
43
+ path = options.get("url_prefix", "/socket.io")
44
+ self.ctx.sio.attach(app, path)
41
45
  super().register(app, options)
42
46
 
43
47
 
@@ -2,7 +2,7 @@ import asyncio
2
2
  import os
3
3
  from typing import Any, Dict, Optional
4
4
  import dotenv
5
- from sanic import Sanic, response
5
+ from sanic import Blueprint, Sanic, response
6
6
  from sanic.response import json
7
7
  from sanic.exceptions import NotFound
8
8
  from sanic.request import Request
@@ -35,12 +35,6 @@ dotenv.load_dotenv()
35
35
 
36
36
  structlogger = structlog.get_logger()
37
37
 
38
- # configure the sanice application
39
- app = Sanic("RasaManager")
40
- # attach the socketio server to the sanic app
41
- sio = AsyncServer(async_mode="sanic", cors_allowed_origins=[])
42
- sio.attach(app, "/socket.io")
43
-
44
38
 
45
39
  # A simple in-memory store for training sessions and running bots
46
40
  trainings: Dict[str, TrainingSession] = {}
@@ -59,26 +53,30 @@ def prepare_working_directories() -> None:
59
53
  def cleanup_training_processes() -> None:
60
54
  """Terminate all running training processes."""
61
55
  structlogger.debug("model_trainer.cleanup_processes.started")
62
- for training in trainings.values():
56
+ running = list(trainings.values())
57
+ for training in running:
63
58
  terminate_training(training)
64
59
 
65
60
 
66
61
  def cleanup_bot_processes() -> None:
67
62
  """Terminate all running bot processes."""
68
63
  structlogger.debug("model_runner.cleanup_processes.started")
69
- for bot in running_bots.values():
64
+ running = list(running_bots.values())
65
+ for bot in running:
70
66
  terminate_bot(bot)
71
67
 
72
68
 
73
69
  def update_status_of_all_trainings() -> None:
74
70
  """Update the status of all training processes."""
75
- for training in trainings.values():
71
+ running = list(trainings.values())
72
+ for training in running:
76
73
  update_training_status(training)
77
74
 
78
75
 
79
76
  async def update_status_of_all_bots() -> None:
80
77
  """Update the status of all bot processes."""
81
- for bot in running_bots.values():
78
+ running = list(running_bots.values())
79
+ for bot in running:
82
80
  await update_bot_status(bot)
83
81
 
84
82
 
@@ -138,295 +136,329 @@ async def continuously_update_process_status() -> None:
138
136
  await asyncio.sleep(1)
139
137
 
140
138
 
141
- @app.before_server_stop
142
- async def cleanup_processes(app: Sanic, loop: asyncio.AbstractEventLoop) -> None:
143
- """Terminate all running processes before the server stops."""
144
- structlogger.debug("model_api.cleanup_processes.started")
145
- cleanup_training_processes()
146
- cleanup_bot_processes()
139
+ def internal_blueprint() -> Blueprint:
140
+ """Create a blueprint for the model manager API."""
141
+ bp = Blueprint("model_api_internal")
147
142
 
143
+ @bp.before_server_stop
144
+ async def cleanup_processes(app: Sanic, loop: asyncio.AbstractEventLoop) -> None:
145
+ """Terminate all running processes before the server stops."""
146
+ structlogger.debug("model_api.cleanup_processes.started")
147
+ cleanup_training_processes()
148
+ cleanup_bot_processes()
148
149
 
149
- @app.get("/")
150
- async def health(request: Request) -> response.HTTPResponse:
151
- return json(
152
- {
153
- "status": "ok",
154
- "bots": [
155
- {
156
- "deployment_id": bot.deployment_id,
157
- "status": bot.status,
158
- "internal_url": bot.internal_url,
159
- "url": bot.url,
160
- }
161
- for bot in running_bots.values()
162
- ],
163
- "trainings": [
150
+ @bp.get("/")
151
+ async def health(request: Request) -> response.HTTPResponse:
152
+ return json(
153
+ {
154
+ "status": "ok",
155
+ "bots": [
156
+ {
157
+ "deployment_id": bot.deployment_id,
158
+ "status": bot.status,
159
+ "internal_url": bot.internal_url,
160
+ "url": bot.url,
161
+ }
162
+ for bot in running_bots.values()
163
+ ],
164
+ "trainings": [
165
+ {
166
+ "training_id": training.training_id,
167
+ "assistant_id": training.assistant_id,
168
+ "client_id": training.client_id,
169
+ "progress": training.progress,
170
+ "status": training.status,
171
+ }
172
+ for training in trainings.values()
173
+ ],
174
+ }
175
+ )
176
+
177
+ @bp.get("/training")
178
+ async def get_training_list(request: Request) -> response.HTTPResponse:
179
+ """Return a list of all training sessions for an assistant."""
180
+ assistant_id = request.args.get("assistant_id")
181
+ sessions = [
182
+ {
183
+ "training_id": session.training_id,
184
+ "assistant_id": session.assistant_id,
185
+ "client_id": session.client_id,
186
+ "training_runtime": "self",
187
+ "status": session.status,
188
+ "bot_config": None,
189
+ "logs": None,
190
+ "metadata": None,
191
+ "model": None,
192
+ "runtime_metadata": None,
193
+ }
194
+ for session in trainings.values()
195
+ if session.assistant_id == assistant_id
196
+ ]
197
+ return json({"training_sessions": sessions, "total_number": len(sessions)})
198
+
199
+ @bp.post("/training")
200
+ async def start_training(request: Request) -> response.HTTPResponse:
201
+ """Start a new training session."""
202
+ data = request.json
203
+ training_id: Optional[str] = data.get("id")
204
+ assistant_id: Optional[str] = data.get("assistant_id")
205
+ client_id: Optional[str] = data.get("client_id")
206
+
207
+ if training_id in trainings:
208
+ # fail, because there apparently is already a training with this id
209
+ return json({"message": "Training with this id already exists"}, status=409)
210
+
211
+ if not assistant_id:
212
+ return json({"message": "Assistant id is required"}, status=400)
213
+
214
+ if not training_id:
215
+ return json({"message": "Training id is required"}, status=400)
216
+
217
+ try:
218
+ training_session = run_training(
219
+ training_id=training_id,
220
+ assistant_id=assistant_id,
221
+ client_id=client_id,
222
+ data=data,
223
+ )
224
+ trainings[training_id] = training_session
225
+ return json({"training_id": training_id})
226
+ except Exception as e:
227
+ return json({"message": str(e)}, status=500)
228
+
229
+ @bp.get("/training/<training_id>")
230
+ async def get_training(request: Request, training_id: str) -> response.HTTPResponse:
231
+ """Return the status of a training session."""
232
+ if training := trainings.get(training_id):
233
+ return json(
164
234
  {
165
- "training_id": training.training_id,
235
+ "training_id": training_id,
166
236
  "assistant_id": training.assistant_id,
167
237
  "client_id": training.client_id,
168
238
  "progress": training.progress,
169
239
  "status": training.status,
170
240
  }
171
- for training in trainings.values()
172
- ],
173
- }
174
- )
175
-
241
+ )
242
+ else:
243
+ return json({"message": "Training not found"}, status=404)
244
+
245
+ @bp.delete("/training/<training_id>")
246
+ async def stop_training(
247
+ request: Request, training_id: str
248
+ ) -> response.HTTPResponse:
249
+ # this is a no-op if the training is already done
250
+ if not (training := trainings.get(training_id)):
251
+ return json({"message": "Training session not found"}, status=404)
176
252
 
177
- @app.get("/training")
178
- async def get_training_list(request: Request) -> response.HTTPResponse:
179
- """Return a list of all training sessions for an assistant."""
180
- assistant_id = request.args.get("assistant_id")
181
- sessions = [
182
- {
183
- "training_id": session.training_id,
184
- "assistant_id": session.assistant_id,
185
- "client_id": session.client_id,
186
- "training_runtime": "self",
187
- "status": session.status,
188
- "bot_config": None,
189
- "logs": None,
190
- "metadata": None,
191
- "model": None,
192
- "runtime_metadata": None,
193
- }
194
- for session in trainings.values()
195
- if session.assistant_id == assistant_id
196
- ]
197
- return json({"training_sessions": sessions, "total_number": len(sessions)})
198
-
199
-
200
- @app.post("/training")
201
- async def start_training(request: Request) -> response.HTTPResponse:
202
- """Start a new training session."""
203
- data = request.json
204
- training_id: Optional[str] = data.get("id")
205
- assistant_id: Optional[str] = data.get("assistant_id")
206
- client_id: Optional[str] = data.get("client_id")
207
-
208
- if training_id in trainings:
209
- # fail, because there apparently is already a training with this id
210
- return json({"message": "Training with this id already exists"}, status=409)
211
-
212
- if not assistant_id:
213
- return json({"message": "Assistant id is required"}, status=400)
214
-
215
- if not training_id:
216
- return json({"message": "Training id is required"}, status=400)
217
-
218
- try:
219
- training_session = run_training(
220
- training_id=training_id,
221
- assistant_id=assistant_id,
222
- client_id=client_id,
223
- data=data,
224
- )
225
- trainings[training_id] = training_session
253
+ terminate_training(training)
226
254
  return json({"training_id": training_id})
227
- except Exception as e:
228
- return json({"message": str(e)}, status=500)
229
255
 
256
+ @bp.get("/training/<training_id>/download_url")
257
+ async def get_training_download_url(
258
+ request: Request, training_id: str
259
+ ) -> response.HTTPResponse:
260
+ # Provide a URL for downloading the training log
261
+ # check object key that is passed in as a query parameter
262
+ key = request.args.get("object_key")
263
+ if "model.tar.gz" in key:
264
+ return get_training_model_url(request, training_id)
265
+ return get_log_url(request, training_id)
266
+
267
+ @bp.post("/bot")
268
+ async def start_bot(request: Request) -> response.HTTPResponse:
269
+ data = request.json
270
+ deployment_id: Optional[str] = data.get("deployment_id")
271
+ assumed_model_path: Optional[str] = data.get("model_path")
272
+
273
+ if deployment_id in running_bots:
274
+ # fail, because there apparently is already a bot running with this id
275
+ return json(
276
+ {"message": "Bot with this deployment id already exists"}, status=409
277
+ )
278
+
279
+ if not deployment_id:
280
+ return json({"message": "Deployment id is required"}, status=400)
281
+
282
+ if not assumed_model_path:
283
+ return json({"message": "Model path is required"}, status=400)
284
+
285
+ training_id = assumed_model_path.split("/")[-3]
286
+ training_base_path = train_path(training_id)
287
+ if not os.path.exists(f"{training_base_path}/models"):
288
+ return json(
289
+ {"message": "Model not found, for the given training id"},
290
+ status=404,
291
+ )
292
+
293
+ base_url_path = base_server_url(request)
294
+ try:
295
+ bot_session = run_bot(deployment_id, training_base_path, base_url_path)
296
+ running_bots[deployment_id] = bot_session
297
+ return json(
298
+ {
299
+ "deployment_id": deployment_id,
300
+ "status": bot_session.status,
301
+ "url": bot_session.url,
302
+ }
303
+ )
304
+ except Exception as e:
305
+ return json({"message": str(e)}, status=500)
230
306
 
231
- @app.get("/training/<training_id>")
232
- async def get_training(request: Request, training_id: str) -> response.HTTPResponse:
233
- """Return the status of a training session."""
234
- if training := trainings.get(training_id):
235
- return json(
236
- {
237
- "training_id": training_id,
238
- "assistant_id": training.assistant_id,
239
- "client_id": training.client_id,
240
- "progress": training.progress,
241
- "status": training.status,
242
- }
243
- )
244
- else:
245
- return json({"message": "Training not found"}, status=404)
246
-
247
-
248
- @app.delete("/training/<training_id>")
249
- async def stop_training(request: Request, training_id: str) -> response.HTTPResponse:
250
- # this is a no-op if the training is already done
251
- if not (training := trainings.get(training_id)):
252
- return json({"message": "Training session not found"}, status=404)
253
-
254
- terminate_training(training)
255
- return json({"training_id": training_id})
256
-
257
-
258
- @app.get("/training/<training_id>/download_url")
259
- async def get_training_download_url(
260
- request: Request, training_id: str
261
- ) -> response.HTTPResponse:
262
- # Provide a URL for downloading the training log
263
- # check object key that is passed in as a query parameter
264
- key = request.args.get("object_key")
265
- if "model.tar.gz" in key:
266
- return get_training_model_url(request, training_id)
267
- return get_log_url(request, training_id)
268
-
307
+ @bp.delete("/bot/<deployment_id>")
308
+ async def stop_bot(request: Request, deployment_id: str) -> response.HTTPResponse:
309
+ bot = running_bots.get(deployment_id)
310
+ if bot is None:
311
+ return json({"message": "Bot not found"}, status=404)
269
312
 
270
- @app.post("/bot")
271
- async def start_bot(request: Request) -> response.HTTPResponse:
272
- data = request.json
273
- deployment_id: Optional[str] = data.get("deployment_id")
274
- assumed_model_path: Optional[str] = data.get("model_path")
313
+ terminate_bot(bot)
275
314
 
276
- if deployment_id in running_bots:
277
- # fail, because there apparently is already a bot running with this id
278
315
  return json(
279
- {"message": "Bot with this deployment id already exists"}, status=409
316
+ {"deployment_id": deployment_id, "status": bot.status, "url": bot.url}
280
317
  )
281
318
 
282
- if not deployment_id:
283
- return json({"message": "Deployment id is required"}, status=400)
284
-
285
- if not assumed_model_path:
286
- return json({"message": "Model path is required"}, status=400)
319
+ @bp.get("/bot/<deployment_id>")
320
+ async def get_bot(request: Request, deployment_id: str) -> response.HTTPResponse:
321
+ bot = running_bots.get(deployment_id)
322
+ if bot is None:
323
+ return json({"message": "Bot not found"}, status=404)
287
324
 
288
- training_id = assumed_model_path.split("/")[-3]
289
- training_base_path = train_path(training_id)
290
- if not os.path.exists(f"{training_base_path}/models"):
291
- return json(
292
- {"message": "Model not found, for the given training id"},
293
- status=404,
294
- )
295
-
296
- base_url_path = base_server_url(request)
297
- try:
298
- bot_session = run_bot(deployment_id, training_base_path, base_url_path)
299
- running_bots[deployment_id] = bot_session
300
325
  return json(
301
326
  {
302
327
  "deployment_id": deployment_id,
303
- "status": bot_session.status,
304
- "url": bot_session.url,
328
+ "status": bot.status,
329
+ "url": bot.url,
305
330
  }
306
331
  )
307
- except Exception as e:
308
- return json({"message": str(e)}, status=500)
309
-
310
-
311
- @app.delete("/bot/<deployment_id>")
312
- async def stop_bot(request: Request, deployment_id: str) -> response.HTTPResponse:
313
- bot = running_bots.get(deployment_id)
314
- if bot is None:
315
- return json({"message": "Bot not found"}, status=404)
316
-
317
- terminate_bot(bot)
318
-
319
- return json({"deployment_id": deployment_id, "status": bot.status, "url": bot.url})
320
-
321
-
322
- @app.get("/bot/<deployment_id>")
323
- async def get_bot(request: Request, deployment_id: str) -> response.HTTPResponse:
324
- bot = running_bots.get(deployment_id)
325
- if bot is None:
326
- return json({"message": "Bot not found"}, status=404)
327
-
328
- return json(
329
- {
330
- "deployment_id": deployment_id,
331
- "status": bot.status,
332
- "url": bot.url,
333
- }
334
- )
335
-
336
-
337
- @app.get("/bot/<deployment_id>/download_url")
338
- async def get_bot_download_url(
339
- request: Request, deployment_id: str
340
- ) -> response.HTTPResponse:
341
- return get_log_url(request, deployment_id)
342
-
343
-
344
- @app.get("/bot/<deployment_id>/logs")
345
- async def get_bot_logs(request: Request, deployment_id: str) -> response.HTTPResponse:
346
- return get_log_url(request, deployment_id)
347
-
348
-
349
- @app.get("/bot")
350
- async def list_bots(request: Request) -> response.HTTPResponse:
351
- bots = [
352
- {
353
- "deployment_id": bot.deployment_id,
354
- "status": bot.status,
355
- "url": bot.url,
356
- }
357
- for bot in running_bots.values()
358
- ]
359
- return json({"deployment_sessions": bots, "total_number": len(bots)})
360
-
361
-
362
- @app.route("/logs/<path:path>")
363
- async def get_training_logs(request: Request, path: str) -> response.HTTPResponse:
364
- try:
365
- headers = {"Content-Disposition": 'attachment; filename="log.txt"'}
366
- return await response.file(
367
- os.path.join(logs_base_path(), path), headers=headers
368
- )
369
- except NotFound:
370
- return json({"message": "Log not found"}, status=404)
371
-
372
-
373
- @app.route("/models/<path:path>")
374
- async def send_model(request: Request, path: str) -> response.HTTPResponse:
375
- try:
376
- return await response.file(models_path(path))
377
- except NotFound:
378
- return json({"message": "Model not found"}, status=404)
379
332
 
333
+ @bp.get("/bot/<deployment_id>/download_url")
334
+ async def get_bot_download_url(
335
+ request: Request, deployment_id: str
336
+ ) -> response.HTTPResponse:
337
+ return get_log_url(request, deployment_id)
338
+
339
+ @bp.get("/bot/<deployment_id>/logs")
340
+ async def get_bot_logs(
341
+ request: Request, deployment_id: str
342
+ ) -> response.HTTPResponse:
343
+ return get_log_url(request, deployment_id)
344
+
345
+ @bp.get("/bot")
346
+ async def list_bots(request: Request) -> response.HTTPResponse:
347
+ bots = [
348
+ {
349
+ "deployment_id": bot.deployment_id,
350
+ "status": bot.status,
351
+ "url": bot.url,
352
+ }
353
+ for bot in running_bots.values()
354
+ ]
355
+ return json({"deployment_sessions": bots, "total_number": len(bots)})
380
356
 
381
- @sio.on("connect")
382
- async def socketio_websocket_traffic(
383
- sid: str, environ: Dict, auth: Optional[Dict]
384
- ) -> bool:
385
- """Bridge websockets between user chat socket and bot server."""
386
- structlogger.debug("model_runner.user_connected", sid=sid)
387
- deployment_id = auth.get("deployment_id") if auth else None
357
+ return bp
388
358
 
389
- if deployment_id is None:
390
- structlogger.error("model_runner.bot_no_deployment_id", sid=sid)
391
- return False
392
359
 
393
- bot = running_bots.get(deployment_id)
394
- if bot is None:
395
- structlogger.error("model_runner.bot_not_found", deployment_id=deployment_id)
396
- return False
360
+ def external_blueprint() -> Blueprint:
361
+ """Create a blueprint for the model manager API."""
362
+ from rasa.core.channels.socketio import SocketBlueprint
397
363
 
398
- client = await create_bridge_client(sio, bot.internal_url, sid, deployment_id)
364
+ sio = AsyncServer(async_mode="sanic", cors_allowed_origins=[])
365
+ bp = SocketBlueprint(sio, "", "model_api_external")
399
366
 
400
- if client.sid is not None:
401
- structlogger.debug(
402
- "model_runner.bot_connection_established", deployment_id=deployment_id
403
- )
404
- socket_proxy_clients[sid] = client
405
- return True
406
- else:
407
- structlogger.error(
408
- "model_runner.bot_connection_failed", deployment_id=deployment_id
367
+ @bp.get("/health")
368
+ async def health(request: Request) -> response.HTTPResponse:
369
+ return json(
370
+ {
371
+ "status": "ok",
372
+ "bots": [
373
+ {
374
+ "deployment_id": bot.deployment_id,
375
+ "status": bot.status,
376
+ "internal_url": bot.internal_url,
377
+ "url": bot.url,
378
+ }
379
+ for bot in running_bots.values()
380
+ ],
381
+ "trainings": [
382
+ {
383
+ "training_id": training.training_id,
384
+ "assistant_id": training.assistant_id,
385
+ "client_id": training.client_id,
386
+ "progress": training.progress,
387
+ "status": training.status,
388
+ }
389
+ for training in trainings.values()
390
+ ],
391
+ }
409
392
  )
410
- return False
411
-
412
-
413
- @sio.on("disconnect")
414
- async def disconnect(sid: str) -> None:
415
- structlogger.debug("model_runner.bot_disconnect", sid=sid)
416
- if sid in socket_proxy_clients:
417
- await socket_proxy_clients[sid].disconnect()
418
- del socket_proxy_clients[sid]
419
-
420
-
421
- @sio.on("*")
422
- async def handle_message(event: str, sid: str, data: Dict[str, Any]) -> None:
423
- # bridge both, incoming messages to the bot_url but also
424
- # send the response back to the client. both need to happen
425
- # in parallel in an async way
426
-
427
- client = socket_proxy_clients.get(sid)
428
- if client is None:
429
- structlogger.error("model_runner.bot_not_connected", sid=sid)
430
- return
431
393
 
432
- await client.emit(event, data)
394
+ @bp.route("/logs/<path:path>")
395
+ async def get_training_logs(request: Request, path: str) -> response.HTTPResponse:
396
+ try:
397
+ headers = {"Content-Disposition": 'attachment; filename="log.txt"'}
398
+ return await response.file(
399
+ os.path.join(logs_base_path(), path), headers=headers
400
+ )
401
+ except NotFound:
402
+ return json({"message": "Log not found"}, status=404)
403
+
404
+ @bp.route("/models/<path:path>")
405
+ async def send_model(request: Request, path: str) -> response.HTTPResponse:
406
+ try:
407
+ return await response.file(models_path(path))
408
+ except NotFound:
409
+ return json({"message": "Model not found"}, status=404)
410
+
411
+ @sio.on("connect")
412
+ async def socketio_websocket_traffic(
413
+ sid: str, environ: Dict, auth: Optional[Dict]
414
+ ) -> bool:
415
+ """Bridge websockets between user chat socket and bot server."""
416
+ structlogger.debug("model_runner.user_connected", sid=sid)
417
+ deployment_id = auth.get("deployment_id") if auth else None
418
+
419
+ if deployment_id is None:
420
+ structlogger.error("model_runner.bot_no_deployment_id", sid=sid)
421
+ return False
422
+
423
+ bot = running_bots.get(deployment_id)
424
+ if bot is None:
425
+ structlogger.error(
426
+ "model_runner.bot_not_found", deployment_id=deployment_id
427
+ )
428
+ return False
429
+
430
+ client = await create_bridge_client(sio, bot.internal_url, sid, deployment_id)
431
+
432
+ if client.sid is not None:
433
+ structlogger.debug(
434
+ "model_runner.bot_connection_established", deployment_id=deployment_id
435
+ )
436
+ socket_proxy_clients[sid] = client
437
+ return True
438
+ else:
439
+ structlogger.error(
440
+ "model_runner.bot_connection_failed", deployment_id=deployment_id
441
+ )
442
+ return False
443
+
444
+ @sio.on("disconnect")
445
+ async def disconnect(sid: str) -> None:
446
+ structlogger.debug("model_runner.bot_disconnect", sid=sid)
447
+ if sid in socket_proxy_clients:
448
+ await socket_proxy_clients[sid].disconnect()
449
+ del socket_proxy_clients[sid]
450
+
451
+ @sio.on("*")
452
+ async def handle_message(event: str, sid: str, data: Dict[str, Any]) -> None:
453
+ # bridge both, incoming messages to the bot_url but also
454
+ # send the response back to the client. both need to happen
455
+ # in parallel in an async way
456
+
457
+ client = socket_proxy_clients.get(sid)
458
+ if client is None:
459
+ structlogger.error("model_runner.bot_not_connected", sid=sid)
460
+ return
461
+
462
+ await client.emit(event, data)
463
+
464
+ return bp
rasa/model_service.py CHANGED
@@ -1,9 +1,12 @@
1
1
  import os
2
2
  import logging
3
3
 
4
+ from sanic import Sanic
4
5
  import structlog
5
6
 
7
+ from rasa.core.utils import list_routes
6
8
  from rasa.model_manager import model_api
9
+ from rasa.model_manager.config import SERVER_BASE_URL
7
10
  from rasa.utils.common import configure_logging_and_warnings
8
11
  import rasa.utils.licensing
9
12
 
@@ -12,6 +15,16 @@ structlogger = structlog.get_logger()
12
15
  MODEL_SERVICE_PORT = 8000
13
16
 
14
17
 
18
+ def url_prefix_from_base_url() -> str:
19
+ """Return the path prefix from the base URL."""
20
+ if SERVER_BASE_URL:
21
+ from urllib.parse import urlparse
22
+
23
+ return urlparse(SERVER_BASE_URL).path
24
+
25
+ return ""
26
+
27
+
15
28
  def main() -> None:
16
29
  """Start the Rasa Model Manager server.
17
30
 
@@ -36,8 +49,17 @@ def main() -> None:
36
49
  structlogger.debug("model_training.starting_server", port=MODEL_SERVICE_PORT)
37
50
  structlogger.debug("model_running.starting_server", port=MODEL_SERVICE_PORT)
38
51
 
39
- model_api.app.add_task(model_api.continuously_update_process_status)
40
- model_api.app.run(host="0.0.0.0", port=MODEL_SERVICE_PORT, legacy=True)
52
+ url_prefix = url_prefix_from_base_url()
53
+ # configure the sanice application
54
+ app = Sanic("RasaModelService")
55
+ app.add_task(model_api.continuously_update_process_status)
56
+ app.blueprint(model_api.external_blueprint(), url_prefix=url_prefix)
57
+ app.blueprint(model_api.internal_blueprint())
58
+
59
+ # list all routes
60
+ list_routes(app)
61
+
62
+ app.run(host="0.0.0.0", port=MODEL_SERVICE_PORT, legacy=True)
41
63
 
42
64
 
43
65
  if __name__ == "__main__":
rasa/version.py CHANGED
@@ -1,3 +1,3 @@
1
1
  # this file will automatically be changed,
2
2
  # do not add anything but the version number here!
3
- __version__ = "3.10.7.dev2"
3
+ __version__ = "3.10.7.dev4"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rasa-pro
3
- Version: 3.10.7.dev2
3
+ Version: 3.10.7.dev4
4
4
  Summary: State-of-the-art open-core Conversational AI framework for Enterprises that natively leverages generative AI for effortless assistant development.
5
5
  Home-page: https://rasa.com
6
6
  Keywords: nlp,machine-learning,machine-learning-library,bot,bots,botkit,rasa conversational-agents,conversational-ai,chatbot,chatbot-framework,bot-framework
@@ -251,7 +251,7 @@ rasa/core/channels/rasa_chat.py,sha256=XGZ7QLyQHhB-m7EjetDNEBSjAa2mEFqU-e-FuS9z3
251
251
  rasa/core/channels/rest.py,sha256=zeUAKr0UyeJVt_UFfri7GAYcGzTdG-mBwwN3zLVzjpc,7129
252
252
  rasa/core/channels/rocketchat.py,sha256=HWOMxXLuwadYEYIMMP-z6RqAJzMGZDLklpgqLOipXF0,5998
253
253
  rasa/core/channels/slack.py,sha256=3b8OZQ_gih5XBwhQ1q4BbBUC1SCAPaO9AoJEn2NaoQE,24405
254
- rasa/core/channels/socketio.py,sha256=k0b6aWE8gqhXBaLN7Sa5qaxqrWEFqf95ZeN-fX9bhPA,10675
254
+ rasa/core/channels/socketio.py,sha256=Lo342YwWm2O5PciEUXAXA3NRJQ5yi3ZXosRXItyzsc4,10807
255
255
  rasa/core/channels/telegram.py,sha256=XvzU7KAgjmRcu2vUJ-5L2eYAAuYBqtcYlhq1Jo6kLns,10649
256
256
  rasa/core/channels/twilio.py,sha256=c63uFLVKaK4Fj8MAn9BSQtxiV_Ezq4POezHo8zWIoiw,5938
257
257
  rasa/core/channels/twilio_voice.py,sha256=SrtNZOk3Yuk_QuUk45Hadj3PGvmwD0jeSzF90GbiUV0,13244
@@ -484,12 +484,12 @@ rasa/markers/validate.py,sha256=YypXKRS87xxrMMEz9HpAQzYJUwg0OPbczMXBRNjlJq4,709
484
484
  rasa/model.py,sha256=GH1-N6Po3gL3nwfa9eGoN2bMRNMrn4f3mi17-osW3T0,3491
485
485
  rasa/model_manager/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
486
486
  rasa/model_manager/config.py,sha256=LCzRoV78bLX_FREW7hfQLsQepupoTs1m-CnK3u_D01s,349
487
- rasa/model_manager/model_api.py,sha256=Eoq6TBjYaqB-9arLIH1Uz_pb7ZagQ8qYDkUAx6DDARE,13926
487
+ rasa/model_manager/model_api.py,sha256=2c0JL-tWn7ayn2EjVes-2tVQHj_FzULmpYC7IpOSJEI,16261
488
488
  rasa/model_manager/runner_service.py,sha256=aMupR7t0EEy2yOGT5cR_6kluApnwOiiGkjyIVYxdsMk,5553
489
489
  rasa/model_manager/socket_bridge.py,sha256=f-dhsV8xYaENXVZT5OOzkMdpSPPPxFEzsQqNJAuktxQ,1390
490
490
  rasa/model_manager/trainer_service.py,sha256=7LP_EsLQt-P2oqO1AgqbgIcTC515eCW58BamDkDjJjw,7856
491
491
  rasa/model_manager/utils.py,sha256=-DJUcgRiyQZsszlOYlww-OGaAof8CIopbsOxZmeZ9NY,819
492
- rasa/model_service.py,sha256=ZULb8jJHPQYIWtMVv5cCYExJdBnAFs4Wv89p1bVGzqo,1212
492
+ rasa/model_service.py,sha256=x6vFrxc_VH8dh1I5Tkw2cbUimbqoxpiFQKpcem9tSg8,1818
493
493
  rasa/model_testing.py,sha256=h0QUpJu6p_TDse3aHjCfYwI6OGH47b3Iuo5Ot0HQADM,14959
494
494
  rasa/model_training.py,sha256=sFdrizWu8JZZDGrMjI6_0OaY9dK-msOShWpgOOCGZzg,20601
495
495
  rasa/nlu/__init__.py,sha256=D0IYuTK_ZQ_F_9xsy0bXxVCAtU62Fzvp8S7J9tmfI_c,123
@@ -727,9 +727,9 @@ rasa/utils/train_utils.py,sha256=f1NWpp5y6al0dzoQyyio4hc4Nf73DRoRSHDzEK6-C4E,212
727
727
  rasa/utils/url_tools.py,sha256=JQcHL2aLqLHu82k7_d9imUoETCm2bmlHaDpOJ-dKqBc,1218
728
728
  rasa/utils/yaml.py,sha256=KjbZq5C94ZP7Jdsw8bYYF7HASI6K4-C_kdHfrnPLpSI,2000
729
729
  rasa/validator.py,sha256=HM0ZIWjo3JRt2FMIfgNI_s932OABOSXkflm-rFTNkvY,62608
730
- rasa/version.py,sha256=_xRWomNdCH1OVLVcaYC_a-LVDeKGrYo4iDznhzakf3k,122
731
- rasa_pro-3.10.7.dev2.dist-info/METADATA,sha256=exaKQ2A81Kk0kydkgvN3ipZyApPtmatZ96AU2LhlpIo,28217
732
- rasa_pro-3.10.7.dev2.dist-info/NOTICE,sha256=7HlBoMHJY9CL2GlYSfTQ-PZsVmLmVkYmMiPlTjhuCqA,218
733
- rasa_pro-3.10.7.dev2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
734
- rasa_pro-3.10.7.dev2.dist-info/entry_points.txt,sha256=ckJ2SfEyTPgBqj_I6vm_tqY9dZF_LAPJZA335Xp0Q9U,43
735
- rasa_pro-3.10.7.dev2.dist-info/RECORD,,
730
+ rasa/version.py,sha256=8PjlwS5fwFAp76cEyd2sO2WTKsD27O3oI34eANowHJQ,122
731
+ rasa_pro-3.10.7.dev4.dist-info/METADATA,sha256=XPkuyA-6VxXeaHYLP43ku28tp_o9KSlk6WpxvpBRTSw,28217
732
+ rasa_pro-3.10.7.dev4.dist-info/NOTICE,sha256=7HlBoMHJY9CL2GlYSfTQ-PZsVmLmVkYmMiPlTjhuCqA,218
733
+ rasa_pro-3.10.7.dev4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
734
+ rasa_pro-3.10.7.dev4.dist-info/entry_points.txt,sha256=ckJ2SfEyTPgBqj_I6vm_tqY9dZF_LAPJZA335Xp0Q9U,43
735
+ rasa_pro-3.10.7.dev4.dist-info/RECORD,,