Загрузка видео...
Не удалось загрузить видео
Messing about with getting structured outputs from an LLM. The concept of 'tools' in Vercel's 'ai' lib makes this pretty simple.
41,182 просмотров • 1 год назад •via X (Twitter)
Комментарии: 10

Nice! Unsolicited feedback: I'd use gpt-4o-mini (more recent) and wouldn't rely too much on the confidence score, since those aren't easily quantifiable and LLMs are not that good with numbers. Another idea is to have it return "not confident", "somewhat confident", ... from an enum instead. Another idea: have a chain of prompts which first classify whether the input is a country or not, and if it is, provide the capital. Begins to look like a state machine 🚀

tools are so cool! Btw if you’re looking for pure structured output, check out the generateObject and streamObject functions

Tools exist on the original APIs, no need for Vercel’s ai libs I want to add.

Useful, thanks!

It’d be amazing to see a full totaltypescript kind of course from you on the Vercel AI SDK soon, pls pls make one!

Maybe worth checking out agentic by @transitive_bs if you're wanting to go deeper with tools. Has a good stdlib collection to play with + you can use it to write SDK agnostic tools if desired.

LOL trying to get the LLM to cooperate the same way it did previously with Djibouti was just hilarious. I haven’t seen this before though I’m excited to try it!

Have you looked at TypeChat? Havent digged deep yet, but seems very interesting. Maybe "outdated" with these new APIs though

That's awesome! I didn't know you could use zod with Vercel AI

Really Nice!

