Enhancement Suite: Anti-loop protection, Kokoro TTS integration, ComfyUI status monitoring, and auto-open image functionality
This commit is contained in:
25
build/lib/ollama_cli/ui/repl.py
Normal file
25
build/lib/ollama_cli/ui/repl.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from prompt_toolkit import PromptSession
|
||||
from prompt_toolkit.history import FileHistory
|
||||
from prompt_toolkit.styles import Style
|
||||
from prompt_toolkit.formatted_text import HTML
|
||||
import os
|
||||
|
||||
class REPL:
|
||||
def __init__(self):
|
||||
history_file = os.path.expanduser("~/.ollama-cli-history")
|
||||
self.session = PromptSession(history=FileHistory(history_file))
|
||||
self.style = Style.from_dict({
|
||||
'prompt': 'ansicyan bold',
|
||||
'command': 'ansigreen',
|
||||
})
|
||||
|
||||
def get_input(self) -> str:
|
||||
try:
|
||||
return self.session.prompt(
|
||||
HTML('<prompt><b>> </b></prompt>'),
|
||||
style=self.style
|
||||
).strip()
|
||||
except KeyboardInterrupt:
|
||||
return ""
|
||||
except EOFError:
|
||||
return "/quit"
|
||||
Reference in New Issue
Block a user