summaryrefslogtreecommitdiffstats
path: root/g4f/gui/server
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-01-10 10:34:56 +0100
committerGitHub <noreply@github.com>2024-01-10 10:34:56 +0100
commitbee75be8e38d25c4568c641412a49b576d425b24 (patch)
tree63ea1505dbe2b84c3011164a7b2699e642d94c19 /g4f/gui/server
parentMerge pull request #1441 from w453y/patch-1 (diff)
downloadgpt4free-bee75be8e38d25c4568c641412a49b576d425b24.tar
gpt4free-bee75be8e38d25c4568c641412a49b576d425b24.tar.gz
gpt4free-bee75be8e38d25c4568c641412a49b576d425b24.tar.bz2
gpt4free-bee75be8e38d25c4568c641412a49b576d425b24.tar.lz
gpt4free-bee75be8e38d25c4568c641412a49b576d425b24.tar.xz
gpt4free-bee75be8e38d25c4568c641412a49b576d425b24.tar.zst
gpt4free-bee75be8e38d25c4568c641412a49b576d425b24.zip
Diffstat (limited to '')
-rw-r--r--g4f/gui/server/backend.py26
-rw-r--r--g4f/gui/server/internet.py2
2 files changed, 15 insertions, 13 deletions
diff --git a/g4f/gui/server/backend.py b/g4f/gui/server/backend.py
index 595f5aa1..67f13de4 100644
--- a/g4f/gui/server/backend.py
+++ b/g4f/gui/server/backend.py
@@ -1,11 +1,11 @@
import logging
-import g4f
-from g4f.Provider import __providers__
-
import json
-from flask import request, Flask
-from .internet import get_search_message
-from g4f import debug, version
+from flask import request, Flask
+from g4f import debug, version, models
+from g4f import _all_models, get_last_provider, ChatCompletion
+from g4f.Provider import __providers__
+from g4f.Provider.bing.create_images import patch_provider
+from .internet import get_search_message
debug.logging = True
@@ -45,7 +45,7 @@ class Backend_Api:
return 'ok', 200
def models(self):
- return g4f._all_models
+ return _all_models
def providers(self):
return [
@@ -69,25 +69,27 @@ class Backend_Api:
if request.json.get('internet_access'):
messages[-1]["content"] = get_search_message(messages[-1]["content"])
model = request.json.get('model')
- model = model if model else g4f.models.default
+ model = model if model else models.default
provider = request.json.get('provider', '').replace('g4f.Provider.', '')
provider = provider if provider and provider != "Auto" else None
-
+ patch = patch_provider if request.json.get('patch_provider') else None
+
def try_response():
try:
first = True
- for chunk in g4f.ChatCompletion.create(
+ for chunk in ChatCompletion.create(
model=model,
provider=provider,
messages=messages,
stream=True,
- ignore_stream_and_auth=True
+ ignore_stream_and_auth=True,
+ patch_provider=patch
):
if first:
first = False
yield json.dumps({
'type' : 'provider',
- 'provider': g4f.get_last_provider(True)
+ 'provider': get_last_provider(True)
}) + "\n"
yield json.dumps({
'type' : 'content',
diff --git a/g4f/gui/server/internet.py b/g4f/gui/server/internet.py
index 97f842d7..6c2e3a89 100644
--- a/g4f/gui/server/internet.py
+++ b/g4f/gui/server/internet.py
@@ -145,5 +145,5 @@ User request:
"""
return message
except Exception as e:
- print("Couldn't search DuckDuckGo:", e)
+ print("Couldn't do web search:", e)
return prompt