SVG geometry:
- Shifted the entire right-column flow 50px right (centre x=580 → 630)
so the 'Final answer' box on the NO branch (at x=410 now, was x=350)
stays inside the card boundary at x=380.
- Loop-back arrow now lives at x=860, still well inside the column's
right edge at x=880.
New tools:
- get_distance(city_a, city_b) — real haversine over a built-in lat/lon
table of 17 cities (IITG-relevant + global hubs).
- get_population(city) — metro-area figures in millions for the same
list.
- get_stock_price(ticker) — mock USD prices for ~12 common tickers.
System prompt now lists the new tools and spells out a three-tool chain
(INR → USD exchange → stock price → share-count calc) as an explicit
example.
Examples overhauled: dropped a couple of weak ones, added
compositional multi-tool questions:
- Delhi–Mumbai distance in miles rounded to the nearest 10
- AAPL shares for 5000 INR (currency → stock → divide)
- Tokyo 9 AM meeting: local time in Delhi + distance between cities
…
Replace HTML-boxes flowchart with inline SVG + real arrows
The CSS box version couldn't draw actual connector lines — the boxes
just stacked with unicode arrow characters between them, and the loop
back had nothing to connect to. Switched to a hand-authored inline SVG:
- Proper line-and-arrowhead connectors between every node (marker defs
for grey and warm-red arrowheads).
- Diamond decision node drawn as a rotated polygon (not a rounded
pill), with labelled YES / NO branches.
- Dashed warm-red "loop back to LLM" arrow that actually routes around
the right side of the diagram from Append-result up to the LLM node.
- Fully self-contained — no CDN, no JS, no runtime parser.
Dropped the now-unused .flow-* CSS rules.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Drop Mermaid, hand-roll the flowchart in HTML + CSS
Mermaid 11.14 kept throwing "Syntax error in text" even after quoting
every label and sanitising edge syntax — likely something about how
Gradio's HTML block wraps the content. Replaced it with a static HTML
diagram styled in the same warm-red / cream palette as the rest of the
app:
- Two columns: plain LLM on the left, agent loop on the right.
- Rounded "pill" decision node, explicit yes / no branches, italic
loop-back arrow.
- No JS, no CDN dependency — always renders.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Match nipunbatra.github.io design system; fix Mermaid parser errors
Look & feel:
- Work Sans body + Playfair Display headings (both from Google Fonts).
- Warm-red #c44536 accent, #1a1a2e ink, cream #faf7f2 surface — same
palette as nipunbatra.github.io / sustainability-lab.github.io.
- Cream title card with warm-red left border replaces the purple/pink
gradient block.
- Underlined-accent tab bar, rounded-corner primary button, subtle
shadows and 4px corners throughout.
- Pill example buttons now white with cream hover in the warm-red.
- Gradio theme switched from Soft to Default(red) so our CSS variables
control the look.
Mermaid:
- Fully quote every node label; switch edge labels from `-- x -->` to
`-->|x|`; drop <br/> from inside diamond labels. Mermaid 11.14 is
strict about unquoted specials and that was the source of
"Syntax error in text".
- Use mermaid.run({nodes}) async with a :not([data-processed]) selector
so re-renders after tab swaps don't double-parse.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Mermaid: drop emojis + classDef from subgraph labels (they tripped the
parser), simplify edge labels, re-run on DOM mutations so the diagram
renders after tab switches.
- Replace gr.Examples with styled pill buttons in a flex-wrapping row.
No more redundant model-name column in the examples table. Each pill
populates the question textbox and chains into run_both with the
currently selected model.
- CSS: pill shape, gradient title card unchanged, focus ring on the
question textbox, global left-alignment for headings / labels /
paragraphs so the layout stops centring everything.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Gemma 3 sometimes emits tool calls as bare 'name, k=v' without parens
or brackets, e.g. 'get_weather, city=\"Delhi\" get_weather, city=\"Bangalore\"'.
Added a fourth leak-extraction pattern so the agent loop can recover
those and actually run the tools.
- Added google/gemma-3n-E2B-it and google/gemma-4-e2b-it to the model
dropdown for experimentation, with a comment noting these on-device
models are usually not served by Inference Providers and will return
model_not_supported on most accounts.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Render LaTeX, auto-run examples, fallback on empty final answer
- gr.Markdown outputs now accept \$…\$ / \$\$…\$\$ / \\(…\\) LaTeX so
the plain-LLM column renders math cleanly instead of showing raw
dollar signs.
- Examples click now auto-runs both panels (fn=run_both,
run_on_click=True) and shows all examples on one page instead of
paginating.
- When the agent loop's final turn returns empty content after a tool
call (Gemma's habit on single-step questions), surface the last tool
result in the Final answer box instead of a blank.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add Mermaid flowchart tab, simplify How-it-works, new tools + hard examples
- New tab: Flowchart — a Mermaid diagram showing the plain-LLM path vs.
the tool-calling agent loop, rendered via Mermaid.js from CDN.
- How it works tab trimmed: short piece-table + 7-line pseudocode up
front; the long system-prompt and per-tool schemas moved into a
collapsible accordion.
- Two new tools: get_time (timezones/cities) and get_exchange_rate
(demo-rate currency conversion) with matching JSON schemas.
- Harder arithmetic examples (powers, percentages, square roots,
mixed-unit multi-step) to make plain-LLM failures more obvious.
- Parse tool-call leaks in three shapes now — JSON, Python
[tool(k=v)] (Gemma 3 symptom), and <function=foo {...}> (Llama).
Gemma was emitting [convert_units(from_unit=celsius, ...)] as final
content; the loop now re-enters and runs it.
- Tightened system prompt to forbid Python/JSON tool-call syntax in the
natural-language reply.
- Custom CSS: gradient title card, colour-coded plain vs. agent panels,
highlighted final-answer box…
Default to Gemma 3, surface friendly model/provider errors
- Reorder MODELS so Gemma 3 27B is the default. Llama 3.3 70B triggers
`tool_use_failed` on some providers when it nests custom function
syntax; Gemma handles tool calls more cleanly.
- Drop Qwen2.5-72B (not broadly enabled on free accounts); add
Qwen2.5-7B instead.
- Friendly error messages for model_not_supported / tool_use_failed /
missing HF_TOKEN so users get actionable hints instead of a raw JSON
error dump.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Upgrade UI + system prompt + leaked-tool-call fallback
- Add tabs: Demo | How it works. The second tab shows the full system
prompt plus every tool's JSON schema and Python source.
- Model picker dropdown with Llama-3.3-70B (default), Qwen2.5-72B,
Llama-3.1-8B so students can watch a small model fail.
- Add a system prompt that tells the model to always reach for
`calculate` on arithmetic and to keep chaining tools until it has the
final number — this was the cause of the "5 km/day for a week" stall.
- Separate the final answer into its own highlighted panel; collapse the
step-by-step trace into an accordion.
- Regex fallback for models that leak tool calls into content as plain
JSON (Llama-3.1-8B symptom) so the agent doesn't silently give up.
- Tolerate non-numeric `value` in convert_units.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pin Gradio 5 + Python 3.11 for HF Space compatibility
Py 3.13 removed the audioop module that Gradio 4.x indirectly imports
through pydub, breaking the build. Gradio 5 drops that dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Side-by-side Gradio demo built on the Week 12 CS 203 agents-from-scratch
lab. Uses huggingface_hub.InferenceClient so the Space runs on free CPU
Basic — default model is meta-llama/Llama-3.1-8B-Instruct.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>