From 2efca58e5741c0721881f99f78f0a0dd788be309 Mon Sep 17 00:00:00 2001 From: saloui Date: Thu, 21 Dec 2023 19:02:00 +0100 Subject: [PATCH] enhanced API --- api/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/__init__.py b/api/__init__.py index 73195340..894c5cec 100644 --- a/api/__init__.py +++ b/api/__init__.py @@ -255,11 +255,13 @@ class LoLLMsAPI(LollmsApplication): @socketio.on('take_picture') def take_picture(): try: + self.info("Loading camera") if not PackageManager.check_package_installed("cv2"): PackageManager.install_package("opencv-python") import cv2 cap = cv2.VideoCapture(0) n = time.time() + self.info("Stand by for taking a shot in 2s") while(time.time()-n<2): _, frame = cap.read() _, frame = cap.read() @@ -273,14 +275,19 @@ class LoLLMsAPI(LollmsApplication): try: cv2.imwrite(str(save_path), frame) if not self.personality.processor is None: + self.info("Sending file to scripted persona") self.personality.processor.add_file(save_path, partial(self.process_chunk, client_id = request.sid)) # File saved successfully socketio.emit('picture_taken', {'status':True, 'progress': 100}) + self.info("File sent to scripted persona") else: + self.info("Sending file to persona") self.personality.add_file(save_path, partial(self.process_chunk, client_id = request.sid)) # File saved successfully socketio.emit('picture_taken', {'status':True, 'progress': 100}) + self.info("File sent to persona") except Exception as e: + trace_exception(e) # Error occurred while saving the file socketio.emit('picture_taken', {'status':False, 'error': str(e)})