frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Structured Output with LangChain and Llamafile

https://blog.brakmic.com/structured-output-with-langchain-and-llamafile/
46•brakmic•7mo ago

Comments

dcreater•7mo ago
People still use langchain?
owebmaster•7mo ago
No
anshumankmr•7mo ago
Its good for quickly developing something but for production, I do not think so.We used it for a RAG application I built last year with a client, ended up removing it piece by piece, and found our app responded faster.

But orgs think its some sort of flagbearer of LLMs.As I am interviewing for other roles now, HRs from other companies still ask for how many years of exp I have with Langchain and Agentic AI.

zingababba•7mo ago
What should be used instead?
Hugsun•7mo ago
I gave up after it didn't let me see the prompt that went into the LLM, without using their proprietary service. I'd recommend just using the API directly. They're very simple. There might be some simpler wrapper library if you want all the providers and can't be bothered to implement the support for each. Vercel's ai-sdk seems decent for JS.
halyconWays•7mo ago
>I gave up after it didn't let me see the prompt that went into the LLM, without using their proprietary service.

Haha, really?

ebonnafoux•7mo ago
httpx to make the call yourself, or if you really want a wrapper the openAI python https://github.com/openai/openai-python.
Jimmc414•7mo ago
pydanticai, dspy or deal directly with the provider sdks
dcreater•7mo ago
DSPy seems like the right, developed approach but its far too convoluted and I find the grammar is ugly.
dcreater•7mo ago
Plain old http requests and your own functions.

Its almost always the better choice

codestank•7mo ago
i do because i don't know any better since i'm new to the AI space.
nilamo•7mo ago
My experience, as someone who is also new and trying to figure things out, is that langchain works great as long as everything you want to do has an adapter. Try to step off the path, and things get really complex really fast. After hitting that several times, I've found it's easier to just do things directly instead of trying to figure out the langchain way of doing things.

I've found dspy to work closer to how I think, which has made working with pipelines so much easier for me.

screye•7mo ago
It is useful if you keep swapping things out. Langchain's wrappers stay stable and up-to-date because of their popularity. In production, it's ideal startups that undergo a lot of flux.

I would suggest against using their orchestration tooling, DSLs or default prompts. Those components are either underbaked or require deep adoption in a way that is harder to strip out later.

We change models, providers and search tooling quite often. Having consistent interfaces helps speed things up and reduce legacy buildup. Their stream callbacks, function calling integration, RAG primitives and logging solutions are nice.

One way of another, it is useful to have a langchain-like solution for these needs. Pydanticai + logfire seems like a better version of what I like about langchain. Haven't tried it, but I bet it's good.

reedlaw•7mo ago
The use case in the article is relatively simple. For more complex structures, BAML (https://www.boundaryml.com/) is a better option.
pcwelder•7mo ago
```

try:

    answer = chain.invoke(question)

    # print(answer) # raw JSON output

    display_answer(answer)
except Exception as e:

    print(f"An error occurred: {e}")

    chain_no_parser = prompt | llm

    raw_output = chain_no_parser.invoke(question)

    print(f"Raw output:\n\n{raw_output}")
```

Wait, are you calling LLM again if parsing fails just to get what LLM has sent to you already?

The whole thing is not difficult to do if you directly call API without Lang chain, it'd also help you avoid such inefficiency.

moribunda•7mo ago
I don't get the langchain hate, but I agree that this "blog post" is bad.

Langchain has a way to return raw output, aside "with structured output": https://python.langchain.com/docs/how_to/structured_output/#...

It's pretty common to use a cheaper model to fix these errors to match the schema if it fails with a tool call.

crystal_revenge•7mo ago
> It's pretty common to use a cheaper model to fix these errors to match the schema if it fails with a tool call.

This has not be true for a while.

For open models there's 0 need for these kind of hacks with libraries like Xgrammar and Outlines (and several others) both existing as a solution on their own and being used by a wide range of open source tools to ensure structured generation happens at the logit levels. There's no-need to add multiples to your inference cost, when in some cases (xgrammar) they can reduce inference cost.

For proprietary models more and more providers are using proper structured generation (i.e. constrained decoding) under-the-hood. Most notably OpenAI's current version of structure outputs makes use of logit based methods to guarantee the structure of the output.

Hugsun•7mo ago
The version of llama.cpp that Llamafile uses supports structured outputs. Don't waste your time with bloat like langchain.

Think about why langchain has dozens of adapters that are all targeting services that describe themselves as OAI compatible, Llamafile included.

I'd bet you could point some of them at Llamafile and get structured outputs.

Note that they can be made 100% reliable when done properly. They're not done properly in this article.

halyconWays•7mo ago
>Don't waste your time with bloat like langchain.

Amen. See also: "Langchain is Pointless" https://news.ycombinator.com/item?id=36645575

kristjansson•7mo ago
It's right there. In the screenshot in the blog post. Grammar > 'JSON Schema + Convert'. That's what structured output is.

... it's going to be september forever, isn't it?

Building a Custom Clawdbot Workflow to Automate Website Creation

https://seedance2api.org/
1•pekingzcc•1m ago•1 comments

Why the "Taiwan Dome" won't survive a Chinese attack

https://www.lowyinstitute.org/the-interpreter/why-taiwan-dome-won-t-survive-chinese-attack
1•ryan_j_naughton•1m ago•0 comments

Xkcd: Game AIs

https://xkcd.com/1002/
1•ravenical•2m ago•0 comments

Windows 11 is finally killing off legacy printer drivers in 2026

https://www.windowscentral.com/microsoft/windows-11/windows-11-finally-pulls-the-plug-on-legacy-p...
1•ValdikSS•3m ago•0 comments

From Offloading to Engagement (Study on Generative AI)

https://www.mdpi.com/2306-5729/10/11/172
1•boshomi•5m ago•1 comments

AI for People

https://justsitandgrin.im/posts/ai-for-people/
1•dive•6m ago•0 comments

Rome is studded with cannon balls (2022)

https://essenceofrome.com/rome-is-studded-with-cannon-balls
1•thomassmith65•11m ago•0 comments

8-piece tablebase development on Lichess (op1 partial)

https://lichess.org/@/Lichess/blog/op1-partial-8-piece-tablebase-available/1ptPBDpC
2•somethingp•13m ago•0 comments

US to bankroll far-right think tanks in Europe against digital laws

https://www.brusselstimes.com/1957195/us-to-fund-far-right-forces-in-europe-tbtb
3•saubeidl•14m ago•0 comments

Ask HN: Have AI companies replaced their own SaaS usage with agents?

1•tuxpenguine•16m ago•0 comments

pi-nes

https://twitter.com/thomasmustier/status/2018362041506132205
1•tosh•19m ago•0 comments

Show HN: Crew – Multi-agent orchestration tool for AI-assisted development

https://github.com/garnetliu/crew
1•gl2334•19m ago•0 comments

New hire fixed a problem so fast, their boss left to become a yoga instructor

https://www.theregister.com/2026/02/06/on_call/
1•Brajeshwar•20m ago•0 comments

Four horsemen of the AI-pocalypse line up capex bigger than Israel's GDP

https://www.theregister.com/2026/02/06/ai_capex_plans/
1•Brajeshwar•21m ago•0 comments

A free Dynamic QR Code generator (no expiring links)

https://free-dynamic-qr-generator.com/
1•nookeshkarri7•22m ago•1 comments

nextTick but for React.js

https://suhaotian.github.io/use-next-tick/
1•jeremy_su•23m ago•0 comments

Show HN: I Built an AI-Powered Pull Request Review Tool

https://github.com/HighGarden-Studio/HighReview
1•highgarden•23m ago•0 comments

Git-am applies commit message diffs

https://lore.kernel.org/git/bcqvh7ahjjgzpgxwnr4kh3hfkksfruf54refyry3ha7qk7dldf@fij5calmscvm/
1•rkta•26m ago•0 comments

ClawEmail: 1min setup for OpenClaw agents with Gmail, Docs

https://clawemail.com
1•aleks5678•33m ago•1 comments

UnAutomating the Economy: More Labor but at What Cost?

https://www.greshm.org/blog/unautomating-the-economy/
1•Suncho•39m ago•1 comments

Show HN: Gettorr – Stream magnet links in the browser via WebRTC (no install)

https://gettorr.com/
1•BenaouidateMed•41m ago•0 comments

Statin drugs safer than previously thought

https://www.semafor.com/article/02/06/2026/statin-drugs-safer-than-previously-thought
1•stareatgoats•42m ago•0 comments

Handy when you just want to distract yourself for a moment

https://d6.h5go.life/
1•TrendSpotterPro•44m ago•0 comments

More States Are Taking Aim at a Controversial Early Reading Method

https://www.edweek.org/teaching-learning/more-states-are-taking-aim-at-a-controversial-early-read...
2•lelanthran•45m ago•0 comments

AI will not save developer productivity

https://www.infoworld.com/article/4125409/ai-will-not-save-developer-productivity.html
1•indentit•50m ago•0 comments

How I do and don't use agents

https://twitter.com/jessfraz/status/2019975917863661760
1•tosh•56m ago•0 comments

BTDUex Safe? The Back End Withdrawal Anomalies

1•aoijfoqfw•59m ago•0 comments

Show HN: Compile-Time Vibe Coding

https://github.com/Michael-JB/vibecode
7•michaelchicory•1h ago•1 comments

Show HN: Ensemble – macOS App to Manage Claude Code Skills, MCPs, and Claude.md

https://github.com/O0000-code/Ensemble
1•IO0oI•1h ago•1 comments

PR to support XMPP channels in OpenClaw

https://github.com/openclaw/openclaw/pull/9741
1•mickael•1h ago•0 comments