diff options
author | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-01-21 09:43:46 +0100 |
---|---|---|
committer | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-01-21 09:43:46 +0100 |
commit | 0b4c6247d051a1dd704f519062686716e8d9f201 (patch) | |
tree | 04a6cdaaba8b92cee4db9be5d883c66677973128 /g4f | |
parent | Merge pull request #1487 from nullstreak/deepinfra-patch (diff) | |
download | gpt4free-0b4c6247d051a1dd704f519062686716e8d9f201.tar gpt4free-0b4c6247d051a1dd704f519062686716e8d9f201.tar.gz gpt4free-0b4c6247d051a1dd704f519062686716e8d9f201.tar.bz2 gpt4free-0b4c6247d051a1dd704f519062686716e8d9f201.tar.lz gpt4free-0b4c6247d051a1dd704f519062686716e8d9f201.tar.xz gpt4free-0b4c6247d051a1dd704f519062686716e8d9f201.tar.zst gpt4free-0b4c6247d051a1dd704f519062686716e8d9f201.zip |
Diffstat (limited to 'g4f')
-rw-r--r-- | g4f/Provider/DeepInfra.py | 10 |
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() |