import pandas as pd from tqdm import tqdm from turftopic.analyzers import OpenAIAnalyzer, LLMAnalyzer # Loading the data data = pd.read_parquet("data/ecb_data.parquet") content = list(data["content"]) # We write a prompt that will extract the relevant information # We ask the model to separate information to key points so that # they become easier to model summary_prompt="Summarize the following press conference from the European Central Bank into a set of key points separated by two newline characters. Reply with the summary only, nothing else. \n {document}" # Formalize a summarized summarizer = OpenAIAnalyzer("gpt-5-nano", summary_prompt=summary_prompt) summaries = [] # Summarize dataframe, track code execution for document in tqdm(data["content"], desc="Summarising documents..."): summary = summarizer.summarize_document(document) # We print summaries as we go as a sanity check, to make sure # the prompt works print(summary) summaries.append(summary) # Collect summaries into a dataframe summary_df = pd.DataFrame( { "id": data["id"], "date": data["date"], "author": data["author"], "title": data["title"], "summary": summaries, } )