Skip to content

Smoothie

Smoothie

The Smoothie object defines the output of an executed BlendSQL script.

Source code in blendsql/_smoothie.py
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
@dataclass
class Smoothie:
    df: pd.DataFrame
    meta: SmoothieMeta

    def __post_init__(self):
        self.df = PrettyDataFrame(self.df)

    def summary(self):
        s = "---------------- SUMMARY ----------------\n"
        s += self.meta.query + "\n"
        s += tabulate(
            pd.DataFrame(
                {
                    "Time (s)": self.meta.process_time_seconds,
                    "Values Passed to Ingredients": self.meta.num_values_passed,
                    "Prompt Tokens": self.meta.prompt_tokens,
                    "Completion Tokens": self.meta.completion_tokens,
                },
                index=[0],
            )
        )
        return s
Source code in blendsql/_smoothie.py
18
19
20
21
22
23
24
25
26
27
28
@dataclass
class SmoothieMeta:
    num_values_passed: int  # Number of values passed to a Map/Join/QA ingredient
    prompt_tokens: int
    completion_tokens: int
    prompts: List[dict]  # Log of prompts submitted to model
    ingredients: Iterable[Type[Ingredient]]
    query: str
    db_url: str
    contains_ingredient: bool = True
    process_time_seconds: float = field(init=False)