mirror of
https://github.com/NovaOSS/nova-api.git
synced 2024-11-25 20:33:58 +01:00
add comments to streaming.py
This commit is contained in:
parent
3e811f3e3b
commit
885da2a27e
|
@ -93,10 +93,18 @@ async def stream(
|
||||||
for _ in range(5):
|
for _ in range(5):
|
||||||
headers = {'Content-Type': 'application/json'}
|
headers = {'Content-Type': 'application/json'}
|
||||||
|
|
||||||
|
|
||||||
|
# Load balancing
|
||||||
|
# If the request is a chat completion, then we need to load balance between chat providers
|
||||||
|
# If the request is an organic request, then we need to load balance between organic providers
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if is_chat:
|
if is_chat:
|
||||||
target_request = await load_balancing.balance_chat_request(payload)
|
target_request = await load_balancing.balance_chat_request(payload)
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
# In this case we are doing a organic request. "organic" means that it's not using a reverse engineered front-end, but rather ClosedAI's API directly
|
||||||
|
# churchless.tech is an example of an organic provider, because it redirects the request to ClosedAI.
|
||||||
target_request = await load_balancing.balance_organic_request({
|
target_request = await load_balancing.balance_organic_request({
|
||||||
'method': incoming_request.method,
|
'method': incoming_request.method,
|
||||||
'path': path,
|
'path': path,
|
||||||
|
@ -115,6 +123,8 @@ async def stream(
|
||||||
if target_request['method'] == 'GET' and not payload:
|
if target_request['method'] == 'GET' and not payload:
|
||||||
target_request['payload'] = None
|
target_request['payload'] = None
|
||||||
|
|
||||||
|
# We haven't done any requests as of right now, everything until now was just preparation
|
||||||
|
# Here, we process the request
|
||||||
async with aiohttp.ClientSession(connector=proxies.get_proxy().connector) as session:
|
async with aiohttp.ClientSession(connector=proxies.get_proxy().connector) as session:
|
||||||
try:
|
try:
|
||||||
async with session.request(
|
async with session.request(
|
||||||
|
|
Loading…
Reference in a new issue