summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLopeKinz <48872005+LopeKinz@users.noreply.github.com>2023-06-13 15:34:14 +0200
committerGitHub <noreply@github.com>2023-06-13 15:34:14 +0200
commit41e00dde266ed90e4993c68692101a73000a7be8 (patch)
tree40c8f3e6fb94cd5a82a312fe82ad3c17b146edcb
parentimportant announcement, g4f v2 & gpt-4 discord bot (diff)
downloadgpt4free-41e00dde266ed90e4993c68692101a73000a7be8.tar
gpt4free-41e00dde266ed90e4993c68692101a73000a7be8.tar.gz
gpt4free-41e00dde266ed90e4993c68692101a73000a7be8.tar.bz2
gpt4free-41e00dde266ed90e4993c68692101a73000a7be8.tar.lz
gpt4free-41e00dde266ed90e4993c68692101a73000a7be8.tar.xz
gpt4free-41e00dde266ed90e4993c68692101a73000a7be8.tar.zst
gpt4free-41e00dde266ed90e4993c68692101a73000a7be8.zip
-rw-r--r--gpt4free/usesless/__init__.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/gpt4free/usesless/__init__.py b/gpt4free/usesless/__init__.py
index bd7879eb..00f7f75d 100644
--- a/gpt4free/usesless/__init__.py
+++ b/gpt4free/usesless/__init__.py
@@ -144,10 +144,15 @@ class Completion:
response = Completion.__response_to_json(content)
return response
+
@classmethod
def __response_to_json(cls, text) -> str:
text = str(text.decode("utf-8"))
- split_text = text.rsplit("\n", 1)[1]
- to_json = json.loads(split_text)
- return to_json
+ split_text = text.rsplit("\n", 1)
+ if len(split_text) > 1:
+ to_json = json.loads(split_text[1])
+ return to_json
+ else:
+ return None
+