LLM abstractions that
aren't obstructions

Modular. Extensible. Reliable. Open Source.

extract_book.py
              
1from mirascope.core import openai
2from pydantic import BaseModel
3
4class Book(BaseModel):
5 title: str
6 author: str
7
8@openai.call("gpt-4o-mini", response_model=Book)
9def extract_book(text: str) -> str:
10 return f"Extract the book: {text}"
11
12text = "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'
Mirascope Logo

© 2024 Mirascope. All rights reserved.