From 778114decf961d055ce072fa61a3856c75c1e394 Mon Sep 17 00:00:00 2001 From: nsde Date: Fri, 25 Aug 2023 19:13:39 +0200 Subject: [PATCH] User agent fix --- api/streaming.py | 6 +++++- api/transfer.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/api/streaming.py b/api/streaming.py index 1b683f6..5075aa3 100644 --- a/api/streaming.py +++ b/api/streaming.py @@ -72,8 +72,12 @@ async def stream( json_response = {'error': 'No JSON response could be received'} + headers = { + 'Content-Type': 'application/json', + 'User-Agent': 'null' + } + for _ in range(5): - headers = {'Content-Type': 'application/json'} # Load balancing: randomly selecting a suitable provider # If the request is a chat completion, then we need to load balance between chat providers diff --git a/api/transfer.py b/api/transfer.py index b6df9ee..4d35a0c 100644 --- a/api/transfer.py +++ b/api/transfer.py @@ -9,6 +9,7 @@ from dotenv import load_dotenv import streaming import moderation +from rich import print from db.users import UserManager from helpers import tokens, errors, network @@ -29,7 +30,7 @@ async def handle(incoming_request): path = incoming_request.url.path.replace('v1/v1', 'v1').replace('//', '/') ip_address = await network.get_ip(incoming_request) - print(f'[{ip_address}] {path}') + print(f'[bold green]>{ip_address}[/bold green]') if '/models' in path: return fastapi.responses.JSONResponse(content=models_list) @@ -54,6 +55,9 @@ async def handle(incoming_request): if not user or not user['status']['active']: return await errors.error(403, 'Invalid or inactive NovaAI API key!', 'Create a new NovaOSS API key or reactivate your account.') + if user.get('auth', {}).get('discord'): + print(f'[bold green]>Discord[/bold green] {user["auth"]["discord"]}') + ban_reason = user['status']['ban_reason'] if ban_reason: return await errors.error(403, f'Your NovaAI account has been banned. Reason: \'{ban_reason}\'.', 'Contact the staff for an appeal.')