left/right arrow key readline bindings in chat, closes #376

This commit is contained in:
Simon Willison 2024-01-26 13:12:55 -08:00
parent 029d8e9e26
commit 1a4853d80e

View file

@ -341,7 +341,9 @@ def chat(
"""
Hold an ongoing chat with a model.
"""
readline.parse_and_bind("")
# Left and right arrow keys to move cursor:
readline.parse_and_bind("\\e[D: backward-char")
readline.parse_and_bind("\\e[C: forward-char")
log_path = logs_db_path()
(log_path.parent).mkdir(parents=True, exist_ok=True)
db = sqlite_utils.Database(log_path)