ExtractResult

Result of extracting structured data from an LLM response.

Usage

Source

ExtractResult(
    data,
    model_name,
    duration,
)

Parameters

data: dict[str, Any]

The extracted data as a dictionary matching the schema.

model_name: str

The model class name used for extraction.

duration: float
Wall-clock time in seconds the extraction took.

Examples

import talk_box as tb
from pydantic import BaseModel

class Sentiment(BaseModel):
    label: str
    score: float

bot = tb.ChatBot().model("gpt-4o-mini")
result = tb.extract(bot, "I love this product!", data_model=Sentiment)
result.data       # {"label": "positive", "score": 0.95}
result.model_name # "Sentiment"
result.duration   # 1.23