From f8e403a745c5caff31d7edb854dcba40eba3166d Mon Sep 17 00:00:00 2001 From: kqlio67 Date: Tue, 24 Sep 2024 13:23:53 +0300 Subject: Resolved merge conflicts --- g4f/Provider/LiteIcoding.py | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'g4f/Provider/LiteIcoding.py') 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 -- cgit v1.2.3