Skip to content

Commit

Permalink
Make next conversation id lookup more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
njbbaer committed May 6, 2024
1 parent f638018 commit aafb88a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/context.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import re

from .conversation import Conversation
from .yaml_config import yaml
Expand Down Expand Up @@ -84,12 +85,11 @@ def _load_conversation(self):
self._conversation.load()

def _next_conversation_id(self):
base_name = os.path.splitext(os.path.basename(self._filepath))[0]
max_id = max(
(
int(os.path.splitext(file)[0].split("_")[1])
for file in os.listdir(self.conversations_dir)
if file.startswith(base_name + "_")
if re.match(rf"^{self.char_name}_\d+\.yml$", file)
),
default=0,
)
Expand Down

0 comments on commit aafb88a

Please sign in to comment.