Models endpoint is now free and very quick

This commit is contained in:
nsde 2023-08-09 11:43:05 +02:00
parent a3d51ed92e
commit f0fee481db
3 changed files with 1356 additions and 2 deletions

1349
api/models.json Normal file

File diff suppressed because it is too large Load diff

View file

@ -86,7 +86,7 @@ async def stream(
webhook = dhooks.Webhook(os.getenv('DISCORD_WEBHOOK__API_ISSUE')) webhook = dhooks.Webhook(os.getenv('DISCORD_WEBHOOK__API_ISSUE'))
webhook.send(content=f'API Issue: **`{exc}`**\nhttps://i.imgflip.com/7uv122.jpg') webhook.send(content=f'API Issue: **`{exc}`**\nhttps://i.imgflip.com/7uv122.jpg')
error = errors.yield_error( error = await errors.yield_error(
500, 500,
'Sorry, the API has no working keys anymore.', 'Sorry, the API has no working keys anymore.',
'The admins have been messaged automatically.' 'The admins have been messaged automatically.'
@ -166,7 +166,7 @@ async def stream(
except Exception as exc: except Exception as exc:
if 'Connection closed' in str(exc): if 'Connection closed' in str(exc):
error = errors.yield_error( error = await errors.yield_error(
500, 500,
'Sorry, there was an issue with the connection.', 'Sorry, there was an issue with the connection.',
'Please first check if the issue on your end. If this error repeats, please don\'t heistate to contact the staff!.' 'Please first check if the issue on your end. If this error repeats, please don\'t heistate to contact the staff!.'

View file

@ -14,6 +14,8 @@ from helpers import tokens, errors
load_dotenv() load_dotenv()
models_list = json.load(open('models.json'))
with open('config/credits.yml', encoding='utf8') as f: with open('config/credits.yml', encoding='utf8') as f:
credits_config = yaml.safe_load(f) credits_config = yaml.safe_load(f)
@ -65,6 +67,9 @@ async def handle(incoming_request):
error = await errors.error(418, 'Your NovaAI account is not active (paused).', 'Simply re-activate your account using a Discord command or the web panel.') error = await errors.error(418, 'Your NovaAI account is not active (paused).', 'Simply re-activate your account using a Discord command or the web panel.')
return error return error
if '/models' in path:
return fastapi.responses.JSONResponse(content=models_list)
# COST # COST
costs = credits_config['costs'] costs = credits_config['costs']
cost = costs['other'] cost = costs['other']