mirror of
https://github.com/NovaOSS/nova-api.git
synced 2024-11-29 11:03:57 +01:00
34 lines
780 B
Python
34 lines
780 B
Python
|
from .helpers import utils
|
||
|
|
||
|
AUTH = True
|
||
|
ORGANIC = True
|
||
|
STREAMING = True
|
||
|
ENDPOINT = 'https://api.openai.com'
|
||
|
MODELS = utils.GPT_3
|
||
|
|
||
|
async def get_key() -> str:
|
||
|
return await utils.random_secret_for('closed')
|
||
|
|
||
|
async def chat_completion(**kwargs):
|
||
|
payload = kwargs
|
||
|
key = await get_key()
|
||
|
|
||
|
return {
|
||
|
'method': 'POST',
|
||
|
'url': f'{ENDPOINT}/v1/chat/completions',
|
||
|
'payload': payload,
|
||
|
'headers': {
|
||
|
'Authorization': f'Bearer {key}'
|
||
|
},
|
||
|
'provider_auth': f'closed>{key}'
|
||
|
}
|
||
|
|
||
|
async def organify(request: dict) -> dict:
|
||
|
key = await get_key()
|
||
|
|
||
|
request['url'] = ENDPOINT + request['path']
|
||
|
request['headers']['Authorization'] = f'Bearer {key}'
|
||
|
request['provider_auth'] = f'closed>{key}'
|
||
|
|
||
|
return request
|