chore: 添加虚拟环境到仓库

- 添加 backend_service/venv 虚拟环境
- 包含所有Python依赖包
- 注意:虚拟环境约393MB,包含12655个文件
This commit is contained in:
2025-12-03 10:19:25 +08:00
parent a6c2027caa
commit c4f851d387
12655 changed files with 3009376 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
from abc import abstractmethod
from typing import Awaitable, Callable, TypeVar, Any
from chromadb.config import Component, System
T = TypeVar("T", bound=Callable[..., Any])
A = TypeVar("A", bound=Awaitable[Any])
class RateLimitEnforcer(Component):
"""
Rate limit enforcer.
Implemented as a wrapper around server functions to block requests if rate limits are exceeded.
"""
def __init__(self, system: System) -> None:
super().__init__(system)
@abstractmethod
def rate_limit(self, func: T) -> T:
pass
class AsyncRateLimitEnforcer(Component):
"""
Rate limit enforcer.
Implemented as a wrapper around async functions to block requests if rate limits are exceeded.
"""
def __init__(self, system: System) -> None:
super().__init__(system)
@abstractmethod
def rate_limit(self, func: A) -> A:
pass

View File

@@ -0,0 +1,42 @@
from overrides import override
from typing import Any, Awaitable, Callable, TypeVar
from functools import wraps
from chromadb.rate_limit import RateLimitEnforcer
from chromadb.config import System
T = TypeVar("T", bound=Callable[..., Any])
A = TypeVar("A", bound=Awaitable[Any])
class SimpleRateLimitEnforcer(RateLimitEnforcer):
"""
A naive implementation of a rate limit enforcer that allows all requests.
"""
def __init__(self, system: System) -> None:
super().__init__(system)
@override
def rate_limit(self, func: T) -> T:
@wraps(func)
def wrapper(*args: Any, **kwargs: Any) -> Any:
return func(*args, **kwargs)
return wrapper # type: ignore
class SimpleAsyncRateLimitEnforcer(RateLimitEnforcer):
"""
A naive implementation of a rate limit enforcer that allows all requests.
"""
def __init__(self, system: System) -> None:
super().__init__(system)
@override
def rate_limit(self, func: A) -> A:
@wraps(func)
async def wrapper(*args: Any, **kwargs: Any) -> Any:
return await func(*args, **kwargs)
return wrapper # type: ignore