mirror of
https://github.com/NovaOSS/nova-api.git
synced 2024-11-25 16:43:58 +01:00
Added /v1/accounts/credits
This commit is contained in:
parent
1384b3add8
commit
d3d9ead8f4
|
@ -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(
|
||||
|
|
|
@ -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
|
Loading…
Reference in a new issue