I'm using a helper called StructuredOutputParser from langchain/core/output_parsers, which you can u

I'm using a helper called StructuredOutputParser from langchain/core/output_parsers, which you can use a zod schema in order to enforce the result type.

import { StructuredOutputParser } from "@langchain/core/output_parsers";

const parser = StructuredOutputParser.fromZodSchema(generateFixSchema);

i'm using this parser with the input:

    Use the following analysis information to generate precise, non-redundant fixes:
    Generate fixes following these guidelines:
    1. ..........
    2. ..........
    3. ..........
    4. ..........

    addAttribute: This method is used to add an attribute to the element or override the existing attribute.
    injectCss: This method is used to add style values to the element.

    ${parser.getFormatInstructions()}


this basically adds a descriptive text to the prompt which explains what is the JSON structure and how you(LLM) should apply this to the result. In the end, it outputs a JSON with the correct fields. Maybe you can try this. I'm sure you can just reverse engineer the process and write your own helper.

I'll try to post the result of the
getFormatInstructions
when i'm home.
Was this page helpful?