fix: handle exceptions in get_file_base64 method
parent
0693ae99ca
commit
5bea2b2566
|
|
@ -71,6 +71,7 @@ class BaseImageToVideoNode(IImageToVideoNode):
|
||||||
'history_message': history_message, 'question': question}, {})
|
'history_message': history_message, 'question': question}, {})
|
||||||
|
|
||||||
def get_file_base64(self, image_url):
|
def get_file_base64(self, image_url):
|
||||||
|
try :
|
||||||
if isinstance(image_url, list):
|
if isinstance(image_url, list):
|
||||||
image_url = image_url[0].get('file_id')
|
image_url = image_url[0].get('file_id')
|
||||||
if isinstance(image_url, str) and not image_url.startswith('http'):
|
if isinstance(image_url, str) and not image_url.startswith('http'):
|
||||||
|
|
@ -82,6 +83,10 @@ class BaseImageToVideoNode(IImageToVideoNode):
|
||||||
encoded_bytes = base64.b64encode(file_bytes)
|
encoded_bytes = base64.b64encode(file_bytes)
|
||||||
return f'data:{content_type};base64,{encoded_bytes.decode()}'
|
return f'data:{content_type};base64,{encoded_bytes.decode()}'
|
||||||
return image_url
|
return image_url
|
||||||
|
except Exception as e:
|
||||||
|
raise ValueError(
|
||||||
|
gettext("Failed to obtain the image"))
|
||||||
|
|
||||||
|
|
||||||
def generate_history_ai_message(self, chat_record):
|
def generate_history_ai_message(self, chat_record):
|
||||||
for val in chat_record.details.values():
|
for val in chat_record.details.values():
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue