- Removed commented-out header styles from styles.base.tcss and styles.tcss. - Added new styles for danger buttons and agent selection views in styles.base.tcss and styles.tcss. - Implemented AgentHomeView to manage agent actions and display metadata. - Created AgentSelectView for selecting agents with a new layout and functionality. - Added CreateAgentView for creating new agents with input validation. - Removed obsolete eval.py and replaced it with evaluation.py. - Developed GameSelectView for selecting games with a dynamic loading interface. - Introduced ModelSelectView for selecting models associated with agents. - Created SelectRunView for managing runs associated with agents. - Added SubmissionView and TrainingView for handling model training and submission processes. - Updated requirements.txt to include pyfiglet for ASCII art rendering.
62 lines
2.2 KiB
Python
62 lines
2.2 KiB
Python
from textual.screen import Screen
|
|
from textual.containers import Vertical
|
|
from textual.widgets import Static, Button, Input
|
|
from agentm.components.footer import AgentMFooter
|
|
from agentm.theme.palette import get_theme
|
|
from agentm.utils.logger import log_with_caller
|
|
|
|
from pathlib import Path
|
|
from agentm.logic.db_functions import insert_agent # ✅ Add this import
|
|
|
|
palette = get_theme()
|
|
|
|
|
|
class CreateAgentView(Screen):
|
|
BINDINGS = [("escape", "app.pop_screen", "Back")]
|
|
|
|
def __init__(self, game_metadata: dict):
|
|
super().__init__()
|
|
self.game_metadata = game_metadata
|
|
|
|
def compose(self):
|
|
# Load ASCII header
|
|
ascii_path = Path(__file__).parent.parent / "assets" / "headers" / "create_agent.txt"
|
|
try:
|
|
header_text = ascii_path.read_text()
|
|
except FileNotFoundError:
|
|
header_text = "### Create Agent ###"
|
|
|
|
self.header = Static(f"[{palette.ACCENT}]{header_text}[/{palette.ACCENT}]", classes="header")
|
|
|
|
self.name_input = Input(placeholder="Enter agent name...", id="agent_name_input")
|
|
self.create_button = Button("🚀 Create Agent", id="create_button", classes="confirm_button")
|
|
|
|
yield Vertical(
|
|
self.header,
|
|
self.name_input,
|
|
self.create_button,
|
|
AgentMFooter(compact=True),
|
|
id="create_agent_layout",
|
|
classes="centered_layout"
|
|
)
|
|
|
|
async def on_button_pressed(self, event: Button.Pressed) -> None:
|
|
if event.button.id == "create_button":
|
|
name = self.name_input.value.strip()
|
|
|
|
if name:
|
|
log_with_caller("info", f"Creating agent '{name}' for game_id: {self.game_metadata['game_id']}")
|
|
|
|
# ✅ Insert the agent into the DB
|
|
insert_agent(
|
|
name=name,
|
|
game_id=self.game_metadata["game_id"],
|
|
config_json="{}", # Replace with actual config later
|
|
notes="Created via CreateAgentView"
|
|
)
|
|
|
|
# ✅ Dismiss screen
|
|
await self.app.pop_screen()
|
|
else:
|
|
log_with_caller("warning", "Tried to create agent with empty name.")
|