Skip to content

Commit b932eb7

Browse files
committed
🛠️ fix: update Driver import paths in middleware files
- Updated Driver import paths in middleware files to resolve import issues.
1 parent ab8e68e commit b932eb7

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

llmkira/middleware/llm_task.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
from ..extra.user.schema import Cost
1515
from ..schema import RawMessage, Scraper
1616
from ..sdk.adapter import SCHEMA_GROUP, SingleModel
17-
from ..sdk.endpoint import Driver
1817
from ..sdk.endpoint.openai import Message, Openai, OpenaiResult
1918
from ..sdk.endpoint.schema import LlmRequest, LlmResult
19+
from ..sdk.endpoint.tee import Driver
2020
from ..sdk.memory.redis import RedisChatMessageHistory
2121
from ..sdk.schema import ToolCallCompletion, SystemMessage, Function, Tool
2222
from ..sdk.utils import sync

llmkira/middleware/service_provider/private.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from config import provider_settings
1212
from . import resign_provider
1313
from .schema import BaseProvider, ProviderException
14-
from ...sdk.endpoint import Driver
14+
from ...sdk.endpoint.tee import Driver
1515

1616
WHITE_LIST = []
1717
if provider_settings.get("private", default=None) is not None:
@@ -40,13 +40,13 @@ async def authenticate(self, uid, token, status) -> bool:
4040
if not Driver.from_public_env().available:
4141
raise ProviderException(
4242
"\nYou are using a public and free instance.\nThe current instance key is not configured.",
43-
provider=self.name
43+
provider=self.name,
4444
)
4545
raise ProviderException(
4646
"This is a private instance."
4747
"\nPlease contact the administrator to apply for a private instance."
4848
f"\n You id is {uid}",
49-
provider=self.name
49+
provider=self.name,
5050
)
5151

5252
async def request_driver(self, uid, token) -> Driver:

llmkira/middleware/service_provider/public.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@
1212
from ...sdk.cache import global_cache_runtime
1313
from . import resign_provider
1414
from .schema import BaseProvider, ProviderException
15-
from ...sdk.endpoint import Driver
15+
from ...sdk.endpoint.tee import Driver
1616

1717
QUOTA = 24
1818
WHITE_LIST = []
1919
if provider_settings.get("public", default=None) is not None:
2020
QUOTA = provider_settings.public.get("public_quota", default=24)
2121
WHITE_LIST = provider_settings.public.get("public_white_list", default=[])
22-
logger.debug(f"🍦 Public Provider Config Loaded, QUOTA({QUOTA}) WHITE_LIST({WHITE_LIST})")
22+
logger.debug(
23+
f"🍦 Public Provider Config Loaded, QUOTA({QUOTA}) WHITE_LIST({WHITE_LIST})"
24+
)
2325

2426

2527
class UserToday(BaseModel):
@@ -42,12 +44,12 @@ async def authenticate(self, uid, token, status) -> bool:
4244
if not _pass:
4345
raise ProviderException(
4446
"You are using a public instance. You triggered data flood protection today",
45-
provider=self.name
47+
provider=self.name,
4648
)
4749
if not Driver.from_public_env().available:
4850
raise ProviderException(
4951
"You are using a public instance\nBut current instance apikey unavailable",
50-
provider=self.name
52+
provider=self.name,
5153
)
5254
return True
5355

@@ -61,14 +63,18 @@ async def check_times(self, times: int, uid: str):
6163
if read:
6264
_data: UserToday = UserToday.model_validate(read)
6365
if str(_data.time) != str(date):
64-
await cache.set_data(self.__database_key(uid=uid), value=UserToday().model_dump())
66+
await cache.set_data(
67+
self.__database_key(uid=uid), value=UserToday().model_dump()
68+
)
6569
return True
6670
else:
6771
if _data.count > times:
6872
return False
6973
if _data.count < times:
7074
_data.count += 1
71-
await cache.set_data(self.__database_key(uid=uid), value=_data.model_dump())
75+
await cache.set_data(
76+
self.__database_key(uid=uid), value=_data.model_dump()
77+
)
7278
return True
7379
else:
7480
_data = UserToday()

llmkira/middleware/service_provider/schema.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77

88
from pydantic import field_validator, Field
99

10-
from llmkira.sdk.endpoint import Driver
1110
from pydantic_settings import BaseSettings
1211

12+
from llmkira.sdk.endpoint.tee import Driver
13+
1314

1415
class ProviderSetting(BaseSettings):
1516
provider: str = Field("PUBLIC", validation_alias="SERVICE_PROVIDER")
@@ -27,7 +28,6 @@ def provider_upper(cls, v):
2728

2829

2930
class ProviderException(Exception):
30-
3131
def __init__(self, message: str, provider: str = None):
3232
self.message = message
3333
self.provider = provider
@@ -57,7 +57,9 @@ async def authenticate(self, uid, token, status) -> bool:
5757
"""
5858
必须提供认证文档
5959
"""
60-
raise ProviderException("Base Provider auth your token,refer docs", provider=self.name)
60+
raise ProviderException(
61+
"Base Provider auth your token,refer docs", provider=self.name
62+
)
6163

6264
@abstractmethod
6365
async def request_driver(self, uid, token) -> Driver:

0 commit comments

Comments
 (0)