DEBO-V1 / modules /history_modules.py
Ridealist's picture
refactor: ๋ถˆํ•„์š”ํ•œ ์ฝ”๋“œ ์ œ๊ฑฐ, DB ๊ด€๋ จ ์ฝ”๋“œ ์ฃผ์„ ์ฒ˜๋ฆฌ
3708b8e
raw
history blame
927 Bytes
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