This file will become your README and also the index of your documentation.
If you are new to using nbdev here are some useful pointers to get you
started.
# 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_prepareInstall latest from the GitHub repository:
$ pip install git+https://github.com/gautam-e/litestruct.gitor from pypi
$ pip install litestructDocumentation can be found hosted on this GitHub repository’s pages. Additionally you can find package manager specific guidelines on conda and pypi respectively.
from litestruct import *
from pydantic import BaseModelmodel="azure/gpt-4o-2024-08-06" # e.g. openai/gpt-4o-2024-08-06 would use the standard OpenAI
system_prompt = "Extract the event information."
class CalendarEvent(BaseModel):
name: str
date: str
participants: list[str]user_prompt = "Alice and Bob are going to Carmen's birthday party on 22nd March 2025"r = structured_output(model=model,
system_prompt=system_prompt,
response_format=CalendarEvent, #Note this is the class name (without the `()`)
user_prompt=user_prompt,
)
r.model_dump(){'name': "Carmen's Birthday Party",
'date': '2025-03-22',
'participants': ['Alice', 'Bob']}