Compare commits

..

15 commits

Author SHA1 Message Date
Game_Time 0e10b961a4
Update tests.yml 2023-08-20 17:42:18 +05:00
Game_Time aeee6ffe1d
Update tests.yml to only work if a review is requested 2023-08-20 17:30:20 +05:00
nsde c52384c72b Changed README 2023-08-20 14:25:39 +02:00
Game_Time 833eb91f45
i lied 2023-08-20 17:11:51 +05:00
nsde 735778d13f Set default keygen infix 2023-08-20 14:07:49 +02:00
Game_Time 13416802cb
making tests properly handle exceptions 2023-08-20 16:23:48 +05:00
Game_Time 70c8dec419
Update tests.yml to use mongo_uri from actions 2023-08-20 16:07:21 +05:00
Game_Time d1e48324f9 fix it up 2023-08-20 16:05:40 +05:00
Game_Time ae66e2e699 debug test 2023-08-20 16:03:21 +05:00
Game_Time cdf8d32ac0 hopefully final please work 2023-08-20 15:46:20 +05:00
Game_Time 862f8d2c08 please work v3 2023-08-20 15:33:01 +05:00
Game_Time 63c717652a
please work v2 2023-08-20 15:29:32 +05:00
Game_Time c263cc1626
please work 2023-08-20 15:29:13 +05:00
Game_Time 8fbb049469
python version to 3.x 2023-08-20 15:20:18 +05:00
Game_Time 6c8814e885
Update main.py 2023-08-20 15:18:36 +05:00
6 changed files with 32 additions and 27 deletions

View file

@ -1,12 +1,14 @@
name: Python Tests
on: [pull_request]
on:
pull_request_target:
types: [review_requested]
jobs:
test:
runs-on: ubuntu-latest
env:
MONGO_URI: justtotes
MONGO_URI: ${{ secrets.MONGO_URI }}
NOVA_KEY: ${{ secrets.NOVA_KEY }}
steps:
@ -16,7 +18,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.10
python-version: 3.x
- name: Install dependencies
run: |
@ -24,9 +26,7 @@ jobs:
pip install -r requirements.txt
pip install uvicorn
- name: Start API server
- name: Start API server & run tests!
run: |
python run
- name: Run tests
run: python tests

View file

@ -1,5 +1,5 @@
# ☄️ NovaOSS API Server
Reverse proxy server for "Closed"AI's API.
# ☄️ NovaAI - Core API Server
API server for accessing AI models.
![Badge showing the most used language](https://img.shields.io/github/languages/top/novaoss/nova-api)
![Badge showing the code size](https://img.shields.io/github/languages/code-size/novaoss/nova-api)
@ -14,11 +14,7 @@ Reverse proxy server for "Closed"AI's API.
![Nova-API Conver/Banner Image - a picture of a galaxy with the caption "the core API server"](https://i.ibb.co/ZBhkS56/nova-api.png)
> "*OpenAI is very closed*"
>
> — [ArsTechnica (July 2023)](https://arstechnica.com/information-technology/2023/07/is-chatgpt-getting-worse-over-time-study-claims-yes-but-others-arent-sure/)
We aim to fix that!
We aim to fix that! NovaAI provides several AI models for you to use for free.
## Star History

View file

@ -47,7 +47,7 @@ class UserManager:
async def create(self, discord_id: str = '') -> dict:
chars = string.ascii_letters + string.digits
infix = os.getenv('KEYGEN_INFIX')
infix = os.getenv('KEYGEN_INFIX', 'S3LFH0ST')
suffix = ''.join(random.choices(chars, k=20))
prefix = ''.join(random.choices(chars, k=20))

View file

@ -26,7 +26,7 @@ app.include_router(core.router)
async def startup_event():
# DATABASE FIX https://stackoverflow.com/questions/65970988/python-mongodb-motor-objectid-object-is-not-iterable-error-while-trying-to-f
import pydantic, bson
pydantic.json.ENCODERS_BY_TYPE[bson.objectid.ObjectId]=str
# pydantic.json.ENCODERS_BY_TYPE[bson.objectid.ObjectId]=str
@app.get('/')
async def root():

View file

@ -14,6 +14,7 @@ Runs for production on the speicified port.
import os
import sys
import time
port = sys.argv[1] if len(sys.argv) > 1 else 2332
dev = True
@ -22,4 +23,4 @@ if 'prod' in sys.argv:
port = 2333
dev = False
os.system(f'cd api && uvicorn main:app{" --reload" if dev else ""} --host 0.0.0.0 --port {port}')
os.system(f'cd api && uvicorn main:app{" --reload" if dev else ""} --host 0.0.0.0 --port {port} & python tests')

View file

@ -3,6 +3,7 @@
import os
import openai as closedai
import httpx
import time
from rich import print
from typing import List
@ -91,21 +92,28 @@ def test_api_moderation() -> dict:
def test_all():
"""Runs all tests."""
try:
print("Waiting until API Server is started up...")
time.sleep(6)
print('[lightblue]Running test on API server to check if its running...')
print(test_server())
print('[lightblue]Running test on API server to check if its running...')
print(test_server())
print('[lightblue]Running a api endpoint to see if requests can go through...')
print(test_api())
print('[lightblue]Running a api endpoint to see if requests can go through...')
print(test_api('gpt-3.5-trubo'))
print('[lightblue]Checking if the API works with the python library...')
print(test_library())
print('[lightblue]Checking if the API works with the python library...')
print(test_library())
print('[lightblue]Checking if the moderation endpoint works...')
print(test_library_moderation())
print('[lightblue]Checking if the moderation endpoint works...')
print(test_library_moderation())
print('[lightblue]Checking the /v1/models endpoint...')
print(test_models())
print('[lightblue]Checking the /v1/models endpoint...')
print(test_models())
except Exception as e:
print('[red]Error: ')
print(e)
exit(500)
if __name__ == '__main__':
closedai.api_base = api_endpoint