-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_terminal.py
More file actions
68 lines (56 loc) · 2.35 KB
/
app_terminal.py
File metadata and controls
68 lines (56 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import sys
import logging
from core.smolagents import MultiAgentCoding
def main():
"""
Simple terminal interface for interacting with the MultiAgentCoding system.
Allows users to input coding requests and displays the generated code responses.
"""
# Set up logging
logging.basicConfig(
level=logging.WARNING, # Changed from INFO to WARNING to disable most logs
format='%(asctime)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)
logger.disabled = True # Disable this logger
logger.info("Initializing MultiAgentCoding system")
coding = MultiAgentCoding()
logger.info("Starting terminal interface")
print("Welcome to the MultiAgent Coding!")
print("Enter your coding requests, or type 'exit' to quit.")
print("-" * 50)
while True:
try:
# Get user input
user_input = input("\nEnter your coding request: ").strip()
# Check for exit command
if user_input.lower() in ['exit', 'quit']:
logger.info("User requested exit")
print("\nThank you for using MultiAgent Coding. Goodbye!")
sys.exit(0)
# Skip empty inputs
if not user_input:
logger.debug("Empty input received, continuing")
continue
logger.info("Processing user request: %s", user_input)
print("\nThinking... Please wait...\n")
# Process the request
logger.debug("Calling run_terminal with user input")
result = coding.run_terminal(user_input)
# Display the result
logger.info("Request processed successfully")
print("-" * 50)
print("Final AI response to user:")
print("-" * 50)
print(result)
print("-" * 50)
except KeyboardInterrupt:
logger.warning("Operation cancelled by keyboard interrupt")
print("\n\nOperation cancelled by user.")
sys.exit(0)
except Exception as e:
logger.error("Error occurred while processing request", exc_info=True)
print(f"\nAn error occurred: {str(e)}")
print("Please try again.")
if __name__ == "__main__":
main()