summaryrefslogtreecommitdiffstats
path: root/g4f/gui/server
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-02-11 01:59:57 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-02-11 01:59:57 +0100
commit6c422b2965d07e33a4c03fd7e1963316500bd527 (patch)
tree852bda60253d7dacf020c819362918b8fb426b48 /g4f/gui/server
parentUpdate image.py (diff)
downloadgpt4free-6c422b2965d07e33a4c03fd7e1963316500bd527.tar
gpt4free-6c422b2965d07e33a4c03fd7e1963316500bd527.tar.gz
gpt4free-6c422b2965d07e33a4c03fd7e1963316500bd527.tar.bz2
gpt4free-6c422b2965d07e33a4c03fd7e1963316500bd527.tar.lz
gpt4free-6c422b2965d07e33a4c03fd7e1963316500bd527.tar.xz
gpt4free-6c422b2965d07e33a4c03fd7e1963316500bd527.tar.zst
gpt4free-6c422b2965d07e33a4c03fd7e1963316500bd527.zip
Diffstat (limited to '')
-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