Skip to main content

Structured output with different LLM providers

Project description

litestruct

This file will become your README and also the index of your documentation.

Developer Guide

If you are new to using nbdev here are some useful pointers to get you started.

Install litestruct in Development mode

# make sure litestruct package is installed in development mode
$ pip install -e .

# make changes under nbs/ directory
# ...

# compile to have changes apply to litestruct
$ nbdev_prepare

Usage

Installation

Install latest from the GitHub repository:

$ pip install git+https://github.com/gautam-e/litestruct.git

or from pypi

$ pip install litestruct

Documentation

Documentation can be found hosted on this GitHub repository’s pages. Additionally you can find package manager specific guidelines on conda and pypi respectively.

How to use

from litestruct import *
from pydantic import BaseModel
model="azure/gpt-4o-2024-08-06"
system_prompt = "Extract the event information."
# This defines the output response format that we want
class CalendarEvent(BaseModel):
    name: str
    date: str
    participants: list[str]
user_prompt = "Alice and Bob are going to Carmen's Birtday party on 22nd March 2025"
r = structured_output(model=model,
                      system_prompt=system_prompt,
                      user_prompt=user_prompt,
                      response_format=CalendarEvent, #Note this is the class name (without the `()`)
                 )

r.model_dump()
{'name': "Carmen's Birthday Party",
 'date': '22nd March 2025',
 'participants': ['Alice', 'Bob']}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

litestruct-0.0.2.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

litestruct-0.0.2-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file litestruct-0.0.2.tar.gz.

File metadata

  • Download URL: litestruct-0.0.2.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for litestruct-0.0.2.tar.gz
Algorithm Hash digest
SHA256 605cd6d53facb01758a3eb90ec2d06a9246fe554317c1806c971c717030002ad
MD5 1b653120fc2a16bf4d6fa319b2857a60
BLAKE2b-256 e978b0edc4be391305c5df07e33378107dee057d0d12b5d6c7998fe7d53709a9

See more details on using hashes here.

File details

Details for the file litestruct-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: litestruct-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for litestruct-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ef04cbdfd89886828f3624dcf6aad4b3d2eab60c4f1f808af8c5709c20d58f9f
MD5 4229a73167081ecc5b0bb4e66f667807
BLAKE2b-256 5ec4bd84b08a5a5226411c660b9c76680d6a30ceebcb74befba02255f9322fd1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page