summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTekky <98614666+xtekky@users.noreply.github.com>2024-01-21 11:46:33 +0100
committerGitHub <noreply@github.com>2024-01-21 11:46:33 +0100
commitc2878fbe148531ccdb668e4f201ff293c49ae75d (patch)
treec395ef85ac53895ccf5d6de53e29afd50f7b3d69
parentMerge pull request #1488 from nullstreak/dolphin-mixtral (diff)
parentFix load json in DeepInfra (diff)
downloadgpt4free-c2878fbe148531ccdb668e4f201ff293c49ae75d.tar
gpt4free-c2878fbe148531ccdb668e4f201ff293c49ae75d.tar.gz
gpt4free-c2878fbe148531ccdb668e4f201ff293c49ae75d.tar.bz2
gpt4free-c2878fbe148531ccdb668e4f201ff293c49ae75d.tar.lz
gpt4free-c2878fbe148531ccdb668e4f201ff293c49ae75d.tar.xz
gpt4free-c2878fbe148531ccdb668e4f201ff293c49ae75d.tar.zst
gpt4free-c2878fbe148531ccdb668e4f201ff293c49ae75d.zip
-rw-r--r--g4f/Provider/DeepInfra.py10
1 files changed, 3 insertions, 7 deletions
diff --git a/g4f/Provider/DeepInfra.py b/g4f/Provider/DeepInfra.py
index 12bd49c7..acde1200 100644
--- a/g4f/Provider/DeepInfra.py
+++ b/g4f/Provider/DeepInfra.py
@@ -60,17 +60,13 @@ class DeepInfra(AsyncGeneratorProvider):
async for line in response.iter_lines():
if not line.startswith(b"data: "):
continue
-
try:
- decoded_line = line.decode().lstrip("data: ")
- json_line = json.loads(decoded_line)
-
+ json_line = json.loads(line[6:])
choices = json_line.get("choices", [{}])
- finish_reason = choices[0].get("finish_reason", "")
+ finish_reason = choices[0].get("finish_reason")
if finish_reason:
break
- token = choices[0].get("delta", {}).get("content", "")
-
+ token = choices[0].get("delta", {}).get("content")
if token:
if first:
token = token.lstrip()