Fix/type-error (#11240)

Signed-off-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
-LAN- 2024-12-02 10:24:21 +08:00 committed by GitHub
commit c34bdb74e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 117 additions and 161 deletions

View file

@ -6,7 +6,7 @@ import string
import subprocess
import time
import uuid
from collections.abc import Generator
from collections.abc import Generator, Mapping
from datetime import datetime
from hashlib import sha256
from typing import Any, Optional, Union
@ -180,7 +180,9 @@ def generate_text_hash(text: str) -> str:
return sha256(hash_text.encode()).hexdigest()
def compact_generate_response(response: Union[dict, RateLimitGenerator]) -> Response:
def compact_generate_response(
response: Union[Mapping[str, Any], RateLimitGenerator, Generator[str, None, None]],
) -> Response:
if isinstance(response, dict):
return Response(response=json.dumps(response), status=200, mimetype="application/json")
else: