extract_book.py
1from mirascope.core import openai2from pydantic import BaseModel34class Book(BaseModel):5 title: str6 author: str78@openai.call("gpt-4o-mini", response_model=Book)9def extract_book(text: str) -> str:10 return f"Extract the book: {text}"1112text = "The Name of the Wind by Patrick Rothfuss"13book = extract_book(text)14assert isinstance(book, Book)15print(book)16# title='The Name of the Wind' author='Patrick Rothfuss'