Hacker News new | ask | show | jobs
by muzani 747 days ago
I'm getting AI to spit out stuff in YAML, because it has trouble doing it in JSON (long story). So we'd get something like follows:

    ----
    - action: web
    - url: https://news.ycombinator.com
    - text: this is the link to hacker news
But AI being what it is, it can be inconsistent. Sometimes it spits out several actions, sometimes it break text apart or do bullet points which is interpreted as a line. Sometimes it hallucinates, like `- web: https://...`

Also most clients are designed to handle JSON perfectly and they have trouble with parsing JSON. And what if there's colons in other lines.

So a YAML to JSON tool would be nice. And better if there's some error correction. Currently, I'm manually writing the error correction, and sometimes it corrects things that aren't errors.

However, knowing AI, it could be possible that AIs would output JSON perfectly fine next week. I know OpenAI Assistants can do this to an extent and Gemini seems to be doing it okay.

1 comments

Yes, I'm planning to use Gemini for this context because of the 1M context length, but 15 reqs per min seems to be a little off :(

However, my implementation (not entirely mine btw) will ensure that whatever the user gets as an output is a valid & type-safe JSON response; otherwise, it will throw an error.