Context
I’m building an AI plugin to autofill fields from a web form. When clicked, we call an LLM pipeline that reads the user’s uploaded electric diagram (PDF) and suggests a value for that field.
I’ve attached a of the proposed workflow:
- Diagram B: Simplified workflow
Explanation:
1) Upload job (runs when the user uploads the PDF)
-
Trigger: User uploads PDF at the top of the form.
-
LangGraph flow (“Render + Upload”):
-
Render PDF → images (helpful because many models better parse wires/symbols from raster images; PDF text/vector alone can be misleading). I am not sure if this is necessary.
-
Upload both the PDF and the rendered image(s) to the model provider.
-
Return & persist the provider file IDs (PDF + image set).
Open question: Best practice to store/retrieve these IDs for subsequent jobs? (Right now I am leaning toward persisting in the same Laravel job/DB record; looking for patterns here.)
-
2) Field extraction job (runs when the user clicks “Magic Bot” on a specific field)
-
Trigger: Click “Magic Bot” next to a field in the form.
-
Inputs to LangGraph flow:
-
File IDs from step 1 (PDF + images).
-
Field prompt (the field’s label/definition pulled from the form’s
.json, i.e., the JSON that defines the form and its display logic) -
Dropdown options (if applicable) to constrain outputs
-
-
LangGraph flow (“LLM + FuzzyMatch”):
-
LLM call with (prompt + file IDs) → returns free-text candidate value(s).
-
FuzzyMatch candidate(s) against the allowed dropdown list (if the field is constrained). How to implement this?? A) Python script embedded in LangGraph node B) On the PHP side, after getting it back from the LangGraph. C) MCP approach. D) Provide the dropdown options to the LLM, embedding the fuzzymatch in the call (I am leaving this as last option because Im afraid of hitting context window limitation and want to avoid unnecessary energy consumption and cost).
-
Result: The form field is auto-filled and flagged as AI-filled or ,if confidence is low: no fill, just a suggestion.
-
Specific questions for the community
-
Best practice to store file IDs:
Where do you persist provider file (and prompt) IDs so they’re cheap to fetch from the field extraction job? -
MCP (Model Context Protocol) fit:
A collaborator suggested an MCP approach—would MCP be a good way to expose “fetch dropdowns,” “retrieve file IDs,” “write audit record,” etc. as tools to the graph/LLM? Any real-world gotchas with MCP + LangGraph? -
Fuzzy matching strategy:
-
Do you prefer post-LLM deterministic matching (e.g., RapidFuzz on the server) vs. LLM-in-the-loop selection from a large allowed list?
-
If you do LLM-in-the-loop, what patterns keep token use + latency sane (chunking, top-K shortlist, embeddings pre-filter)?
-
-
Spec-driven prompts:
We want theSPEC.json(the large JSON that drives the form + display conditions) to be the single source of truth at runtime. Any tips for:-
Pulling the right label/constraints per field without overloading the prompt
-
Adding OR-style dependencies in the spec so the workflow can infer when a file upload is a valid source (someone suggested modeling upload as a dependency OR; if anyone has done inverse-dependency checks from a spec, would love tips)
-
-
Fallback & UX:
Any patterns for communicating confidence/traceability to the user (e.g., confidence badges, “preview before fill,” or one-click revert)? What’s worked well for you? -
Reliability / idempotency / rate-limits:
Favorite patterns in LangGraph for retries, idempotent form actions, and provider rate-limit handling in a multi-tenant web app?
Questions for the community:
1. Storing file IDs after upload
Right now I am leaning on the Laravel job that handles the initial upload to also persist the provider’s file IDs in a DB record keyed to the form/session. That seems simplest for retrieval later, but I wonder if there are cleaner or more robust ways to handle this (e.g., caching strategies, TTL awareness, or MCP tools).
2. Best way to trigger LangGraph jobs
Our current pattern is: user uploads PDF → Laravel job calls LangGraph (render + upload). Then later, user clicks “Magic Bot” → another Laravel job calls LangGraph (field extraction). This works but feels a little heavyweight. Is this the right abstraction, or do folks prefer a lighter direct call pattern (e.g., async workers or LangGraph as a service endpoint)?
3. Fuzzy matching strategies
Approaches ideas:
-
Post-LLM deterministic fuzzy matching on a python script embedded in an extra LangGraph node
-
Having the LLM itself pick from the dropdown.
The Post-LLM approach seems safer (no hallucinations, controllable scoring), but the LLM option is seasier. Downsides are token costs + reliability. Curious what others have found to be the sweet spot here, especially with large dropdown lists.
4. Extracting prompts from the JSON spec
I want the SPEC.json (the same one that drives the form’s behavior and display conditions) to be the single source of truth. Right now, I am pulling the field label + constraints and feed that to the LLM. Is that the common approach? Or do people find it better to preprocess the spec into a slimmer lookup table to avoid overloading prompts?
5. Handling fallbacks
My idea is: if confidence is low, don’t fill the field automatically, but show a suggestion with trace + raw LLM output. This is fine for an MVP, but I’d love to know what the common practice is here — do people usually implement a “preview and accept” step, or rely on confidence thresholds, or something else?
I am very excited to hear the community’s feedback, hope this is an interesting thread!
