deepseek update

This commit is contained in:
based
2025-01-20 05:21:53 +10:00
parent c4d08a209b
commit c405a67c79
3 changed files with 47 additions and 19 deletions
+2 -1
View File
@@ -74,8 +74,9 @@ class APIKey:
self.pro_voice_limit = 0
elif provider == Provider.DEEPSEEK:
self.balance = ""
self.balance = "$0.0 USD"
self.available = False
self.rate_limited = False
def clone(self):
cloned_key = APIKey(self.provider, self.api_key)
+29 -15
View File
@@ -1,33 +1,47 @@
import APIKey
async def check_whale(key: APIKey, session):
async with session.get(f'https://api.deepseek.com/models', headers={'Authorization': f'Bearer {key.api_key}'}) as response:
if response.status != 200:
return
if not await check_balance(key, session):
return
return True
valid = await check_balance(key, session)
return valid
async def check_balance(key: APIKey, session):
async with session.get(f'https://api.deepseek.com/user/balance', headers={'Authorization': f'Bearer {key.api_key}'}) as response:
if response.status != 200:
return
if response.status == 429:
return False
elif response.status != 200:
return None
data = await response.json()
key.available = data.get('is_available', False)
balance_infos = data.get('balance_infos', [])
if balance_infos:
key.balance = float(balance_infos[0].get('total_balance', '0.0'))
total_usd = 0.0
for balance in balance_infos:
amount = float(balance.get('total_balance', '0.0'))
currency = balance.get('currency', 'USD')
if currency == 'CNY':
amount *= 0.14
total_usd += amount
key.balance = f'${total_usd:.1f} USD'
return True
def pretty_print_deepseek_keys(keys):
keys = sorted(keys, key=lambda x: x.balance, reverse=True)
def get_balance_value(key):
return float(key.balance.split()[0].replace('$', ''))
keys = sorted(keys, key=lambda x: (
x.rate_limited,
get_balance_value(x) == 0,
-get_balance_value(x)
))
print('-' * 90)
available = sum(1 for key in keys if key.available)
print(f'Validated {len(keys)} Deepseek keys:')
for key in keys:
balance_str = f'| ${key.balance}' if key.available else ''
print(f'{key.api_key} {balance_str}')
print(f'\n--- Total Valid Deepseek Keys: {len(keys)} ({available} with sufficient usage balance) ---\n')
balance_str = f' | {key.balance}' if key.available else ''
ratelimit_str = f' | rate-limited' if key.rate_limited else ''
print(f'{key.api_key}{balance_str}{ratelimit_str}')
print(f'\n--- Total Valid Deepseek Keys: {len(keys)} ({available} with sufficient usage balance) ---\n')
+16 -3
View File
@@ -183,12 +183,25 @@ async def validate_vertexai(key: APIKey, sem):
async def validate_whale(key: APIKey, sem):
async with sem, aiohttp.ClientSession() as session:
retry_count = 4
async with sem, deepseek_semaphore, aiohttp.ClientSession() as session:
IO.conditional_print(f"Checking Deepseek key: {key.api_key}", args.verbose)
if await check_whale(key, session) is None:
key_status = await check_whale(key, session)
if key_status is None:
IO.conditional_print(f"Invalid Deepseek key: {key.api_key}", args.verbose)
return
elif key_status is False:
i = 0
while await check_whale(key, session) is False and i < retry_count:
i += 1
await asyncio.sleep(2)
print(f"Stuck determining status of rate limited Deepseek key '{key.api_key[-8:]}' - attempt {i} of {retry_count}")
key.rate_limited = True
else:
if i < retry_count:
key.rate_limited = False
IO.conditional_print(f"Deepseek key '{key.api_key}' is valid", args.verbose)
# await asyncio.sleep(5)
api_keys.add(key)
@@ -226,7 +239,7 @@ deepseek_regex = re.compile(r'sk-[a-f0-9]{32}')
executor = ThreadPoolExecutor(max_workers=100)
concurrent_connections = asyncio.Semaphore(1500)
makersuite_semaphore = asyncio.Semaphore(50) # when did google become such a pussy
deepseek_semaphore = asyncio.Semaphore(50)
async def validate_keys():
tasks = []