From 471dee584981f499399e853c8da619ca60ceb3b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?th=E1=BB=8Bnh?= Date: Thu, 14 Nov 2024 15:05:58 +0700 Subject: [PATCH] Change notification response format to {notification:{prompt, params}} --- backend/utils/plugins.py | 20 ++++++++++---------- plugins/example/basic/mentor.py | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/backend/utils/plugins.py b/backend/utils/plugins.py index d2be9de22..5a5a2fea0 100644 --- a/backend/utils/plugins.py +++ b/backend/utils/plugins.py @@ -252,26 +252,26 @@ def _single(plugin: Plugin): # message message = response_data.get('message', '') - mentor = response_data.get('mentor', None) - print('Plugin', plugin.id, 'response:', message, mentor) + print('Plugin', plugin.id, 'response message:', message) if message and len(message) > 5: send_plugin_notification(token, plugin.name, plugin.id, message) results[plugin.id] = message # proactive_notification if plugin.has_capability("proactive_notification"): - mentor = response_data.get('mentor', None) - if mentor: - prompt = mentor.get('prompt', '') - if len(prompt) > 0 and len(prompt) <= 5000: - params = mentor.get('params', []) + noti = response_data.get('notification', None) + print('Plugin', plugin.id, 'response notification:', noti) + if noti: + prompt = noti.get('prompt', '') + if len(prompt) > 0 and len(prompt) <= 8000: + params = noti.get('params', []) message = get_metoring_message(uid, prompt, plugin.fitler_proactive_notification_scopes(params)) if message and len(message) > 5: send_plugin_notification(token, plugin.name, plugin.id, message) results[plugin.id] = message - elif len(prompt) > 5000: - send_plugin_notification(token, plugin.name, plugin.id, f"Prompt too long: {len(prompt)}/5000 characters. Please shorten.") - print(f"Plugin {plugin.id} prompt too long, length: {len(prompt)}/5000") + elif len(prompt) > 8000: + send_plugin_notification(token, plugin.name, plugin.id, f"Prompt too long: {len(prompt)}/8000 characters. Please shorten.") + print(f"Plugin {plugin.id} prompt too long, length: {len(prompt)}/8000") except Exception as e: print(f"Plugin integration error: {e}") diff --git a/plugins/example/basic/mentor.py b/plugins/example/basic/mentor.py index 06b8fe026..d2ceda041 100644 --- a/plugins/example/basic/mentor.py +++ b/plugins/example/basic/mentor.py @@ -74,7 +74,7 @@ def normalize(text): # 3. Respond with the format {mentor: {prompt, params}} return {'session_id': data.session_id, - 'mentor': {'prompt': prompt, + 'notification': {'prompt': prompt, 'params': ['user_name', 'user_facts']}} @ router.get('/setup/mentor', tags=['mentor'])