nova-api/api/providers/closed4.py

36 lines
818 B
Python
Raw Normal View History

2023-10-05 15:06:33 +02:00
from .helpers import utils
AUTH = True
ORGANIC = False
CONTEXT = True
STREAMING = True
MODERATIONS = True
ENDPOINT = 'https://api.openai.com'
MODELS = utils.GPT_4
async def get_key() -> str:
return await utils.random_secret_for('closed4')
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'closed4>{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'closed4>{key}'
return request