Some fixes?

This commit is contained in:
nsde 2023-08-16 15:06:16 +02:00
parent 8c05fd9d87
commit f6cd1f7aa2
6 changed files with 24 additions and 6 deletions

View file

@ -21,7 +21,7 @@ UA_SIMPLIFY = {
conn = AsyncIOMotorClient(os.getenv('MONGO_URI')) conn = AsyncIOMotorClient(os.getenv('MONGO_URI'))
async def _get_collection(collection_name: str): async def _get_collection(collection_name: str):
return conn['nova-core'][collection_name] return conn[os.getenv('MONGO_NAME', 'nova-test')][collection_name]
async def replacer(text: str, dict_: dict) -> str: async def replacer(text: str, dict_: dict) -> str:
# This seems to exist for a very specific and dumb purpose :D # This seems to exist for a very specific and dumb purpose :D

View file

@ -26,7 +26,7 @@ class StatsManager:
self.conn = AsyncIOMotorClient(os.getenv('MONGO_URI')) self.conn = AsyncIOMotorClient(os.getenv('MONGO_URI'))
async def _get_collection(self, collection_name: str): async def _get_collection(self, collection_name: str):
return self.conn['nova-core'][collection_name] return self.conn[os.getenv('MONGO_NAME', 'nova-test')][collection_name]
async def add_date(self): async def add_date(self):
date = datetime.datetime.now(pytz.timezone('GMT')).strftime('%Y.%m.%d') date = datetime.datetime.now(pytz.timezone('GMT')).strftime('%Y.%m.%d')

View file

@ -33,10 +33,10 @@ class UserManager:
self.conn = AsyncIOMotorClient(os.getenv('MONGO_URI')) self.conn = AsyncIOMotorClient(os.getenv('MONGO_URI'))
async def _get_collection(self, collection_name: str): async def _get_collection(self, collection_name: str):
return self.conn['nova-core'][collection_name] return self.conn[os.getenv('MONGO_NAME', 'nova-test')][collection_name]
async def get_all_users(self): async def get_all_users(self):
return self.conn['nova-core']['users'] return self.conn[os.getenv('MONGO_NAME', 'nova-test')]['users']
async def create(self, discord_id: str = '') -> dict: async def create(self, discord_id: str = '') -> dict:
chars = string.ascii_letters + string.digits chars = string.ascii_letters + string.digits

View file

@ -169,7 +169,10 @@ async def stream(
headers=target_request.get('headers', {}), headers=target_request.get('headers', {}),
cookies=target_request.get('cookies'), cookies=target_request.get('cookies'),
ssl=False, ssl=False,
timeout=aiohttp.ClientTimeout(total=float(os.getenv('TRANSFER_TIMEOUT', '120'))), timeout=aiohttp.ClientTimeout(
connect=3.0,
total=float(os.getenv('TRANSFER_TIMEOUT', '120'))
),
) as response: ) as response:
if response.content_type == 'application/json': if response.content_type == 'application/json':
data = await response.json() data = await response.json()

View file

@ -1 +1,13 @@
# Script to start the production server
# Copy files to production
cp -r * /home/nova-prod
# Copy env file to production
cp env/.prod.env /home/nova-prod/.env
# Change directory
cd /home/nova-prod
# Start screen
screen -S nova-api python run prod screen -S nova-api python run prod

View file

@ -69,7 +69,10 @@ def test_library():
return completion['choices'][0]['message']['content'] return completion['choices'][0]['message']['content']
def test_library_moderation(): def test_library_moderation():
return closedai.Moderation.create('I wanna kill myself, I wanna kill myself; It\'s all I hear right now, it\'s all I hear right now') try:
return closedai.Moderation.create('I wanna kill myself, I wanna kill myself; It\'s all I hear right now, it\'s all I hear right now')
except closedai.errors.InvalidRequestError as exc:
return True
def test_models(): def test_models():
response = httpx.get( response = httpx.get(