@chand1012 i had this exact need (the `format: 'json'` option), and i couldn’t find a satisfactory s

@chand1012 i had this exact need (the format: 'json' option), and i couldn’t find a satisfactory solution out there, so i made a parseAsJSON util that takes a string and parses it as JSON even if it has syntax errors or too many closing curly braces, or not enough curly braces, or overly escaped characters, or unescaped characters, or pre- and post-ambles, or

it’s a JS (typescript) package available on NPM called @acusti/parsing. here’s the readme: https://github.com/acusti/uikit/tree/main/packages/parsing

i also implemented some simple few-shot prompting modelled on what’s documented in this guide to get the LLM to return JSON: https://www.pinecone.io/learn/llama-2/#Llama-2-Chat-Prompt-Structure
GitHub
UI toolkit monorepo containing a React component library, UI utilities, a drag-and-drop library, and more - acusti/uikit
Llama 2 is the latest Large Language Model (LLM) from Meta AI. It has been released as an open-access model, enabling unrestricted access to corporations and open-source hackers alike. Here we learn how to use it with Hugging Face, LangChain, and as a conversational agent.
Was this page helpful?