Skip to content

feat: add AntV diagrams + Leaflet maps#83

Open
OchnikBartek wants to merge 3 commits into
mainfrom
feat/advanced-charts
Open

feat: add AntV diagrams + Leaflet maps#83
OchnikBartek wants to merge 3 commits into
mainfrom
feat/advanced-charts

Conversation

@OchnikBartek

@OchnikBartek OchnikBartek commented Jun 1, 2026

Copy link
Copy Markdown
Member

Summary

Adds AntV diagram sidecar + Leaflet map rendering to the generated template, with reliability fixes for MCP tooling across all 6 AI frameworks.

Changes

  • Add enable_antv_charts cookiecutter variable gating AntV MCP sidecar, diagram tools, and Leaflet map rendering
  • Add create_map tool with MapMarker typed schema — prevents empty-marker validation errors from weaker models (GPT-4.5 etc.)
  • Wire create_map into all 6 framework assistants with typed signatures for JSON schema fidelity
  • Add render-once prompt nudge for maps, charts, and AntV diagrams (fixes Opus re-render duplicate bug)
  • Fix MCP connection leak in CrewAI: get_antv_crewai_tools memoizes the started adapter so it's started once per process, not once per request
  • Fix per-request event-loop blocking in LangChain/LangGraph/DeepAgents: memoize tool discovery so _run_sync only blocks on first request
  • Fix antvis-chart Docker healthcheck: plain wget rejected by streamable-HTTP endpoint → replaced with node one-liner
  • Add coordinate bounds validation to MapSpec._validate_center (matches per-marker validation)
  • Remove dead parse_map_spec export
  • Add react-leaflet map renderer in frontend (MapMessage, MapLeaflet components)
  • Add AntV image renderer in tool-call-card.tsx
  • Add matrix test entries for pydantic_ai, langchain, crewai with enable_antv_charts and enable_charts
  • Add TestGeneratedTemplateAntvCharts content tests verifying typed markers, bounds check, cache variables, and absence of removed dead code

Testing

  • Matrix tests: generated pydantic_ai / langchain / crewai / pydantic_deep with --antv-charts; all render, compile, pass ruff
  • TestGeneratedTemplateAntvCharts content tests: MapMarker present, bounds check present, parse_map_spec absent, list[MapMarker] in assistant, module-level cache in antv_chart.py
  • Typed-marker fix verified via LangChain smoke test (dict markers coerced, empty markers rejected)
  • All tests pass locally: make test
  • Linting passes: make lint
  • Type checking passes: make typecheck
  • Generated projects still work: tested with at least one preset

@OchnikBartek OchnikBartek requested a review from DEENUU1 June 1, 2026 13:47
@OchnikBartek OchnikBartek self-assigned this Jun 1, 2026
@OchnikBartek OchnikBartek added the enhancement New feature or request label Jun 1, 2026
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
fastapi_gen/prompts.py 90.90% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

bll-kacper-wlodarczyk

This comment was marked as off-topic.

@DEENUU1 DEENUU1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid, well-documented feature — the per-framework MCP wiring, graceful degradation, typed MapMarker schema, and the dedicated content tests are all nicely done. A few things worth addressing before merge: a doc/compose mismatch around the production compose, publishing the unauthenticated MCP port to the host in prod, and two edge cases in the tool-discovery memoization (thread-safety race + permanent caching of a transient failure). Inline comments below.

Comment thread template/VARIABLES.md Outdated
Comment thread template/{{cookiecutter.project_slug}}/docker-compose.yml Outdated
Comment thread template/{{cookiecutter.project_slug}}/backend/app/agents/tools/antv_chart.py Outdated
Comment thread template/{{cookiecutter.project_slug}}/backend/app/agents/tools/antv_chart.py Outdated
…fety

- antv_chart.py: guard tool discovery with a module-level lock (CrewAI +
  LangChain loaders) so requests racing in the FastAPI threadpool can't
  each start an adapter; memoize only on success so a transient sidecar
  failure (e.g. still warming up) is retried instead of caching [] and
  pinning AntV off until the process restarts.
- docker-compose.yml (prod): drop the host port mapping for the
  antvis-chart sidecar — the backend reaches it over the internal
  network; publishing 1122 exposed an unauthenticated MCP/render endpoint.
- docker-compose.dev.yml: keep the host port, documented as dev-only.
- VARIABLES.md: correct the claim that the sidecar isn't in the prod
  compose — it is, just profile-gated and off by default.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@OchnikBartek OchnikBartek requested a review from DEENUU1 June 8, 2026 11:59
aiohttp 3.13.5 has CVE-2026-34993 and CVE-2026-47265 (fixed in 3.14.0).
pyjwt 2.12.1 has PYSEC-2026-175/177/178/179 (fixed in 2.13.0).
Both are transitive deps pulled in via the project venv; bumping them
unblocks the Security Scan CI job and re-enables all template test jobs
that were skipping because they need: [security].

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants