mirror of
https://github.com/NovaOSS/nova-api.git
synced 2024-11-29 09:53:57 +01:00
Compare commits
2 commits
ab3a019e0e
...
f5be895f48
Author | SHA1 | Date | |
---|---|---|---|
f5be895f48 | |||
03f8c9ad0a |
|
@ -7,6 +7,7 @@ import aiohttp
|
||||||
import asyncio
|
import asyncio
|
||||||
import starlette
|
import starlette
|
||||||
|
|
||||||
|
from typing import Set
|
||||||
from rich import print
|
from rich import print
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
@ -23,6 +24,8 @@ CRITICAL_API_ERRORS = ['invalid_api_key', 'account_deactivated']
|
||||||
|
|
||||||
keymanager = providerkeys.manager
|
keymanager = providerkeys.manager
|
||||||
|
|
||||||
|
background_tasks: Set[asyncio.Task] = set()
|
||||||
|
|
||||||
async def respond(
|
async def respond(
|
||||||
path: str='/v1/chat/completions',
|
path: str='/v1/chat/completions',
|
||||||
user: dict=None,
|
user: dict=None,
|
||||||
|
@ -166,7 +169,7 @@ async def respond(
|
||||||
if (not is_stream) and server_json_response:
|
if (not is_stream) and server_json_response:
|
||||||
yield json.dumps(server_json_response)
|
yield json.dumps(server_json_response)
|
||||||
|
|
||||||
asyncio.create_task(
|
task = asyncio.create_task(
|
||||||
after_request.after_request(
|
after_request.after_request(
|
||||||
incoming_request=incoming_request,
|
incoming_request=incoming_request,
|
||||||
target_request=target_request,
|
target_request=target_request,
|
||||||
|
@ -178,3 +181,5 @@ async def respond(
|
||||||
model=model,
|
model=model,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
background_tasks.add(task)
|
||||||
|
task.add_done_callback(background_tasks.discard)
|
||||||
|
|
Loading…
Reference in a new issue