File size: 954 Bytes
ee57972
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294c730
ee57972
 
 
 
 
 
 
294c730
 
ee57972
 
 
294c730
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

from modules.db_modules import get_db, put_item, get_item, get_lastest_item

def get_history(
        table, 
        name_of_partition_key, 
        value_of_partition_key,
        session_num
        ):
    
    history_list = get_lastest_item(
        table=table,
        name_of_partition_key=name_of_partition_key,
        value_of_partition_key=value_of_partition_key,
    )

    if history_list==[]:
        history = ""
        history_num = 0
    else:
        history = ""
        history_dummy_list = []
        for dic in history_list:
            if dic['session_num'] == session_num:
                history_dummy_list.append("User: " + dic['user_prompt'])
                history_dummy_list.append("Bot: " + dic['bot_response'])

        history_num = int( len(history_dummy_list) / 2 ) # user와 bot이 한 세트이므로, 절반으로 나누기
        
        history = "\n".join(history_dummy_list)

    return history, history_num