add services shared layer
This commit is contained in:
parent
8aaed632b6
commit
94d28188d9
|
@ -6,8 +6,8 @@ from simplylab.services.chat import ChatService
|
|||
|
||||
|
||||
class Services:
|
||||
def __init__(self, ctx: Context, providers: Providers):
|
||||
self.ctx = ctx
|
||||
def __init__(self, context: Context, providers: Providers):
|
||||
self.ctx = context
|
||||
self.pvd = providers
|
||||
|
||||
@property
|
||||
|
|
|
@ -8,12 +8,14 @@ from simplylab.model.req import GetAiChatResponseInput, GetUserChatHistoryInput,
|
|||
from simplylab.model.table import MessageRoleType, Message
|
||||
from simplylab.error import MessageLimitedInDailyError, MessageLimitedIn30SecondsError
|
||||
from simplylab.providers import Providers
|
||||
from simplylab.services.shared import ServicesShared
|
||||
|
||||
|
||||
class ChatService:
|
||||
def __init__(self, ctx: Context, providers: Providers):
|
||||
self.ctx = ctx
|
||||
def __init__(self, context: Context, providers: Providers):
|
||||
self.ctx = context
|
||||
self.pvd = providers
|
||||
self.shared = ServicesShared(context, providers)
|
||||
|
||||
async def get_ai_chat_response(self, req: GetAiChatResponseInput) -> GetAiChatResponseOutput:
|
||||
if await self.pvd.chat.check_user_message_limited_in_30_seconds(self.ctx.user.id):
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
from simplylab.model.entity import Context
|
||||
from simplylab.providers import Providers
|
||||
|
||||
|
||||
class ServicesShared:
|
||||
def __init__(self, context: Context, providers: Providers) -> None:
|
||||
self.ctx = context
|
||||
self.pvd = providers
|
||||
|
||||
def do_sth(self):
|
||||
res = self.pvd.user.get_user_by_name("SimplyLab")
|
||||
return None
|
Loading…
Reference in New Issue