mirror of
https://github.com/kennethreitz/simplemind.git
synced 2026-06-05 06:46:18 +00:00
Refactor EnhancedContextPlugin to include command autocompletion and history
This commit is contained in:
@@ -30,6 +30,8 @@ from docopt import docopt
|
||||
from prompt_toolkit import PromptSession
|
||||
from prompt_toolkit.key_binding import KeyBindings
|
||||
from prompt_toolkit.keys import Keys
|
||||
from prompt_toolkit.completion import WordCompleter
|
||||
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
|
||||
|
||||
import xerox
|
||||
|
||||
@@ -696,9 +698,21 @@ class EnhancedContextPlugin(sm.BasePlugin):
|
||||
|
||||
|
||||
def get_multiline_input() -> str:
|
||||
"""Get input from user. Press Enter to send."""
|
||||
session = PromptSession()
|
||||
return session.prompt("> ", multiline=False)
|
||||
"""Get input from user with command autocompletion."""
|
||||
# Define available commands
|
||||
commands = ["/summary", "/topics", "/essence", "/perspectives", "/copy", "/paste"]
|
||||
|
||||
# Create command completer
|
||||
command_completer = WordCompleter(commands, ignore_case=True)
|
||||
|
||||
# Create session with autocompletion and history
|
||||
session = PromptSession(
|
||||
completer=command_completer,
|
||||
auto_suggest=AutoSuggestFromHistory(),
|
||||
complete_while_typing=True,
|
||||
)
|
||||
|
||||
return session.prompt("\n> ", multiline=False)
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -9,3 +9,4 @@ nltk
|
||||
spacy
|
||||
docopt
|
||||
xerox
|
||||
prompt_toolkit
|
||||
|
||||
Reference in New Issue
Block a user