enhancement: Add Structured Output support#127
enhancement: Add Structured Output support#127Azzedde wants to merge 2 commits intoBeastByteAI:mainfrom
Conversation
|
Hi @Azzedde, Thank you for the PR. I have a couple of questions. First of all, it seems like the structured completion is only implemented at the client level and not exposed to any of the higher level APIs. Is this intentional? Also, currently the project uses unittest, not pytest, so it is better to stick to it. |
|
Hi @OKUA1 , Thank you for your feedback. Regarding the structured completion implementation:
|
Summary
This PR adds structured output support using Pydantic models, allowing users to define output schemas that LLM responses will be parsed into. Closes #121.
Changes
get_parsed_completion()function inskllm/llm/gpt/clients/openai/completion.pythat:tests/test_structured_outputs.pycovering:Motivation
Structured outputs provide more reliable results by:
This directly addresses #121 by implementing the requested structured output functionality.
How to test
get_parsed_completion()with your model classExample test cases are provided in the test file.
Risks & considerations
Additional information
The implementation maintains backward compatibility while adding the new functionality. The parsing happens after the standard completion response, so existing code won't be affected.