Skip to content

Commit e146b3e

Browse files
author
Daniele Briggi
committed
fix(cli): REPL with left/right arrows and commands history
1 parent c58eaad commit e146b3e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ dependencies = [
2626
"markitdown[pptx]",
2727
"markitdown[xls]",
2828
"markitdown[xlsx]",
29+
"prompt-toolkit",
2930
"sqlite-ai",
3031
"sqlite-vector"
3132
]

src/sqlite_rag/cli.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from typing import Optional
88

99
import typer
10+
from prompt_toolkit import prompt
11+
from prompt_toolkit.history import InMemoryHistory
1012

1113
from sqlite_rag.database import Database
1214
from sqlite_rag.settings import SettingsManager
@@ -477,17 +479,23 @@ def download_model(
477479

478480

479481
def repl_mode():
480-
"""Interactive REPL mode"""
482+
"""Interactive REPL mode with arrow key support"""
481483
typer.echo("Entering interactive mode. Type 'help' for commands or 'exit' to quit.")
482484
typer.echo(
483485
"Note: --database and configure commands are not available in REPL mode."
484486
)
485487

486488
disabled_features = ["configure", "--database", "-db"]
489+
history = InMemoryHistory()
487490

488491
while True:
489492
try:
490-
command = input("\nsqlite-rag> ").strip()
493+
command = prompt(
494+
"sqlite-rag> ",
495+
history=history,
496+
enable_history_search=True,
497+
).strip()
498+
491499
if not command:
492500
continue
493501

0 commit comments

Comments
 (0)