-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathsimple_main.py
More file actions
90 lines (73 loc) · 2.68 KB
/
simple_main.py
File metadata and controls
90 lines (73 loc) · 2.68 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env python3
"""
Simple main entry point for OpenHands CLI.
This is a simplified version that demonstrates the TUI functionality.
"""
import sys
import traceback
from prompt_toolkit import PromptSession, print_formatted_text
from prompt_toolkit.formatted_text import HTML
from openhands_cli.tui import display_banner
def show_menu() -> str:
"""Show the main menu and get user choice."""
print_formatted_text(HTML("<gold>OpenHands CLI</gold>"))
print_formatted_text(
HTML("<grey>Terminal User Interface for OpenHands AI Agent</grey>")
)
print()
print("🚀 Welcome to OpenHands CLI!")
print()
print("Available options:")
print(" 1. Start Agent Chat - Interactive conversation with AI agent")
print(" 2. Show TUI Demo - Display TUI components")
print(" 3. Exit")
print()
session = PromptSession()
choice: str = session.prompt("Select an option (1-3): ")
return choice.strip()
def show_tui_demo() -> None:
"""Show the TUI demo functionality."""
print()
print("📱 TUI Demo:")
print("Available features:")
print(" • Terminal User Interface (TUI) components")
print(" • Prompt Toolkit integration")
print(" • Agent SDK integration")
print()
print("To use the full functionality, ensure you have:")
print(" 1. OpenHands agent SDK properly configured")
print(" 2. Required environment variables set (LITELLM_API_KEY or OPENAI_API_KEY)")
print(" 3. Proper authentication tokens")
print()
# For now, just show that the CLI is working
try:
display_banner(session_id="demo")
except ImportError as e:
print(f"Note: Full TUI functionality requires additional setup: {e}")
print("TUI demo complete! 🎉")
def main() -> int:
"""Main entry point for the OpenHands CLI."""
try:
# Start agent chat directly by default
from openhands_cli.agent_chat import main as run_agent_chat
return run_agent_chat()
except ImportError as e:
print_formatted_text(
HTML(f"<red>Error: Agent chat requires additional dependencies: {e}</red>")
)
print_formatted_text(
HTML("<yellow>Please ensure the agent SDK is properly installed.</yellow>")
)
return 1
except KeyboardInterrupt:
print_formatted_text(HTML("\n<yellow>Goodbye! 👋</yellow>"))
return 0
except EOFError:
print_formatted_text(HTML("\n<yellow>Goodbye! 👋</yellow>"))
return 0
except Exception as e:
print_formatted_text(HTML(f"<red>Error starting agent chat: {e}</red>"))
traceback.print_exc()
return 1
if __name__ == "__main__":
sys.exit(main())