44 lines
1.1 KiB
Python
44 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Text interface for the LLM interaction system.
|
|
Handles input/output operations with the user.
|
|
"""
|
|
|
|
|
|
class TextInterface:
|
|
"""Handles text-based input and output operations."""
|
|
|
|
def __init__(self):
|
|
"""Initialize the text interface."""
|
|
pass
|
|
|
|
def get_user_input(self):
|
|
"""Get input from the user.
|
|
|
|
Returns:
|
|
str: The user's input text
|
|
"""
|
|
try:
|
|
user_input = input("> ")
|
|
return user_input
|
|
except EOFError:
|
|
# Handle Ctrl+D (EOF) gracefully
|
|
return "quit"
|
|
|
|
def display_response(self, response):
|
|
"""Display the LLM response to the user.
|
|
|
|
Args:
|
|
response (str): The response text to display
|
|
"""
|
|
print(response)
|
|
print() # Add a blank line for readability
|
|
|
|
def display_system_message(self, message):
|
|
"""Display a system message to the user.
|
|
|
|
Args:
|
|
message (str): The system message to display
|
|
"""
|
|
print(f"[System] {message}")
|
|
print() |