summaryrefslogtreecommitdiffstats
path: root/g4f/gui/server/backend.py
diff options
context:
space:
mode:
authorTekky <98614666+xtekky@users.noreply.github.com>2023-10-28 09:27:53 +0200
committerGitHub <noreply@github.com>2023-10-28 09:27:53 +0200
commit1dc8e6d528c5deff96db56beb73329ab7f229cf8 (patch)
treeae6919124bb9da2e5f6d7d94e8c4dd80c11d8925 /g4f/gui/server/backend.py
parentMerge pull request #1177 from hlohaus/arkose (diff)
parentadded context (diff)
downloadgpt4free-1dc8e6d528c5deff96db56beb73329ab7f229cf8.tar
gpt4free-1dc8e6d528c5deff96db56beb73329ab7f229cf8.tar.gz
gpt4free-1dc8e6d528c5deff96db56beb73329ab7f229cf8.tar.bz2
gpt4free-1dc8e6d528c5deff96db56beb73329ab7f229cf8.tar.lz
gpt4free-1dc8e6d528c5deff96db56beb73329ab7f229cf8.tar.xz
gpt4free-1dc8e6d528c5deff96db56beb73329ab7f229cf8.tar.zst
gpt4free-1dc8e6d528c5deff96db56beb73329ab7f229cf8.zip
Diffstat (limited to '')
-rw-r--r--g4f/gui/server/backend.py48
1 files changed, 14 insertions, 34 deletions
diff --git a/g4f/gui/server/backend.py b/g4f/gui/server/backend.py
index cf6d6358..304b9fc8 100644
--- a/g4f/gui/server/backend.py
+++ b/g4f/gui/server/backend.py
@@ -1,5 +1,4 @@
import g4f
-import json
from flask import request
from .internet import search
@@ -44,45 +43,26 @@ class Backend_Api:
}
def _conversation(self):
- config = None
- proxy = None
try:
- config = json.load(open("config.json","r",encoding="utf-8"))
- proxy = config["proxy"]
-
- except Exception:
- pass
-
- try:
- jailbreak = request.json['jailbreak']
- internet_access = request.json['meta']['content']['internet_access']
- conversation = request.json['meta']['content']['conversation']
- prompt = request.json['meta']['content']['parts'][0]
+ #jailbreak = request.json['jailbreak']
+ #internet_access = request.json['meta']['content']['internet_access']
+ #conversation = request.json['meta']['content']['conversation']
+ prompt = request.json['meta']['content']['parts']
model = request.json['model']
provider = request.json.get('provider').split('g4f.Provider.')[1]
- messages = special_instructions[jailbreak] + conversation + search(internet_access, prompt) + [prompt]
+ messages = prompt
+ print(messages)
def stream():
- if proxy != None:
- yield from g4f.ChatCompletion.create(
- model=model,
- provider=get_provider(provider),
- messages=messages,
- stream=True,
- proxy=proxy
- ) if provider else g4f.ChatCompletion.create(
- model=model, messages=messages, stream=True, proxy=proxy
- )
- else:
- yield from g4f.ChatCompletion.create(
- model=model,
- provider=get_provider(provider),
- messages=messages,
- stream=True,
- ) if provider else g4f.ChatCompletion.create(
- model=model, messages=messages, stream=True
- )
+ yield from g4f.ChatCompletion.create(
+ model=g4f.models.gpt_35_long,
+ provider=get_provider(provider),
+ messages=messages,
+ stream=True,
+ ) if provider else g4f.ChatCompletion.create(
+ model=model, messages=messages, stream=True
+ )
return self.app.response_class(stream(), mimetype='text/event-stream')