summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxtekky <98614666+xtekky@users.noreply.github.com>2023-06-18 00:59:33 +0200
committerGitHub <noreply@github.com>2023-06-18 00:59:33 +0200
commit94412b0dbbf8659242c4a422291408126bf7861e (patch)
tree0be211c27cf5367601ca3849d9d1932413ad9374
parentupdates (diff)
parentUpdate __init__.py (diff)
downloadgpt4free-94412b0dbbf8659242c4a422291408126bf7861e.tar
gpt4free-94412b0dbbf8659242c4a422291408126bf7861e.tar.gz
gpt4free-94412b0dbbf8659242c4a422291408126bf7861e.tar.bz2
gpt4free-94412b0dbbf8659242c4a422291408126bf7861e.tar.lz
gpt4free-94412b0dbbf8659242c4a422291408126bf7861e.tar.xz
gpt4free-94412b0dbbf8659242c4a422291408126bf7861e.tar.zst
gpt4free-94412b0dbbf8659242c4a422291408126bf7861e.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
+