summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/needs_auth
diff options
context:
space:
mode:
authorHeiner Lohaus <heiner@lohaus.eu>2023-10-28 19:02:39 +0200
committerHeiner Lohaus <heiner@lohaus.eu>2023-10-28 19:02:39 +0200
commitcc301a3dd82f26d9b33894beb1ec80f979a20d49 (patch)
tree6354007b81aff61595d5c17f0ae54b4a07f27a50 /g4f/Provider/needs_auth
parentAdd arkose_token to OpenaiChat (diff)
downloadgpt4free-cc301a3dd82f26d9b33894beb1ec80f979a20d49.tar
gpt4free-cc301a3dd82f26d9b33894beb1ec80f979a20d49.tar.gz
gpt4free-cc301a3dd82f26d9b33894beb1ec80f979a20d49.tar.bz2
gpt4free-cc301a3dd82f26d9b33894beb1ec80f979a20d49.tar.lz
gpt4free-cc301a3dd82f26d9b33894beb1ec80f979a20d49.tar.xz
gpt4free-cc301a3dd82f26d9b33894beb1ec80f979a20d49.tar.zst
gpt4free-cc301a3dd82f26d9b33894beb1ec80f979a20d49.zip
Diffstat (limited to '')
-rw-r--r--g4f/Provider/needs_auth/OpenaiChat.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/g4f/Provider/needs_auth/OpenaiChat.py b/g4f/Provider/needs_auth/OpenaiChat.py
index eaccb7f1..fb81face 100644
--- a/g4f/Provider/needs_auth/OpenaiChat.py
+++ b/g4f/Provider/needs_auth/OpenaiChat.py
@@ -1,7 +1,7 @@
from __future__ import annotations
import uuid, json, time, os
-import tempfile, subprocess, shutil
+import tempfile, shutil, asyncio
from ..base_provider import AsyncGeneratorProvider
from ..helper import get_browser, get_cookies, format_prompt, get_event_loop
@@ -174,7 +174,14 @@ fun.getToken(config).then(token => {
tmp.write(source.encode())
tmp.close()
try:
- p = subprocess.Popen([node, tmp.name], stdout=subprocess.PIPE)
- return p.stdout.read().decode()
+ p = await asyncio.create_subprocess_exec(
+ node, tmp.name,
+ stderr=asyncio.subprocess.PIPE,
+ stdout=asyncio.subprocess.PIPE
+ )
+ stdout, stderr = await p.communicate()
+ if p.returncode == 0:
+ return stdout.decode()
+ raise RuntimeError(f"Exec Error: {stderr.decode()}")
finally:
os.unlink(tmp.name) \ No newline at end of file