API: Add KoboldAI server

Used for interacting with applications that use KoboldAI's API
such as horde.

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri
2024-07-26 16:37:30 -04:00
parent 4e808cbed7
commit b7cb6f0b91
6 changed files with 330 additions and 3 deletions

View File

@@ -828,10 +828,14 @@ class ExllamaV2Container:
return dict(zip_longest(top_tokens, cleaned_values))
async def generate(self, prompt: str, request_id: str, **kwargs):
async def generate(
self, prompt: str, request_id: str, abort_event: asyncio.Event = None, **kwargs
):
"""Generate a response to a prompt"""
generations = []
async for generation in self.generate_gen(prompt, request_id, **kwargs):
async for generation in self.generate_gen(
prompt, request_id, abort_event, **kwargs
):
generations.append(generation)
joined_generation = {