From 9239c5720002f31b67bdd1ee805e2cd9b528d085 Mon Sep 17 00:00:00 2001
From: Commenter123321 <36051603+Commenter123321@users.noreply.github.com>
Date: Tue, 10 Oct 2023 15:11:17 +0200
Subject: fix provider thing in gui x2
---
g4f/gui/client/html/index.html | 6 +++++-
g4f/gui/server/backend.py | 6 +++---
g4f/gui/server/provider.py | 7 +------
3 files changed, 9 insertions(+), 10 deletions(-)
(limited to 'g4f/gui')
diff --git a/g4f/gui/client/html/index.html b/g4f/gui/client/html/index.html
index bb472706..c15584b8 100644
--- a/g4f/gui/client/html/index.html
+++ b/g4f/gui/client/html/index.html
@@ -118,9 +118,13 @@
diff --git a/g4f/gui/server/backend.py b/g4f/gui/server/backend.py
index cf1f9428..a76ca12b 100644
--- a/g4f/gui/server/backend.py
+++ b/g4f/gui/server/backend.py
@@ -33,17 +33,17 @@ class Backend_Api:
conversation = request.json['meta']['content']['conversation']
prompt = request.json['meta']['content']['parts'][0]
model = request.json['model']
- provider = get_provider(request.json.get('provider'))
+ provider = request.json.get('provider').split("g4f.Provider.")[1]
messages = special_instructions[jailbreak] + conversation + search(internet_access, prompt) + [prompt]
def stream():
if provider:
answer = g4f.ChatCompletion.create(model=model,
- provider=g4f.Provider.ProviderUtils.convert.get(provider), messages=messages, stream=True)
+ provider=get_provider(provider), messages=messages, stream=True)
else:
answer = g4f.ChatCompletion.create(model=model,
- messages=messages, stream=True)
+ messages=messages, stream=True)
for token in answer:
yield token
diff --git a/g4f/gui/server/provider.py b/g4f/gui/server/provider.py
index 230b5f5f..11202d38 100644
--- a/g4f/gui/server/provider.py
+++ b/g4f/gui/server/provider.py
@@ -3,17 +3,12 @@ from g4f import BaseProvider
def get_provider(provider: str) -> BaseProvider | None:
-
if isinstance(provider, str):
print(provider)
if provider == 'g4f.Provider.Auto':
return None
- if provider in g4f.Provider.ProviderUtils.convert:
- return g4f.Provider.ProviderUtils.convert[provider]
-
- else:
- return None
+ return g4f.Provider.ProviderUtils.convert.get(provider)
else:
return None
--
cgit v1.2.3