mirror of
https://github.com/NovaOSS/nova-api.git
synced 2024-11-25 21:23:56 +01:00
Compare commits
15 commits
0877645981
...
0e10b961a4
Author | SHA1 | Date | |
---|---|---|---|
0e10b961a4 | |||
aeee6ffe1d | |||
c52384c72b | |||
833eb91f45 | |||
735778d13f | |||
13416802cb | |||
70c8dec419 | |||
d1e48324f9 | |||
ae66e2e699 | |||
cdf8d32ac0 | |||
862f8d2c08 | |||
63c717652a | |||
c263cc1626 | |||
8fbb049469 | |||
6c8814e885 |
12
.github/workflows/tests.yml
vendored
12
.github/workflows/tests.yml
vendored
|
@ -1,12 +1,14 @@
|
||||||
name: Python Tests
|
name: Python Tests
|
||||||
|
|
||||||
on: [pull_request]
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types: [review_requested]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
MONGO_URI: justtotes
|
MONGO_URI: ${{ secrets.MONGO_URI }}
|
||||||
NOVA_KEY: ${{ secrets.NOVA_KEY }}
|
NOVA_KEY: ${{ secrets.NOVA_KEY }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
@ -16,7 +18,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.10
|
python-version: 3.x
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
|
@ -24,9 +26,7 @@ jobs:
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
pip install uvicorn
|
pip install uvicorn
|
||||||
|
|
||||||
- name: Start API server
|
- name: Start API server & run tests!
|
||||||
run: |
|
run: |
|
||||||
python run
|
python run
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
run: python tests
|
|
||||||
|
|
10
README.md
10
README.md
|
@ -1,5 +1,5 @@
|
||||||
# ☄️ NovaOSS API Server
|
# ☄️ NovaAI - Core API Server
|
||||||
Reverse proxy server for "Closed"AI's API.
|
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 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,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)
|
![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*"
|
We aim to fix that! NovaAI provides several AI models for you to use for free.
|
||||||
>
|
|
||||||
> — [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
|
||||||
|
|
||||||
|
|
|
@ -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')
|
infix = os.getenv('KEYGEN_INFIX', 'S3LFH0ST')
|
||||||
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))
|
||||||
|
|
||||||
|
|
|
@ -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():
|
||||||
|
|
|
@ -14,6 +14,7 @@ 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
|
||||||
|
@ -22,4 +23,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}')
|
os.system(f'cd api && uvicorn main:app{" --reload" if dev else ""} --host 0.0.0.0 --port {port} & python tests')
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
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
|
||||||
|
@ -91,12 +92,15 @@ 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())
|
print(test_api('gpt-3.5-trubo'))
|
||||||
|
|
||||||
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())
|
||||||
|
@ -106,6 +110,10 @@ 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
|
||||||
|
|
Loading…
Reference in a new issue