Use this file to discover all available pages before exploring further.
In this tutorial, we’ll create a dynamic context for a chatbot by enriching prompts with custom data. We’re using the “Oscar Award, 1927 – 2023” dataset from Kaggle, which includes every nominee and winner by year, ceremony number, category, nominee name, film, and winner status.
Next, we generate a self-contained sentence for each nomination, combining name, category, film title, and win status.
def make_context(row) -> str: status = "and won the award" if row["winner"] else "but did not win" return ( f"{row['name']} got nominated under the category {row['category']} " f"for the film {row['film']} {status}" )df["text"] = df.apply(make_context, axis=1)df.head(3)
# Example entry #12print(df["text"].iloc[11])# Ana de Armas got nominated under the category actress in a leading role# Example entry #101print(df["text"].iloc[100])# Viktor Prášil, Frank Kruse, Markus Stemler, Lars Ginzel and Stefan Korte# got nominated under the category sound for the film All Quiet on the Western Front# but did not win