Package Exports
- gpt-json
- gpt-json/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gpt-json) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
gpt-json
gpt-json is a library that enables interaction with OpenAI's GPT models using JSON and supports schema validation with yup. You can execute requests to retrieve specific information and get a validated result back.
Upcoming features
- Streaming
- Multi message support
- Schema labeling
Getting started
Install
npm install gpt-jsonUsage
import GPTJSON from 'gpt-json';
import { object, number } from 'yup';
const client = new GPTJSON({
apiKey: 'YOUR_OPENAI_API_KEY',
});
const response = await client.executeRequest({
model: 'gpt-4',
request: 'Give me basic data about Estonia',
schema: object({
population: number(),
area: number().meta({ description: 'Area in square meters' }),
}),
});
//=> 'hello from my package'