summaryrefslogtreecommitdiffstats
path: root/g4f/gui/server
diff options
context:
space:
mode:
Diffstat (limited to 'g4f/gui/server')
-rw-r--r--g4f/gui/server/backend.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/g4f/gui/server/backend.py b/g4f/gui/server/backend.py
index 2218452c..14f6cece 100644
--- a/g4f/gui/server/backend.py
+++ b/g4f/gui/server/backend.py
@@ -134,25 +134,30 @@ class Backend_Api:
dict: Arguments prepared for chat completion.
"""
kwargs = {}
- if 'image' in request.files:
+ if "image" in request.files:
file = request.files['image']
if file.filename != '' and is_allowed_extension(file.filename):
kwargs['image'] = to_image(file.stream, file.filename.endswith('.svg'))
- if 'json' in request.form:
+ if "json" in request.form:
json_data = json.loads(request.form['json'])
else:
json_data = request.json
provider = json_data.get('provider', '').replace('g4f.Provider.', '')
provider = provider if provider and provider != "Auto" else None
+
+ if "image" in kwargs and not provider:
+ provider = "Bing"
if provider == 'OpenaiChat':
kwargs['auto_continue'] = True
+
messages = json_data['messages']
if json_data.get('web_search'):
if provider == "Bing":
kwargs['web_search'] = True
else:
messages[-1]["content"] = get_search_message(messages[-1]["content"])
+
model = json_data.get('model')
model = model if model else models.default
patch = patch_provider if json_data.get('patch_provider') else None