mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-09 20:50:58 +00:00
feat(agent-platform): add bot route dry-run
This commit is contained in:
@@ -38,6 +38,33 @@ class BotsRouterGroup(group.RouterGroup):
|
||||
logs, total_count = await self.ap.bot_service.list_event_logs(bot_uuid, from_index, max_count)
|
||||
return self.success(data={'logs': logs, 'total_count': total_count})
|
||||
|
||||
async def _dry_run_event_route(bot_uuid: str) -> str:
|
||||
json_data = await quart.request.json
|
||||
if not isinstance(json_data, dict):
|
||||
return self.http_status(400, -1, 'invalid request body')
|
||||
|
||||
result = await self.ap.bot_service.dry_run_event_route(
|
||||
bot_uuid=bot_uuid,
|
||||
event_type=json_data.get('event_type'),
|
||||
event_data=json_data.get('event_data', json_data.get('payload')),
|
||||
context=json_data.get('context'),
|
||||
event_bindings=json_data.get('event_bindings'),
|
||||
)
|
||||
return self.success(data=result)
|
||||
|
||||
self.route(
|
||||
'/<bot_uuid>/event-routes/dry-run',
|
||||
methods=['POST'],
|
||||
auth_type=group.AuthType.USER_TOKEN_OR_API_KEY,
|
||||
)(_dry_run_event_route)
|
||||
# Backward-compatible alias for early local clients/tests created before
|
||||
# the product route naming was settled.
|
||||
self.route(
|
||||
'/<bot_uuid>/event_route/dry_run',
|
||||
methods=['POST'],
|
||||
auth_type=group.AuthType.USER_TOKEN_OR_API_KEY,
|
||||
)(_dry_run_event_route)
|
||||
|
||||
@self.route('/<bot_uuid>/send_message', methods=['POST'], auth_type=group.AuthType.API_KEY)
|
||||
async def _(bot_uuid: str) -> str:
|
||||
json_data = await quart.request.json
|
||||
|
||||
Reference in New Issue
Block a user