summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/LiteIcoding.py
diff options
context:
space:
mode:
authorzukixa <56563509+zukixa@users.noreply.github.com>2024-08-25 10:00:06 +0200
committerzukixa <56563509+zukixa@users.noreply.github.com>2024-08-25 10:00:06 +0200
commita338ed588397737d3c1be66ee4f15d51c84f1770 (patch)
tree0de45ef57733bfb8c3c38e74dddabeb697ee445a /g4f/Provider/LiteIcoding.py
parent. (diff)
downloadgpt4free-a338ed588397737d3c1be66ee4f15d51c84f1770.tar
gpt4free-a338ed588397737d3c1be66ee4f15d51c84f1770.tar.gz
gpt4free-a338ed588397737d3c1be66ee4f15d51c84f1770.tar.bz2
gpt4free-a338ed588397737d3c1be66ee4f15d51c84f1770.tar.lz
gpt4free-a338ed588397737d3c1be66ee4f15d51c84f1770.tar.xz
gpt4free-a338ed588397737d3c1be66ee4f15d51c84f1770.tar.zst
gpt4free-a338ed588397737d3c1be66ee4f15d51c84f1770.zip
Diffstat (limited to 'g4f/Provider/LiteIcoding.py')
-rw-r--r--g4f/Provider/LiteIcoding.py19
1 files changed, 15 insertions, 4 deletions
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: