Skip to content

Commit

Permalink
add warning when loading files
Browse files Browse the repository at this point in the history
  • Loading branch information
RexWzh committed Nov 18, 2023
1 parent dae4444 commit 1344e62
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions chattool/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@ def load_chats( checkpoint:str
chatlogs.extend([None] * (idx - chat_size + 1))
chat_size = idx + 1
chatlogs[idx] = log['chatlog']
# check if there are missing chatlogs
if None in chatlogs:
warnings.warn(f"checkpoint file {checkpoint} has unfinished chats")
else: ## logs without chatid
# check if the checkpoint file is generated with id
if len(logs) > 0 and 'chatid' in logs[0]:
warnings.warn(f"checkpoint file {checkpoint} is generated with id, please use the `withid=True` option")
return []
chatlogs = logs
# return Chat class
return [Chat(chatlog) if chatlog is not None else None for chatlog in chatlogs]
Expand Down

0 comments on commit 1344e62

Please sign in to comment.