SShortSingh.
Back to feed

Fixing Flaky LLM JSON Output by Switching to Function Calling

0
·1 views

A developer building a natural-language tool that turns user requests into API calls found that GPT-3.5 and GPT-4-turbo frequently produced malformed JSON, causing parsing errors and roughly 15-20% failed calls. Prompt tweaks, markdown formatting, schema examples, re-prompting, and regex fixes only partly helped and sometimes made things worse. The breakthrough came from using the model's function calling feature, where the LLM supplies typed arguments and the developer's code builds the JSON with Python's standard library. This shift reportedly reduced the failure rate to nearly zero.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Docker bypasses ufw rules, and logs need rotation before your first container

Docker publishes container ports through the nat table, which runs before the INPUT chain ufw relies on, so a default-deny ufw policy does not block them. The article recommends publishing only a reverse proxy's ports (80 and 443), binding any admin ports to 127.0.0.1 and reaching them through an SSH tunnel, and filtering traffic at the network edge or in the DOCKER-USER chain. It also explains that Docker's default json-file logging does no rotation, so a chatty container can fill the disk, and shows how to set max-size and max-file in /etc/docker/daemon.json. Those settings apply only to newly created containers, so existing ones must be recreated. Finally, it warns that membership in the docker group grants root-level host access and should be limited to trusted admins.

0
ProgrammingDEV Community ·

Postgres 18 Clones Let Each Git Worktree Agent Get Its Own Dev Database

Running several AI coding agents in separate git worktrees isolates their code but not a shared local Postgres database, so one agent's migration can break another's tests. The article proposes giving each worktree its own cloned database instead of a full server or a full data copy. Since Postgres 15 the default CREATE DATABASE strategy copies data block by block, while Postgres 18 adds a file_copy_method setting that can use copy-on-write filesystem cloning to make copies much cheaper. Using it requires setting file_copy_method to clone and specifying STRATEGY = FILE_COPY in the same session, since the default WAL_LOG strategy ignores that setting. The author cites benchmarks where cloning a 6,289 MB database took 212 ms instead of 67,000 ms.

0
ProgrammingDEV Community ·

Seven Weekly Cursor Rules for Senior .NET Engineers, October 12-18, 2026

A weekly digest from the Agentic Architect blog offers one opinionated rule per weekday for senior C#/.NET engineers using Cursor. The rules cover practices such as propagating CancellationToken through async methods, using IHttpClientFactory instead of new HttpClient(), and injecting TimeProvider rather than reading DateTime.Now. Other guidance recommends MapGroup and endpoints for .NET 9 services, FluentValidation for MediatR requests, structured ILogger templates, and keeping database logic within the Infrastructure layer. The digest also promotes a free sample Cursor rule file and a paid full kit priced at £9.00.

0
ProgrammingDEV Community ·

Attention and a 1982 Hopfield memory compute identical outputs, but accuracy degrades with noise

A developer showed that a modern Hopfield network and a single attention head produce bit-identical outputs when their inputs are set equivalently, since both are the same softmax-weighted retrieval computation. Testing the retrieval with random patterns, accuracy declined gradually rather than collapsing as the number of stored patterns grew, reaching about 59% at 200 patterns. Noise in the cue was far more damaging, dropping success from 100% to roughly 3% as noise rose. Sharpening the softmax with a higher inverse temperature helped, though with diminishing returns. The findings were reported from the author's own numpy experiments.