summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/LiteIcoding.py
diff options
context:
space:
mode:
authorkqlio67 <kqlio67@users.noreply.github.com>2024-09-24 12:23:53 +0200
committerkqlio67 <kqlio67@users.noreply.github.com>2024-09-24 12:23:53 +0200
commitf8e403a745c5caff31d7edb854dcba40eba3166d (patch)
treea75c6030a8054c56201fa2d41306a51b9052545c /g4f/Provider/LiteIcoding.py
parentAdded gpt-4o provider (diff)
downloadgpt4free-f8e403a745c5caff31d7edb854dcba40eba3166d.tar
gpt4free-f8e403a745c5caff31d7edb854dcba40eba3166d.tar.gz
gpt4free-f8e403a745c5caff31d7edb854dcba40eba3166d.tar.bz2
gpt4free-f8e403a745c5caff31d7edb854dcba40eba3166d.tar.lz
gpt4free-f8e403a745c5caff31d7edb854dcba40eba3166d.tar.xz
gpt4free-f8e403a745c5caff31d7edb854dcba40eba3166d.tar.zst
gpt4free-f8e403a745c5caff31d7edb854dcba40eba3166d.zip
Diffstat (limited to '')
-rw-r--r--g4f/Provider/LiteIcoding.py29
1 files changed, 23 insertions, 6 deletions
diff --git a/g4f/Provider/LiteIcoding.py b/g4f/Provider/LiteIcoding.py
index 69294a57..1b568e80 100644
--- a/g4f/Provider/LiteIcoding.py
+++ b/g4f/Provider/LiteIcoding.py
@@ -20,6 +20,25 @@ class LiteIcoding(AsyncGeneratorProvider, ProviderModelMixin):
'claude-3.5',
'gemini-1.5',
]
+
+ model_aliases = {
+ "gpt-4o-mini": "gpt-4o",
+ "gemini-pro": "gemini-1.5",
+ }
+
+ bearer_tokens = [
+ "aa3020ee873e40cb8b3f515a0708ebc4",
+ "5d69cd271b144226ac1199b3c849a566",
+ "62977f48a95844f8853a953679401850",
+ "d815b091959e42dd8b7871dfaf879485"
+ ]
+ current_token_index = 0
+
+ @classmethod
+ def get_next_bearer_token(cls):
+ token = cls.bearer_tokens[cls.current_token_index]
+ cls.current_token_index = (cls.current_token_index + 1) % len(cls.bearer_tokens)
+ return token
@classmethod
async def create_async_generator(
@@ -29,10 +48,11 @@ class LiteIcoding(AsyncGeneratorProvider, ProviderModelMixin):
proxy: str = None,
**kwargs
) -> AsyncResult:
+ bearer_token = cls.get_next_bearer_token()
headers = {
"Accept": "*/*",
"Accept-Language": "en-US,en;q=0.9",
- "Authorization": "Bearer aa3020ee873e40cb8b3f515a0708ebc4",
+ "Authorization": f"Bearer {bearer_token}",
"Connection": "keep-alive",
"Content-Type": "application/json;charset=utf-8",
"DNT": "1",
@@ -87,20 +107,17 @@ class LiteIcoding(AsyncGeneratorProvider, ProviderModelMixin):
content = part[6:].strip()
if content and content != "[DONE]":
content = content.strip('"')
- # 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
+ full_response.replace('""', '')
+ .replace('" "', ' ')
.replace("\\n\\n", "\n\n")
.replace("\\n", "\n")
.replace('\\"', '"')
.strip()
)
- # Add filter to remove unwanted text
filtered_response = re.sub(r'\n---\n.*', '', full_response, flags=re.DOTALL)
- # Remove extra quotes at the beginning and end
cleaned_response = filtered_response.strip().strip('"')
yield cleaned_response