first_visit logic
This commit is contained in:
parent
0e33063c99
commit
41fd8e3d15
2 changed files with 6 additions and 5 deletions
|
|
@ -57,8 +57,11 @@ async def init_chat(request: models.InitializeChatRequest):
|
|||
name = None
|
||||
if request.context and request.context.name:
|
||||
name = request.context.name.first_name
|
||||
first_visit = True
|
||||
if request.context:
|
||||
first_visit = request.context.isFirstVisit
|
||||
|
||||
result = await chat_service.initialize_chat(str(request.userId), application, name)
|
||||
result = await chat_service.initialize_chat(str(request.userId), application, name, first_visit)
|
||||
return models.InitializeChatResponse(
|
||||
session_id=result["session_id"],
|
||||
answer=result["answer"],
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ class ChatService:
|
|||
session.add(user_session)
|
||||
session.commit()
|
||||
|
||||
async def initialize_chat(self, uid: str, application, name):
|
||||
async def initialize_chat(self, uid: str, application, name, first_visit):
|
||||
session_id = await self.get_user_session(uid)
|
||||
if not session_id or not await session_service.validate_session(session_id):
|
||||
session_id = await session_service.create_session(agent_id=settings.TALESTORM_AGENT_ID)
|
||||
|
|
@ -191,9 +191,7 @@ class ChatService:
|
|||
"answer": INIT_MESSAGES[0],
|
||||
}
|
||||
|
||||
last_message = await self.get_last_chat_message_date(session_id)
|
||||
print(f"{uid}; {session_id}; {last_message}")
|
||||
if not last_message:
|
||||
if first_visit:
|
||||
return {
|
||||
"session_id": session_id,
|
||||
"answer": INIT_MESSAGES[0],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue