Spaces:
Runtime error
Runtime error
| from modules.db_modules import 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 | |