User agent fix

This commit is contained in:
nsde 2023-08-25 19:13:39 +02:00
parent f01b8e5ecc
commit 778114decf
2 changed files with 10 additions and 2 deletions

View file

@ -72,8 +72,12 @@ async def stream(
json_response = {'error': 'No JSON response could be received'} json_response = {'error': 'No JSON response could be received'}
headers = {
'Content-Type': 'application/json',
'User-Agent': 'null'
}
for _ in range(5): for _ in range(5):
headers = {'Content-Type': 'application/json'}
# Load balancing: randomly selecting a suitable provider # Load balancing: randomly selecting a suitable provider
# If the request is a chat completion, then we need to load balance between chat providers # If the request is a chat completion, then we need to load balance between chat providers

View file

@ -9,6 +9,7 @@ from dotenv import load_dotenv
import streaming import streaming
import moderation import moderation
from rich import print
from db.users import UserManager from db.users import UserManager
from helpers import tokens, errors, network 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('//', '/') path = incoming_request.url.path.replace('v1/v1', 'v1').replace('//', '/')
ip_address = await network.get_ip(incoming_request) 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: if '/models' in path:
return fastapi.responses.JSONResponse(content=models_list) return fastapi.responses.JSONResponse(content=models_list)
@ -54,6 +55,9 @@ async def handle(incoming_request):
if not user or not user['status']['active']: 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.') 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'] ban_reason = user['status']['ban_reason']
if 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.') return await errors.error(403, f'Your NovaAI account has been banned. Reason: \'{ban_reason}\'.', 'Contact the staff for an appeal.')