Skip to content

Use JSONValidator with a class #15

@Godrules500

Description

@Godrules500

Is it possible to use a JSON validator with a class? So instead of manually typing out the properties and required values, and adding "return using this json structure", we'd use a class. That way it's all in one spot? Thanks again!

        const validator = new JSONResponseValidator({
            type: 'object',
            properties: {
                answer: { type: 'string' },
                sentiment: {
                    type: 'string',
                    enum: ['positive', 'neutral', 'negative']
                }
            },
            required: ['answer', 'sentiment']
        });
                new SystemMessage(
                    [
                        `Return your answer using this JSON structure:`,
                        `{"answer":"<answer>","sentiment":"positive|neutral|negative"}`
                    ].join('\n')

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions