diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2024-02-11 08:41:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-11 08:41:54 +0100 |
commit | 3c498496f812b252d65b65690c36e5f2aa133b94 (patch) | |
tree | 6b46c5cc3671f0e1f4fcdab7e92050b3713d466c /g4f/gui/server/backend.py | |
parent | Update image.py (diff) | |
parent | Change python version to 3.12 in unitests (diff) | |
download | gpt4free-3c498496f812b252d65b65690c36e5f2aa133b94.tar gpt4free-3c498496f812b252d65b65690c36e5f2aa133b94.tar.gz gpt4free-3c498496f812b252d65b65690c36e5f2aa133b94.tar.bz2 gpt4free-3c498496f812b252d65b65690c36e5f2aa133b94.tar.lz gpt4free-3c498496f812b252d65b65690c36e5f2aa133b94.tar.xz gpt4free-3c498496f812b252d65b65690c36e5f2aa133b94.tar.zst gpt4free-3c498496f812b252d65b65690c36e5f2aa133b94.zip |
Diffstat (limited to 'g4f/gui/server/backend.py')
-rw-r--r-- | g4f/gui/server/backend.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/g4f/gui/server/backend.py b/g4f/gui/server/backend.py index 2218452c..6847be34 100644 --- a/g4f/gui/server/backend.py +++ b/g4f/gui/server/backend.py @@ -134,25 +134,31 @@ 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: + kwargs['image_name'] = file.filename + 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 |