From c4e87c109e7e7b506740f8efc1f2bb164007f226 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Fri, 17 Feb 2023 00:24:27 -0300 Subject: [PATCH] Include the bot's image as base64 This is needed for Colab. --- modules/html_generator.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/html_generator.py b/modules/html_generator.py index 7ddfdbd1..669e525d 100644 --- a/modules/html_generator.py +++ b/modules/html_generator.py @@ -4,6 +4,7 @@ This is a library for formatting GPT-4chan and chat outputs as nice HTML. ''' +import base64 import copy import re from pathlib import Path @@ -260,7 +261,12 @@ def generate_chat_html(history, name1, name2, character): ]: if Path(i).exists(): - img = f'' + with open(i, "rb") as image_file: + encoded_string = base64.b64encode(image_file.read()) + if i.endswith('png'): + img = f'' + elif i.endswith('jpg') or i.endswith('jpeg'): + img = f'' break img_me = ''