From 991e143b63568dfc5fded407774f6da67cd4b2c0 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 12 May 2023 14:49:33 -0700 Subject: [PATCH] aider: Added date/time stamp to the "New session started" message. # Context: USER: add a date/time stamp to the New session started msg ASSISTANT: To add a date/time stamp to the "New session started" message, we will import the `datetime` module and use the `datetime.now()` function to get the current date and time. Then, we will format the date/time string and append it to the message. Here's the change to the `aider/getinput.py` file: ```python aider/getinput.py <<<<<<< ORIGINAL import sys import time import random from pathlib import Path ======= import sys import time import random from pathlib import Path from datetime import datetime >>>>>>> UPDATED aider/getinput.py <<<<<<< ORIGINAL def __init__(self, pretty, yes, input_history_file, chat_history_file): self.pretty = pretty self.yes = yes self.input_history_file = input_history_file self.chat_history_file = Path(chat_history_file) if pretty: self.console = Console() else: self.console = Console(force_terminal=True, no_color=True) self.append_chat_history('# New session started', False) ======= def __init__(self, pretty, yes, input_history_file, chat_history_file): self.pretty = pretty self.yes = yes self.input_history_file = input_history_file self.chat_history_file = Path(chat_history_file) if pretty: self.console = Console() else: self.console = Console(force_terminal=True, no_color=True) current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S") self.append_chat_history(f'# New session started at {current_time}', False) >>>>>>> UPDATED ``` --- aider/getinput.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/aider/getinput.py b/aider/getinput.py index 8e49d8016..1e3659f1b 100644 --- a/aider/getinput.py +++ b/aider/getinput.py @@ -13,6 +13,7 @@ import sys import time import random from pathlib import Path +from datetime import datetime class FileContentCompleter(Completer): @@ -64,7 +65,8 @@ class InputOutput: else: self.console = Console(force_terminal=True, no_color=True) - self.append_chat_history('# New session started', False) + current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S") + self.append_chat_history(f'# New session started at {current_time}', False) def canned_input(self, show_prompt): console = Console()