Add AI schema models for structured output and response validation - #4289
Conversation
|
@vabene1111 would love for you to test this approach out. I think recipes will be more reliable with such structured outputs in the long run. |
|
interesting approach, looks good on first glance. Currently not much time but will take a look |
|
I'm curious how many people use the ai import feature? I'm trying to use local AI for my mother import of all her paper Recepies, but do to the limited amount of schema I have access to I cannot tune the output. This sounds like a promising route to fix these issues surrounding the ai import. I wish I could support you with coding, but cannot code. I love this project and hope to see this implemented in the future, or something like this. Thanks PS I was able to get image working but had to add a model file/ prompt using ollama to get the AI to satisfy the strict structure expected by the parser, works most of the time, but could be better. Have not been able to get PDFs to work, but saw another open ticket stating what I believe to be the issue. It seems the endpoint hard coded only accept images and not PDFs (a litellm issue) if I remember I can find it and post the link here. |
|
had to revert this. Did not work right away so I had to fix the import as Recipe was referencing the django ORM model and not your custom schema. After that this was still not working (tested with gemini-flash-latest). Reverting to the old system worked without problems. Feel free to try again but please make sure to test with the most common models (gemini/gpt). |
Introduce Pydantic models for structured output schemas related to recipes and nutrition information.
Implement validation functions to ensure responses from the AI conform to these schemas, enhancing response integrity and usability. Update response formats in API requests to utilize the new schemas.
Fixes #4246