mirror of
https://github.com/NovaOSS/nova-api.git
synced 2024-11-26 00:23:57 +01:00
Compare commits
No commits in common. "ce2cd9469e9b2e053e470a1fb6e8a3302ff6ed64" and "e4313b439a47c8ae399d2e6fba51c07e9dfb54b4" have entirely different histories.
ce2cd9469e
...
e4313b439a
12
.github/workflows/tests.yml
vendored
12
.github/workflows/tests.yml
vendored
|
@ -5,9 +5,6 @@ on: [pull_request]
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
|
||||||
MONGO_URI: justtotes
|
|
||||||
NOVA_KEY: ${{ secrets.NOVA_KEY }}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
|
@ -16,17 +13,22 @@ 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: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
pip install uvicorn
|
|
||||||
|
|
||||||
- name: Start API server
|
- name: Start API server
|
||||||
|
env:
|
||||||
|
MONGO_URI: ${{ secrets.MONGO_URI }}
|
||||||
|
TEST_NOVA_KEY: ${{ secrets.NOVA_KEY }}
|
||||||
run: |
|
run: |
|
||||||
python run
|
python run
|
||||||
|
|
||||||
|
- name: Wait for API server to start
|
||||||
|
run: sleep 10 # We can adjust this sleep duration as needed. idk how long the server takes to start
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: python tests
|
run: python tests
|
||||||
|
|
32
README.md
32
README.md
|
@ -12,7 +12,7 @@ Reverse proxy server for "Closed"AI's API.
|
||||||
![Badge showing the number of forks](https://img.shields.io/github/forks/novaoss/nova-api?style=social)
|
![Badge showing the number of forks](https://img.shields.io/github/forks/novaoss/nova-api?style=social)
|
||||||
![Badge showing the number of watchers](https://img.shields.io/github/watchers/novaoss/nova-api?style=social)
|
![Badge showing the number of watchers](https://img.shields.io/github/watchers/novaoss/nova-api?style=social)
|
||||||
|
|
||||||
![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*"
|
> "*OpenAI is very closed*"
|
||||||
>
|
>
|
||||||
|
@ -20,29 +20,13 @@ Reverse proxy server for "Closed"AI's API.
|
||||||
|
|
||||||
We aim to fix that!
|
We aim to fix that!
|
||||||
|
|
||||||
## Star History
|
|
||||||
|
|
||||||
|
|
||||||
###### *I founded FoxGPT (called *NovaGPT* back then)
|
|
||||||
Old, slow, deprecated* FoxGPT vs new NovaAI repository star count:
|
|
||||||
|
|
||||||
<a href="https://star-history.com/#NovaOSS/nova-api&FoxGPT/gpt&Date">
|
|
||||||
<picture>
|
|
||||||
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=NovaOSS/nova-api,FoxGPT/gpt&type=Date&theme=dark" />
|
|
||||||
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=NovaOSS/nova-api,FoxGPT/gpt&type=Date" />
|
|
||||||
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=NovaOSS/nova-api,FoxGPT/gpt&type=Date" />
|
|
||||||
</picture>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<img alt="'Emotional damage' meme, with a man with a worried face and the yellow caption 'emotional damage'" src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Findianmemetemplates.com%2Fwp-content%2Fuploads%2Femotional-damage-1024x575.jpg&f=1&nofb=1&ipt=b325721ee0a7b9e11603a9bd484c8042b82e1704e639887107c6ce3e0d9b389e&ipo=images" height=100>
|
|
||||||
|
|
||||||
## NovaOSS APIs
|
## NovaOSS APIs
|
||||||
Our infrastructure might seem a bit confusing, but it's actually quite simple. Just the first one really matters for you, if you want to access our AI API. The other ones are just for the team.
|
Our infrastructure might seem a bit confusing, but it's actually quite simple. Just the first one really matters for you, if you want to access our AI API. The other ones are just for the team.
|
||||||
|
|
||||||
### AI API
|
### AI API
|
||||||
**Public** (everyone can use it with a valid API key)
|
**Public** (everyone can use it with a valid API key)
|
||||||
|
|
||||||
Endpoint: `https://api.nova-oss.com/v1/...`
|
Official endpoints: `https://api.nova-oss.com/v1/...`
|
||||||
Documentation & info: [nova-oss.com](https://nova-oss.com)
|
Documentation & info: [nova-oss.com](https://nova-oss.com)
|
||||||
|
|
||||||
- Access to AI models
|
- Access to AI models
|
||||||
|
@ -52,24 +36,16 @@ Documentation & info: [nova-oss.com](https://nova-oss.com)
|
||||||
### User/Account management API
|
### User/Account management API
|
||||||
**Private** (NovaOSS operators only!)
|
**Private** (NovaOSS operators only!)
|
||||||
|
|
||||||
Endpoint: `https://api.nova-oss.com/...`
|
Official endpoints: `https://api.nova-oss.com/...`
|
||||||
Documentation: [api.nova-oss.com/docs](https://api.nova-oss.com/docs)
|
Documentation: [api.nova-oss.com/docs](https://api.nova-oss.com/docs)
|
||||||
|
|
||||||
- Access to user accounts
|
- Access to user accounts
|
||||||
- Implemented in [NovaCord](https://nova-oss.com/novacord)
|
- Implemented in [NovaCord](https://nova-oss.com/novacord)
|
||||||
|
|
||||||
### NovaCord Bot API
|
|
||||||
**Private** (NovaOSS operators only!)
|
|
||||||
|
|
||||||
Endpoint: `http://0.0.0.0:3224/...`
|
|
||||||
|
|
||||||
- acess to Discord server member roles (for receiving the Discord level, ...)
|
|
||||||
- hosted using [NovaCord](https://nova-oss.com/novacord)
|
|
||||||
|
|
||||||
### Website API
|
### Website API
|
||||||
**Private** (NovaOSS operators only!)
|
**Private** (NovaOSS operators only!)
|
||||||
|
|
||||||
Endpoint: `https://nova-oss.com/api/...`
|
Official endpoints: `https://nova-oss.com/api/...`
|
||||||
|
|
||||||
This one's code can be found in the following repository: [github.com/novaoss/nova-web](https://github.com/novaoss/nova-web)
|
This one's code can be found in the following repository: [github.com/novaoss/nova-web](https://github.com/novaoss/nova-web)
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ UA_SIMPLIFY = {
|
||||||
|
|
||||||
## MONGODB Setup
|
## MONGODB Setup
|
||||||
|
|
||||||
conn = AsyncIOMotorClient(os.environ['MONGO_URI'])
|
conn = AsyncIOMotorClient(os.getenv('MONGO_URI'))
|
||||||
|
|
||||||
async def _get_collection(collection_name: str):
|
async def _get_collection(collection_name: str):
|
||||||
return conn[os.getenv('MONGO_NAME', 'nova-test')][collection_name]
|
return conn[os.getenv('MONGO_NAME', 'nova-test')][collection_name]
|
||||||
|
|
|
@ -23,7 +23,7 @@ class StatsManager:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.conn = AsyncIOMotorClient(os.environ['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[os.getenv('MONGO_NAME', 'nova-test')][collection_name]
|
return self.conn[os.getenv('MONGO_NAME', 'nova-test')][collection_name]
|
||||||
|
|
|
@ -35,7 +35,7 @@ class UserManager:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.conn = AsyncIOMotorClient(os.environ['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[os.getenv('MONGO_NAME', 'nova-test')][collection_name]
|
return self.conn[os.getenv('MONGO_NAME', 'nova-test')][collection_name]
|
||||||
|
|
3054
api/models.json
3054
api/models.json
File diff suppressed because it is too large
Load diff
|
@ -28,9 +28,6 @@ async def handle(incoming_request):
|
||||||
users = UserManager()
|
users = UserManager()
|
||||||
path = incoming_request.url.path.replace('v1/v1/', 'v1/')
|
path = incoming_request.url.path.replace('v1/v1/', 'v1/')
|
||||||
|
|
||||||
if '/models' in path:
|
|
||||||
return fastapi.responses.JSONResponse(content=models_list)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
payload = await incoming_request.json()
|
payload = await incoming_request.json()
|
||||||
except json.decoder.JSONDecodeError:
|
except json.decoder.JSONDecodeError:
|
||||||
|
@ -55,6 +52,10 @@ async def handle(incoming_request):
|
||||||
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.')
|
||||||
|
|
||||||
|
path_contains_models = '/models' in path
|
||||||
|
if path_contains_models:
|
||||||
|
return fastapi.responses.JSONResponse(content=models_list)
|
||||||
|
|
||||||
costs = config['costs']
|
costs = config['costs']
|
||||||
cost = costs['other']
|
cost = costs['other']
|
||||||
|
|
||||||
|
|
BIN
image-1.png
BIN
image-1.png
Binary file not shown.
Before Width: | Height: | Size: 566 KiB |
|
@ -109,7 +109,7 @@ def test_all():
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
closedai.api_base = api_endpoint
|
closedai.api_base = api_endpoint
|
||||||
closedai.api_key = os.environ['NOVA_KEY']
|
closedai.api_key = os.getenv('TEST_NOVA_KEY')
|
||||||
|
|
||||||
HEADERS = {
|
HEADERS = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|
Loading…
Reference in a new issue