From 201cd6207c617d5a95e349448a8bd3a599d8aec9 Mon Sep 17 00:00:00 2001 From: based Date: Wed, 24 Jan 2024 07:36:54 +1000 Subject: [PATCH] added verbose flag --- IO.py | 5 +++++ README.md | 4 ++++ main.py | 23 +++++++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/IO.py b/IO.py index 57628bd..8309c05 100644 --- a/IO.py +++ b/IO.py @@ -14,6 +14,11 @@ class IO: def flush(self): pass + @staticmethod + def conditional_print(message, condition): + if condition: + print(message) + @staticmethod def read_keys_from_file(filename): if not os.path.isfile(filename): diff --git a/README.md b/README.md index 304ba5b..d3c8778 100644 --- a/README.md +++ b/README.md @@ -31,3 +31,7 @@ Stops outputting and saving keys to the snapshot file (proxyoutput will also do `-file` Reads keys from a file instead of stdin, place either the absolute or relative path to the file in quotes after the flag. + +`-verbose` + +Displays an output as keys are being checked real time. diff --git a/main.py b/main.py index 8a67b50..9da5a66 100644 --- a/main.py +++ b/main.py @@ -27,6 +27,7 @@ def parse_args(): parser.add_argument('-nooutput', '--nooutput', action='store_true', help='stop writing slop to a file') parser.add_argument('-proxyoutput', '--proxyoutput', action='store_true', help='proxy format output for easy copying') parser.add_argument('-file', '--file', action='store', dest='file', help='read slop from a provided filename') + parser.add_argument('-verbose', '--verbose', action='store_true', help='watch as your slop is checked real time') return parser.parse_args() @@ -50,19 +51,24 @@ else: async def validate_openai(key: APIKey, sem): async with sem, aiohttp.ClientSession() as session: + IO.conditional_print(f"Checking OpenAI key: {key.api_key}", args.verbose) if await get_oai_model(key, session) is None: + IO.conditional_print(f"Invalid OpenAI key: {key.api_key}", args.verbose) return if await get_oai_key_attribs(key, session) is None: return if await get_oai_org(key, session) is None: return + IO.conditional_print(f"OpenAI key '{key.api_key}' is valid", args.verbose) api_keys.add(key) async def validate_anthropic(key: APIKey, retry_count, sem): async with sem, aiohttp.ClientSession() as session: + IO.conditional_print(f"Checking Anthropic key: {key.api_key}", args.verbose) key_status = await check_anthropic(key, session) if key_status is None: + IO.conditional_print(f"Invalid Anthropic key: {key.api_key}", args.verbose) return elif key_status is False: i = 0 @@ -74,41 +80,58 @@ async def validate_anthropic(key: APIKey, retry_count, sem): else: if i < retry_count: key.rate_limited = False + IO.conditional_print(f"Anthropic key '{key.api_key}' is valid", args.verbose) api_keys.add(key) async def validate_ai21_and_mistral(key: APIKey, sem): async with sem, aiohttp.ClientSession() as session: + IO.conditional_print(f"Checking AI21 key: {key.api_key}", args.verbose) if await check_ai21(key, session) is None: + IO.conditional_print(f"Invalid AI21 key: {key.api_key}, checking provider Mistral", args.verbose) key.provider = Provider.MISTRAL if await check_mistral(key, session) is None: + IO.conditional_print(f"Invalid Mistral key: {key.api_key}", args.verbose) return + IO.conditional_print(f"{'AI21' if key.provider == Provider.AI21 else 'Mistral'} key '{key.api_key}' is valid", args.verbose) api_keys.add(key) async def validate_makersuite(key: APIKey, sem): async with sem, aiohttp.ClientSession() as session: + IO.conditional_print(f"Checking MakerSuite key: {key.api_key}", args.verbose) if await check_makersuite(key, session) is None: + IO.conditional_print(f"Invalid MakerSuite key: {key.api_key}", args.verbose) return + IO.conditional_print(f"MakerSuite key '{key.api_key}' is valid", args.verbose) api_keys.add(key) def validate_aws(key: APIKey): + IO.conditional_print(f"Checking AWS key: {key.api_key}", args.verbose) if check_aws(key) is None: + IO.conditional_print(f"Invalid AWS key: {key.api_key}", args.verbose) return + IO.conditional_print(f"AWS key '{key.api_key}' is valid", args.verbose) api_keys.add(key) async def validate_azure(key: APIKey, sem): async with sem, aiohttp.ClientSession() as session: + IO.conditional_print(f"Checking Azure key: {key.api_key}", args.verbose) if await check_azure(key, session) is None: + IO.conditional_print(f"Invalid Azure key: {key.api_key}", args.verbose) return + IO.conditional_print(f"Azure key '{key.api_key}' is valid", args.verbose) api_keys.add(key) def validate_vertexai(key: APIKey): + IO.conditional_print(f"Checking Vertex AI keyfile: {key.api_key}", args.verbose) if check_vertexai(key) is None: + IO.conditional_print(f"Invalid Vertex AI keyfile: {key.api_key}", args.verbose) return + IO.conditional_print(f"Vertex AI keyfile '{key.api_key}' is valid", args.verbose) api_keys.add(key)