|
1 | 1 | # Prime Numbers Calculation Script by TLIEPE
|
2 | 2 |
|
| 3 | + |
| 4 | +## Versioning |
| 5 | + |
| 6 | +This project maintains two versions: |
| 7 | + |
| 8 | +- **v1**: Uses OpenAI's beta feature for structured outputs (deprecated approach). |
| 9 | +- **v2**: Updated to use the stable Instructor library integration with OpenAI API for structured outputs. |
| 10 | + |
| 11 | +Version tags are available in the Git history for easy reference: |
| 12 | + |
| 13 | +- `v1` - Original beta version |
| 14 | +- `v2` - Updated Instructor version |
| 15 | + |
| 16 | + |
3 | 17 | ## Overview
|
4 | 18 | This script is a showcase of a new approach to generating **structured output** using OpenAI's beta capabilities for structured outputs in its API. The script demonstrates a comparison between prime numbers generated locally and those generated through the OpenAI API using structured outputs.
|
5 | 19 |
|
| 20 | +**Important Update:** As OpenAI's structured output feature is currently in beta and subject to future changes, this project has been updated to use the stable approach with the Instructor library. This prevents issues when the beta API is deprecated ("sundown"). The original beta version is preserved in the repository history. |
| 21 | + |
6 | 22 | The **structured output** capability of OpenAI helps ensure responses adhere to a defined format, validated using tools like Pydantic. In this case, it ensures a list of prime numbers is returned in a consistent manner.
|
7 | 23 |
|
8 | 24 | ## How It Works
|
@@ -59,9 +75,11 @@ After setting up the virtual environment and installing the libraries, you're re
|
59 | 75 | ```
|
60 | 76 |
|
61 | 77 | ## Notes
|
62 |
| -- **Structured Output Beta Feature**: This script leverages OpenAI's beta feature for **structured outputs**, as detailed [here](https://openai.com/index/introducing-structured-outputs-in-the-api/). |
| 78 | +- **Structured Output Handling**: Initially, this project used OpenAI's beta feature for structured outputs. It now uses the Instructor library for a stable, production-ready approach. For details about the original beta feature, see [Structured Outputs Introduction](https://openai.com/index/introducing-structured-outputs-in-the-api/). |
63 | 79 | - **MIT License**: This project is licensed under the MIT License, meaning you are free to use, modify, and distribute it as long as proper credit is given.
|
64 | 80 |
|
| 81 | +- **Strict Mode Option**: OpenAI now supports a strict mode in structured output, ensuring perfect schema compliance. This project currently uses a relaxed mode for flexibility in examples. For critical applications, enabling `strict: true` is recommended to guarantee response schema adherence. |
| 82 | + |
65 | 83 | ## License
|
66 | 84 | MIT License. See `LICENSE` for more details.
|
67 | 85 |
|
|
0 commit comments