Spaces:
Configuration error
Configuration error
Download agents/ui_agent.py from Smnbrzq/Autonomous-coding-system: direct link, hf CLI and curl.
- Browser
- Download file 1.63 kB
-
https://huggingface.co/spaces/Smnbrzq/Autonomous-coding-system/resolve/main/agents/ui_agent.py
- Command line
-
hf download hf://spaces/Smnbrzq/Autonomous-coding-system/agents/ui_agent.py
-
curl -L -o ui_agent.py https://huggingface.co/spaces/Smnbrzq/Autonomous-coding-system/resolve/main/agents/ui_agent.py
1.63 kB
| """ | |
| UIAgent β UI component generation (React/Next.js/Tailwind) | |
| """ | |
| from typing import Dict | |
| import structlog | |
| from .base_agent import BaseAgent | |
| log = structlog.get_logger() | |
| UI_SYSTEM = """You are an expert React/Next.js/Tailwind CSS UI engineer. | |
| You generate beautiful, responsive, production-ready UI components. | |
| Always use: | |
| - TypeScript with proper types | |
| - Tailwind CSS for styling | |
| - shadcn/ui components when appropriate | |
| - Framer Motion for animations | |
| - Lucide React for icons | |
| - Dark mode support | |
| - Mobile-first responsive design | |
| - Accessibility (aria labels, semantic HTML) | |
| """ | |
| class UIAgent(BaseAgent): | |
| def __init__(self, ws_manager=None, ai_router=None): | |
| super().__init__("UIAgent", ws_manager, ai_router) | |
| async def run(self, task: str, context: Dict = {}, **kwargs) -> str: | |
| session_id = kwargs.get("session_id", "") | |
| task_id = kwargs.get("task_id", "") | |
| await self.emit(task_id, "agent_start", {"agent": "UIAgent", "task": task[:80]}, session_id) | |
| messages = [ | |
| {"role": "system", "content": UI_SYSTEM}, | |
| {"role": "user", "content": ( | |
| f"Generate a complete, production-ready UI component for: {task}\n\n" | |
| f"Requirements:\n" | |
| f"- TypeScript\n- Tailwind CSS\n- Dark mode\n- Mobile responsive\n" | |
| f"- Include all imports\n- Export as default" | |
| )}, | |
| ] | |
| result = await self.llm(messages, task_id=task_id, session_id=session_id, temperature=0.3, max_tokens=6000) | |
| await self.emit(task_id, "ui_generated", {"agent": "UIAgent"}, session_id) | |
| return result | |