Spaces:
Running
Running
Download features/agent.py from RoxieRoller/H-script-AI: direct link, hf CLI and curl.
- Browser
- Download file 926 Bytes
-
https://huggingface.co/spaces/RoxieRoller/H-script-AI/resolve/main/features/agent.py
- Command line
-
hf download hf://spaces/RoxieRoller/H-script-AI/features/agent.py
-
curl -L -o agent.py https://huggingface.co/spaces/RoxieRoller/H-script-AI/resolve/main/features/agent.py
926 Bytes
| # agent.py — Agentic AI loop | |
| # Implemented: full agentic multi-turn loop with tool calling via api/agent.py | |
| # This module mirrors the tool registry used by the FastAPI agent endpoint. | |
| TOOLS = { | |
| "run_code": "Execute H-Script code via backend /api/run, return output/errors", | |
| "explain_code": "Explain H-Script code in friendly Hinglish", | |
| "suggest_fix": "Given code + error, return fixed code (user manually accepts)", | |
| "generate": "Generate H-Script code from a natural language prompt", | |
| } | |
| def run_agent(prompt: str, code: str, history: list) -> dict: | |
| """ | |
| Implemented — see ai/api/agent.py for the live FastAPI endpoint. | |
| Supports: tool calling, multi-turn history (last 10 messages), | |
| editor code context, two-pass Groq inference (plan + reflect). | |
| """ | |
| return { | |
| "status": "implemented", | |
| "endpoint": "POST /ai/agent", | |
| "tools": list(TOOLS.keys()), | |
| } | |