Spaces:
Sleeping
Sleeping
Download app.py from Fsubhan786/AIEngineer: direct link, hf CLI and curl.
- Browser
- Download file 1.59 kB
-
https://huggingface.co/spaces/Fsubhan786/AIEngineer/resolve/main/app.py
- Command line
-
hf download hf://spaces/Fsubhan786/AIEngineer/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Fsubhan786/AIEngineer/resolve/main/app.py
1.59 kB
| """ | |
| app.py — agent UI that shows BOTH the final answer and the tool-call trace, | |
| so reviewers can see the agent reasoning, not just the result. | |
| Deploys free to Hugging Face Spaces. | |
| """ | |
| import gradio as gr | |
| from agent import run | |
| def respond(goal): | |
| if not goal.strip(): | |
| return "Give the agent a goal.", "" | |
| try: | |
| answer, trace = run(goal) | |
| trace_text = "\n".join(trace) if trace else "(no tools were needed)" | |
| return answer, trace_text | |
| except Exception as e: | |
| message = str(e) | |
| if "RESOURCE_EXHAUSTED" in message or "429" in message: | |
| return ( | |
| "Gemini free-tier quota is temporarily exhausted. Wait and retry, " | |
| "or set GEMINI_MODEL=gemini-2.5-flash-lite in .env / Space variables.", | |
| message, | |
| ) | |
| return "The agent hit an error. See the trace box for details.", message | |
| with gr.Blocks(title="AI Engineer — Project 3 Agent") as demo: | |
| gr.Markdown("# Tool-Using Agent\n" | |
| "Calculator · live weather · persistent notes. Bounded loop with guardrails. " | |
| "Project 3 of 4.") | |
| goal = gr.Textbox(label="Goal", | |
| placeholder="e.g. What's sqrt(2025)? Save it as a note, then list my notes.") | |
| go = gr.Button("Run agent", variant="primary") | |
| answer = gr.Markdown(label="Answer") | |
| trace = gr.Textbox(label="Tool-call trace", lines=8, interactive=False) | |
| go.click(respond, [goal], [answer, trace]) | |
| goal.submit(respond, [goal], [answer, trace]) | |
| if __name__ == "__main__": | |
| demo.launch() | |