This repository has been archived on 2023-10-20. You can view files and clone it, but cannot push or open issues or pull requests.
hf-key-scraper/huggingface/check-keys.py

76 lines
1.9 KiB
Python

import argparse
import concurrent
from concurrent.futures import ThreadPoolExecutor
from pathlib import Path
from keychecker.check import check_key
def process_key(key):
result = check_key(key)
if not len(result['errors']):
if result['has_gpt_4'] or result['has_only_turbo'] or result['has_gpt_4_32k']:
print(result)
return result
return None
def main():
parser = argparse.ArgumentParser(description='Scrape data from chub.ai.')
parser.add_argument('input_file', help='Path to the file containing the keys.')
args = parser.parse_args()
input_file = Path(args.input_file).resolve().absolute()
if not input_file.exists():
print('Input file does not exist:', input_file)
quit(1)
with open(input_file) as f:
content = set(f.read().splitlines())
# content = ['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']
gpt_4 = set()
gpt_4_32k = set()
gpt_3 = set()
with ThreadPoolExecutor(max_workers=50) as executor:
results = executor.map(process_key, content)
for result in results:
if result is not None:
if result['has_gpt_4']:
gpt_4.add(result['api_key'])
if result['has_gpt_4_32k']:
gpt_4_32k.add(result['api_key'])
if result['has_only_turbo']:
gpt_3.add(result['api_key'])
print('')
print('GPT4 KEYS:')
if not len(gpt_4):
print('none')
else:
for key in gpt_4:
print(key)
print('')
print('GPT4-32k KEYS:')
if not len(gpt_4_32k):
print('none')
else:
for key in gpt_4_32k:
print(key)
print('')
print('GPT3 KEYS:')
if not len(gpt_3):
print('none')
else:
for key in gpt_3:
print(key)
if __name__ == "__main__":
main()