add message limit
This commit is contained in:
parent
0e8f130149
commit
7c53602c08
|
@ -4,7 +4,7 @@ from loguru import logger
|
||||||
|
|
||||||
from simplylab.entity import GetAiChatResponseInput, GetUserChatHistoryInput, GetChatStatusTodayInput, UserChatMessage, \
|
from simplylab.entity import GetAiChatResponseInput, GetUserChatHistoryInput, GetChatStatusTodayInput, UserChatMessage, \
|
||||||
GetChatStatusTodayOutput, GetAiChatResponseOutput, GetUserChatHistoryOutput, Context, Message, MessageRoleType
|
GetChatStatusTodayOutput, GetAiChatResponseOutput, GetUserChatHistoryOutput, Context, Message, MessageRoleType
|
||||||
from simplylab.error import MessageLimitedInDailyError
|
from simplylab.error import MessageLimitedInDailyError, MessageLimitedIn30SecondsError
|
||||||
from simplylab.providers import Providers
|
from simplylab.providers import Providers
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,6 +14,11 @@ class ChatService:
|
||||||
self.pvd = provider
|
self.pvd = provider
|
||||||
|
|
||||||
async def get_ai_chat_response(self, req: GetAiChatResponseInput) -> GetAiChatResponseOutput:
|
async def get_ai_chat_response(self, req: GetAiChatResponseInput) -> GetAiChatResponseOutput:
|
||||||
|
if self.pvd.chat.check_user_message_limited_in_30_seconds(self.ctx.user.id):
|
||||||
|
raise MessageLimitedIn30SecondsError()
|
||||||
|
if self.pvd.chat.check_user_message_limited_in_daily(self.ctx.user.id):
|
||||||
|
raise MessageLimitedInDailyError()
|
||||||
|
|
||||||
request_content = req.message
|
request_content = req.message
|
||||||
# todo: request content middle out
|
# todo: request content middle out
|
||||||
response_content = await self.pvd.openrouter.chat(content=request_content)
|
response_content = await self.pvd.openrouter.chat(content=request_content)
|
||||||
|
|
Loading…
Reference in New Issue