This simple demo app showcases how to build deterministic interfaces by using Structured Outputs. It also demonstrates how to stream JSON responses.
As an example, the app extracts key details from PDF resumes.
- Reliable Parsing: Ensures output adheres to a defined JSON schema.
- Streaming Responses: Streams structured outputs for dynamic display in the UI.
- Type-Safe Interfaces: Simplifies downstream processing with predictable JSON responses.
-
Clone the repository:
git clone https://github.com/openai/structured-outputs-samples.git cd resume-extraction
-
Install dependencies:
npm i
-
Set up your environment:
export OPENAI_API_KEY=your-api-key
Or create a
.env
file in theresume-extraction
folder containing:OPENAI_API_KEY=<your-api-key>
-
Run the demo
npm run dev
The app will be available at
http://localhost:3000
.
To test the app, you can either upload a PDF resume or use the example resume provided by clicking on the "Use the example" button.
You can then see the extracted fields stream in the UI. To see the full JSON response, toggle the JSON view by clicking on the "{}" icon in the top right.
To update the fields extracted by the model, you can edit the zod schema in lib/resume.ts
file.