@@ -74,6 +74,8 @@ async def on_chat_start(self):
7474 if store .has_history (user .identifier , project_id ):
7575 content = getattr (config , f"CONTINUATION_{ lang_code .upper ()} " , "" )
7676 await cl .Message (content = content ).send ()
77+ history = store .get_history (user .identifier , project_id )
78+ await self .send_history (history , user )
7779 else :
7880 # if the history is empty, display the confirmation message
7981 content = getattr (config , f"CONFIRMATION_{ lang_code .upper ()} " , "" )
@@ -147,6 +149,19 @@ async def on_user_message(self, message):
147149
148150 return response_message
149151
152+ async def send_history (self , history , user ):
153+ assistant_name = getattr (config , "ASSISTANT_NAME" , "Assistant" )
154+
155+ for message in history :
156+ if isinstance (message , HumanMessage ):
157+ author = user .display_name or "You"
158+ elif isinstance (message , AIMessage ):
159+ author = assistant_name
160+ else :
161+ continue
162+
163+ await cl .Message (content = message .content , author = author ).send ()
164+
150165 async def on_system_message (self , message ):
151166 try :
152167 action = message .metadata .get ("action" )
0 commit comments