Spaces:
Paused
Paused
| from pygmyclaw import PygmyClaw | |
| class AgentExecutor: | |
| _agent = None # singleton | |
| def __init__(self): | |
| if AgentExecutor._agent is None: | |
| print("[EXECUTOR] Initializing PygmyClaw once...") | |
| AgentExecutor._agent = PygmyClaw() | |
| def run(self, prompt, agent_type): | |
| agent = AgentExecutor._agent | |
| system_prompt = self.get_system_prompt(agent_type) | |
| final_prompt = f""" | |
| {system_prompt} | |
| User Task: | |
| {prompt} | |
| """ | |
| print(f"[EXECUTOR] Running ({agent_type})") | |
| print(f"[DEBUG PROMPT]\n{final_prompt[:300]}") | |
| return agent.generate_with_ssd(final_prompt, max_tokens=512) | |
| def get_system_prompt(self, agent_type): | |
| if agent_type == "code": | |
| return """You are a coding agent. | |
| STRICT RULES: | |
| - Always return Python code inside ```python ``` blocks | |
| - Do NOT return JSON tools | |
| - Do NOT use "echo" | |
| - Code must be directly executable | |
| """ | |
| elif agent_type == "research": | |
| return "You are a research agent. Provide detailed factual answers." | |
| elif agent_type == "image": | |
| return "You are an image generation planner." | |
| else: | |
| return "You are a command execution agent." |