@@ -67,8 +67,13 @@ def get_chat_predict_data(session: SessionDep, chart_record_id: int):
6767 return {}
6868
6969
70+ def get_chat_with_records_with_data (session : SessionDep , chart_id : int , current_user : CurrentUser ,
71+ current_assistant : CurrentAssistant ) -> ChatInfo :
72+ return get_chat_with_records (session , chart_id , current_user , current_assistant , True )
73+
74+
7075def get_chat_with_records (session : SessionDep , chart_id : int , current_user : CurrentUser ,
71- current_assistant : CurrentAssistant ) -> ChatInfo :
76+ current_assistant : CurrentAssistant , with_data : bool = False ) -> ChatInfo :
7277 chat = session .get (Chat , chart_id )
7378 if not chat :
7479 raise Exception (f"Chat with id { chart_id } not found" )
@@ -96,6 +101,16 @@ def get_chat_with_records(session: SessionDep, chart_id: int, current_user: Curr
96101 ChatRecord .recommended_question , ChatRecord .first_chat ,
97102 ChatRecord .finish , ChatRecord .error ).where (
98103 and_ (ChatRecord .create_by == current_user .id , ChatRecord .chat_id == chart_id )).order_by (ChatRecord .create_time )
104+ if with_data :
105+ stmt = select (ChatRecord .id , ChatRecord .chat_id , ChatRecord .create_time , ChatRecord .finish_time ,
106+ ChatRecord .question , ChatRecord .sql_answer , ChatRecord .sql ,
107+ ChatRecord .chart_answer , ChatRecord .chart , ChatRecord .analysis , ChatRecord .predict ,
108+ ChatRecord .datasource_select_answer , ChatRecord .analysis_record_id , ChatRecord .predict_record_id ,
109+ ChatRecord .recommended_question , ChatRecord .first_chat ,
110+ ChatRecord .finish , ChatRecord .error , ChatRecord .data , ChatRecord .predict_data ).where (
111+ and_ (ChatRecord .create_by == current_user .id , ChatRecord .chat_id == chart_id )).order_by (
112+ ChatRecord .create_time )
113+
99114 result = session .execute (stmt ).all ()
100115 record_list : list [ChatRecord ] = []
101116 for row in result :
0 commit comments