Added /v1/accounts/credits

This commit is contained in:
henceiusegentoo 2023-09-22 02:38:21 +02:00
parent 1384b3add8
commit d3d9ead8f4
2 changed files with 5 additions and 2 deletions

View file

@ -71,6 +71,9 @@ async def handle(incoming_request: fastapi.Request):
if ban_reason:
return await errors.error(403, f'Your NovaAI account has been banned. Reason: \'{ban_reason}\'.', 'Contact the staff for an appeal.')
if 'account/credits' in path:
return fastapi.responses.JSONResponse({'credits': user['credits']})
costs = config['costs']
cost = costs['other']
@ -150,7 +153,7 @@ async def handle(incoming_request: fastapi.Request):
media_type = 'text/event-stream' if payload.get('stream', False) else 'application/json'
if payload['model'] not in models:
if (model := payload.get('model')) not in models and model is not None:
return await errors.error(404, 'Model not found.', 'Check the model name and try again.')
return fastapi.responses.StreamingResponse(

View file

@ -66,4 +66,4 @@ async def root():
@app.route('/v1/{path:path}', methods=['GET', 'POST', 'PUT', 'DELETE', 'PATCH'])
async def v1_handler(request: fastapi.Request):
res = await handler.handle(incoming_request=request)
return res
return res