Fix: update agents/ui_agent.py
Browse files- agents/ui_agent.py +28 -14
agents/ui_agent.py
CHANGED
|
@@ -1,19 +1,24 @@
|
|
| 1 |
"""
|
| 2 |
-
UIAgent — UI
|
| 3 |
"""
|
| 4 |
-
import structlog
|
| 5 |
from typing import Dict
|
|
|
|
| 6 |
from .base_agent import BaseAgent
|
| 7 |
|
| 8 |
log = structlog.get_logger()
|
| 9 |
|
| 10 |
-
UI_SYSTEM = """You are
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
-
|
| 14 |
-
-
|
|
|
|
|
|
|
|
|
|
| 15 |
- Dark mode support
|
| 16 |
-
-
|
|
|
|
|
|
|
| 17 |
|
| 18 |
|
| 19 |
class UIAgent(BaseAgent):
|
|
@@ -21,11 +26,20 @@ class UIAgent(BaseAgent):
|
|
| 21 |
super().__init__("UIAgent", ws_manager, ai_router)
|
| 22 |
|
| 23 |
async def run(self, task: str, context: Dict = {}, **kwargs) -> str:
|
| 24 |
-
session_id = kwargs.get("session_id",
|
| 25 |
-
task_id
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
| 27 |
{"role": "system", "content": UI_SYSTEM},
|
| 28 |
-
{"role": "user",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
]
|
| 30 |
-
await self.
|
| 31 |
-
|
|
|
|
|
|
| 1 |
"""
|
| 2 |
+
UIAgent — UI component generation (React/Next.js/Tailwind)
|
| 3 |
"""
|
|
|
|
| 4 |
from typing import Dict
|
| 5 |
+
import structlog
|
| 6 |
from .base_agent import BaseAgent
|
| 7 |
|
| 8 |
log = structlog.get_logger()
|
| 9 |
|
| 10 |
+
UI_SYSTEM = """You are an expert React/Next.js/Tailwind CSS UI engineer.
|
| 11 |
+
You generate beautiful, responsive, production-ready UI components.
|
| 12 |
+
Always use:
|
| 13 |
+
- TypeScript with proper types
|
| 14 |
+
- Tailwind CSS for styling
|
| 15 |
+
- shadcn/ui components when appropriate
|
| 16 |
+
- Framer Motion for animations
|
| 17 |
+
- Lucide React for icons
|
| 18 |
- Dark mode support
|
| 19 |
+
- Mobile-first responsive design
|
| 20 |
+
- Accessibility (aria labels, semantic HTML)
|
| 21 |
+
"""
|
| 22 |
|
| 23 |
|
| 24 |
class UIAgent(BaseAgent):
|
|
|
|
| 26 |
super().__init__("UIAgent", ws_manager, ai_router)
|
| 27 |
|
| 28 |
async def run(self, task: str, context: Dict = {}, **kwargs) -> str:
|
| 29 |
+
session_id = kwargs.get("session_id", "")
|
| 30 |
+
task_id = kwargs.get("task_id", "")
|
| 31 |
+
|
| 32 |
+
await self.emit(task_id, "agent_start", {"agent": "UIAgent", "task": task[:80]}, session_id)
|
| 33 |
+
|
| 34 |
+
messages = [
|
| 35 |
{"role": "system", "content": UI_SYSTEM},
|
| 36 |
+
{"role": "user", "content": (
|
| 37 |
+
f"Generate a complete, production-ready UI component for: {task}\n\n"
|
| 38 |
+
f"Requirements:\n"
|
| 39 |
+
f"- TypeScript\n- Tailwind CSS\n- Dark mode\n- Mobile responsive\n"
|
| 40 |
+
f"- Include all imports\n- Export as default"
|
| 41 |
+
)},
|
| 42 |
]
|
| 43 |
+
result = await self.llm(messages, task_id=task_id, session_id=session_id, temperature=0.3, max_tokens=6000)
|
| 44 |
+
await self.emit(task_id, "ui_generated", {"agent": "UIAgent"}, session_id)
|
| 45 |
+
return result
|