mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-12-01 11:54:04 +01:00
Typing
This commit is contained in:
parent
98443196d1
commit
76c76584f3
@ -239,7 +239,7 @@ async def handle_embeddings(request: Request, request_data: EmbeddingsRequest):
|
|||||||
if not input:
|
if not input:
|
||||||
raise HTTPException(status_code=400, detail="Missing required argument input")
|
raise HTTPException(status_code=400, detail="Missing required argument input")
|
||||||
|
|
||||||
if type(input) is str:
|
if isinstance(input, str):
|
||||||
input = [input]
|
input = [input]
|
||||||
|
|
||||||
async with embedding_semaphore:
|
async with embedding_semaphore:
|
||||||
|
@ -2,7 +2,7 @@ import base64
|
|||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
from typing import Callable, Optional, AsyncGenerator, Generator
|
from typing import Any, Callable, Optional, AsyncGenerator, Generator
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from modules import shared
|
from modules import shared
|
||||||
@ -58,7 +58,7 @@ def _start_cloudflared(port: int, tunnel_id: str, max_attempts: int = 3, on_star
|
|||||||
raise Exception('Could not start cloudflared.')
|
raise Exception('Could not start cloudflared.')
|
||||||
|
|
||||||
|
|
||||||
def get_next_generator_result(gen: Generator) -> tuple[any, bool]:
|
def get_next_generator_result(gen: Generator) -> tuple[Any, bool]:
|
||||||
"""
|
"""
|
||||||
Because StopIteration interacts badly with generators and cannot be raised into a Future
|
Because StopIteration interacts badly with generators and cannot be raised into a Future
|
||||||
"""
|
"""
|
||||||
@ -69,7 +69,7 @@ def get_next_generator_result(gen: Generator) -> tuple[any, bool]:
|
|||||||
return None, True
|
return None, True
|
||||||
|
|
||||||
|
|
||||||
async def generate_in_executor(partial: partial, loop: AbstractEventLoop = None) -> AsyncGenerator[any, any]:
|
async def generate_in_executor(partial: partial, loop: AbstractEventLoop|None = None) -> AsyncGenerator[Any, Any]:
|
||||||
"""
|
"""
|
||||||
Converts a blocking generator to an async one
|
Converts a blocking generator to an async one
|
||||||
"""
|
"""
|
||||||
@ -84,7 +84,7 @@ async def generate_in_executor(partial: partial, loop: AbstractEventLoop = None)
|
|||||||
yield result
|
yield result
|
||||||
|
|
||||||
|
|
||||||
async def run_in_executor(partial: partial, loop: AbstractEventLoop = None) -> Future:
|
async def run_in_executor(partial: partial, loop: AbstractEventLoop|None = None) -> Future:
|
||||||
"""
|
"""
|
||||||
Runs a blocking function in a new thread so it can be awaited.
|
Runs a blocking function in a new thread so it can be awaited.
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user