Find answers from the community

Updated 4 months ago

Is there a way to retry matching a

At a glance

The community member is asking if there is a way to retry matching a certain JSON format, instead of just trying to parse it and re-prompting if it fails. They feel it would be better to have the system correct its mistake instead of retrying entirely. The comments suggest using the OpenAI pydantic program to define the schema, or sending the broken schema to the language model and asking it to correct it. The community member has tried the pydantic program but had issues with it not returning a response sometimes, which is why they are considering going back to using JSON. They are open to the suggestion of sending the broken schema to the model to see if it can correct it, as they thought there might be a built-in way to do this.

Useful resources
Is there a way to retry matching a certain JSON format? Right now i just try to parse it and re-prompt if it fails. But i feel it would be better to just have it correct its mistake instead of retrying enterly right? Is this possible?
W
L
M
6 comments
Did you try OpenAI pydantic program: https://docs.llamaindex.ai/en/stable/examples/output_parsing/openai_pydantic_program.html

You can define the schema in which you want the response.
You could also send the LLM the broken schema and ask it to correct it πŸ€”
Yes Ive tried the pydantic program, but actually had issues with it not returning a response sometimes... thats why im considering going to back to using JSON.
@Logan M yea that seems like a good option. I though maybe there was some build in way of doing this
I'll try resending the broken schema and see if that works
We've been meaning to make this builtin somehow -- but that sounds good πŸ‘
Add a reply
Sign up and join the conversation on Discord