From a338ed588397737d3c1be66ee4f15d51c84f1770 Mon Sep 17 00:00:00 2001 From: zukixa <56563509+zukixa@users.noreply.github.com> Date: Sun, 25 Aug 2024 01:00:06 -0700 Subject: 8 providers improved --- g4f/Provider/LiteIcoding.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'g4f/Provider/LiteIcoding.py') diff --git a/g4f/Provider/LiteIcoding.py b/g4f/Provider/LiteIcoding.py index 6aa407ca..ad04aceb 100644 --- a/g4f/Provider/LiteIcoding.py +++ b/g4f/Provider/LiteIcoding.py @@ -31,7 +31,7 @@ class LiteIcoding(AsyncGeneratorProvider, ProviderModelMixin): headers = { "Accept": "*/*", "Accept-Language": "en-US,en;q=0.9", - "Authorization": "Bearer null", + "Authorization": "Bearer b3b2712cf83640a5acfdc01e78369930", "Connection": "keep-alive", "Content-Type": "application/json;charset=utf-8", "DNT": "1", @@ -74,6 +74,9 @@ class LiteIcoding(AsyncGeneratorProvider, ProviderModelMixin): response.raise_for_status() buffer = "" full_response = "" + def decode_content(data): + bytes_array = bytes([int(b, 16) ^ 255 for b in data.split()]) + return bytes_array.decode('utf-8') async for chunk in response.content.iter_any(): if chunk: buffer += chunk.decode() @@ -83,9 +86,17 @@ class LiteIcoding(AsyncGeneratorProvider, ProviderModelMixin): content = part[6:].strip() if content and content != "[DONE]": content = content.strip('"') - full_response += content - - full_response = full_response.replace('" "', ' ') + # Decoding each content block + decoded_content = decode_content(content) + full_response += decoded_content + full_response = ( + full_response.replace('""', '') # Handle double quotes + .replace('" "', ' ') # Handle space within quotes + .replace("\\n\\n", "\n\n") + .replace("\\n", "\n") + .replace('\\"', '"') + .strip() + ) yield full_response.strip() except ClientResponseError as e: -- cgit v1.2.3