Improve interruption UX.

This commit is contained in:
user 2024-12-23 14:10:54 -05:00
parent 34fcb76ad8
commit 1d8b44e1a6
1 changed files with 8 additions and 0 deletions

View File

@ -1,3 +1,4 @@
import sys
from langchain_core.tools import tool
from prompt_toolkit import PromptSession
from prompt_toolkit.key_binding import KeyBindings
@ -16,6 +17,13 @@ def create_keybindings():
"""Trigger submission when Ctrl+D is pressed."""
event.current_buffer.validate_and_handle()
@bindings.add('c-c')
def exit(event):
"""Trigger exit when Ctrl+C is pressed."""
print()
print(" 👋 Bye!")
sys.exit(0)
return bindings
@tool