gpt-json  by piercefreeman

SDK for structured, typehinted GPT responses

created 2 years ago
742 stars

Top 47.7% on sourcepulse

GitHubView on GitHub
Project Summary

This library provides a Python wrapper for OpenAI's GPT models, enabling users to declaratively define expected output formats using Pydantic schemas. It simplifies structured data extraction from LLM responses, supporting various GPT features like Vision API and Function Calling, and includes built-in retry logic and JSON transformation for common API failures.

How It Works

The core mechanism involves defining Pydantic models that represent the desired output structure. The library then injects a JSON schema derived from these models into the prompt, instructing the GPT model to adhere to this format. It supports both single object and list responses, and can integrate with GPT's function calling capabilities by mapping Pydantic models to function signatures.

Quick Start & Requirements

Highlighted Details

  • Supports Pydantic schema definitions for type casting and validation.
  • Integrates with GPT Vision API and Function Calling.
  • Includes lightweight transformations to fix broken JSON (e.g., response truncation, incorrect boolean casing).
  • Offers retry logic for common API failures.

Maintenance & Community

  • The project is actively maintained by piercefreeman.
  • Community support channels are not explicitly mentioned in the README.

Licensing & Compatibility

  • The project is licensed under the MIT License.
  • Compatible with commercial use and closed-source applications.

Limitations & Caveats

The library is specifically tailored for the GPT-X family of models and does not support Hugging Face models due to differences in output mechanisms like logit probabilities and fixed decoder templating. While it attempts to fix common JSON errors, GPT's output can still be unpredictable, and users may need to implement custom logic for edge cases.

Health Check
Last commit

1 year ago

Responsiveness

1 day

Pull Requests (30d)
0
Issues (30d)
0
Star History
7 stars in the last 90 days

Explore Similar Projects

Starred by Aravind Srinivas Aravind Srinivas(Cofounder of Perplexity), Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems), and
1 more.

gpt3-sandbox by shreyashankar

0%
3k
Web app for quick GPT-3 demo prototyping
created 5 years ago
updated 1 year ago
Feedback? Help us improve.