Skip to content

Add retry mechanism for malformed JSON in LLM generators #70

@aviralgarg05

Description

@aviralgarg05

The LlamaDatasetGenerator and OpenAIDatasetGenerator currently raise a ValueError immediately if the LLM response cannot be parsed as JSON.

File: src/agentunit/generators/llm_generator.py

LLMs often fail 1-2 times before succeeding.
Task:

  • Implement a simple retry loop (e.g., 3 attempts) when occurs.
  • Optionally, feed the error back to the LLM to correct its output in the next attempt.

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