Fix js error in gui, Revert to_image in gui

This commit is contained in:
Heiner Lohaus 2024-05-19 01:33:05 +02:00
parent dc77a1a7ff
commit 4bab6009c1
2 changed files with 3 additions and 3 deletions

View File

@ -302,7 +302,7 @@ const prepare_messages = (messages, message_index = -1) => {
} }
messages.forEach((new_message) => { messages.forEach((new_message) => {
// Include only not regenerated messages // Include only not regenerated messages
if (!new_message.regenerate) { if (new_message && !new_message.regenerate) {
// Remove generated images from history // Remove generated images from history
new_message.content = filter_message(new_message.content); new_message.content = filter_message(new_message.content);
delete new_message.provider; delete new_message.provider;

View File

@ -1,6 +1,6 @@
import json import json
from flask import request, Flask from flask import request, Flask
from g4f.image import is_allowed_extension, to_bytes from g4f.image import is_allowed_extension, to_image
from .api import Api from .api import Api
class Backend_Api(Api): class Backend_Api(Api):
@ -79,7 +79,7 @@ class Backend_Api(Api):
if "file" in request.files: if "file" in request.files:
file = request.files['file'] file = request.files['file']
if file.filename != '' and is_allowed_extension(file.filename): if file.filename != '' and is_allowed_extension(file.filename):
kwargs['image'] = to_bytes(file.stream) kwargs['image'] = to_image(file.stream, file.filename.endswith('.svg'))
kwargs['image_name'] = file.filename kwargs['image_name'] = file.filename
if "json" in request.form: if "json" in request.form:
json_data = json.loads(request.form['json']) json_data = json.loads(request.form['json'])