Compare commits

..

No commits in common. "0e10b961a4a35f5fe2bad7cca9865163f4c47c3e" and "08776459818e4c7c26079d9fdb0054721f486fa4" have entirely different histories.

6 changed files with 27 additions and 32 deletions

View file

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

View file

@ -1,5 +1,5 @@
# ☄️ NovaAI - Core API Server # ☄️ NovaOSS API Server
API server for accessing AI models. Reverse proxy server for "Closed"AI's API.
![Badge showing the most used language](https://img.shields.io/github/languages/top/novaoss/nova-api) ![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) ![Badge showing the code size](https://img.shields.io/github/languages/code-size/novaoss/nova-api)
@ -14,7 +14,11 @@ API server for accessing AI models.
![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) ![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)
We aim to fix that! NovaAI provides several AI models for you to use for free. > "*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!
## Star History ## Star History

View file

@ -47,7 +47,7 @@ class UserManager:
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
infix = os.getenv('KEYGEN_INFIX', 'S3LFH0ST') infix = os.getenv('KEYGEN_INFIX')
suffix = ''.join(random.choices(chars, k=20)) suffix = ''.join(random.choices(chars, k=20))
prefix = ''.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(): async def startup_event():
# DATABASE FIX https://stackoverflow.com/questions/65970988/python-mongodb-motor-objectid-object-is-not-iterable-error-while-trying-to-f # DATABASE FIX https://stackoverflow.com/questions/65970988/python-mongodb-motor-objectid-object-is-not-iterable-error-while-trying-to-f
import pydantic, bson import pydantic, bson
# pydantic.json.ENCODERS_BY_TYPE[bson.objectid.ObjectId]=str pydantic.json.ENCODERS_BY_TYPE[bson.objectid.ObjectId]=str
@app.get('/') @app.get('/')
async def root(): async def root():

View file

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

View file

@ -3,7 +3,6 @@
import os import os
import openai as closedai import openai as closedai
import httpx import httpx
import time
from rich import print from rich import print
from typing import List from typing import List
@ -92,15 +91,12 @@ def test_api_moderation() -> dict:
def test_all(): def test_all():
"""Runs all tests.""" """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('[lightblue]Running test on API server to check if its running...')
print(test_server()) print(test_server())
print('[lightblue]Running a api endpoint to see if requests can go through...') print('[lightblue]Running a api endpoint to see if requests can go through...')
print(test_api('gpt-3.5-trubo')) print(test_api())
print('[lightblue]Checking if the API works with the python library...') print('[lightblue]Checking if the API works with the python library...')
print(test_library()) print(test_library())
@ -110,10 +106,6 @@ def test_all():
print('[lightblue]Checking the /v1/models endpoint...') print('[lightblue]Checking the /v1/models endpoint...')
print(test_models()) print(test_models())
except Exception as e:
print('[red]Error: ')
print(e)
exit(500)
if __name__ == '__main__': if __name__ == '__main__':
closedai.api_base = api_endpoint closedai.api_base = api_endpoint