Skip to main content
You can also check this cookbook in Colab here. This notebook demonstrates how to set up and leverage OpenAI Function Calling combined with Dappier’s AI Recommendations API for summarizing real-time sports news. By integrating AI-curated content and automated function execution, this notebook walks you through a practical approach to generating concise, up-to-date summaries of trending sports stories. In this notebook, you’ll explore:
  • OpenAI Function Calling: A powerful feature that enables large language models to automatically detect and invoke external tools to accomplish tasks in a structured and contextual manner.
  • Dappier AI Recommendations: A capability that provides real-time, AI-powered content recommendations from trusted sources, delivering rich contextual articles based on the latest news and natural language queries.
  • Sports News Summarization: A real-world use case where the assistant retrieves the latest sports news and generates a human-readable summary for quick consumption.
This setup not only demonstrates a flexible architecture for building intelligent news summarization assistants but also serves as a foundation for developing other real-world applications requiring live content curation, structured tool use, and contextual response generation.

πŸ“Ί Video Walkthrough

Prefer watching? Here’s a video version of this notebook:

πŸ“¦ Installation

Install the required packages:

πŸ”‘ Setting Up API Keys

You’ll need to set up your API keys for OpenAI and Dappier.
This ensures that the tools can interact with external services securely.
You can go to here to get API Key from Dappier with free credits.
Python
You can go to here to get API Key from OpenAI.
Python

βš™οΈ Initialize Clients

Set up the OpenAI and Dappier Python SDK clients.
Python

πŸ›°οΈ Define the Dappier AI Recommendations Tool Function

This function will be called by the LLM to fetch AI-powered sports news recommendations using customizable parameters. It formats all returned articles into a readable string.
Python

πŸ“‹ Define the User Prompt

This prompt instructs the assistant to fetch the latest sports news and generate a readable summary of the most relevant stories.
Python

🧠 Define the Tool Schema for OpenAI

We’ll register get_latest_sports_news as a callable tool for OpenAI’s function calling, allowing the assistant to fetch and summarize live sports articles.
Python

πŸ€– Run the Assistant Workflow

This function runs the full interaction: the model decides which tools to use, retrieves the data, and then generates a final response.
Python

πŸš€ Generate the News Summary

Run the full conversation and stream the final response as a summarized sports news digest.
Python

🌟 Highlights

This notebook has guided you through setting up and running a real-time sports news summarizer using OpenAI Function Calling and Dappier’s AI Recommendations API. You can adapt and expand this example for various content curation scenarios requiring live information and contextual summaries. Key tools utilized in this notebook include:
  • OpenAI Function Calling: Allows the model to automatically determine when to invoke external tools, enabling dynamic decision-making during a conversation.
  • Dappier AI Recommendations: Delivers curated, real-time article recommendations based on natural language queries and similarity scoring, making it ideal for summarizing trending content from trusted domains.
  • Streamed Response Generation: Leverages OpenAI’s streaming capability to output responses incrementally, improving performance and responsiveness when generating long-form summaries.
This flexible architecture can be adapted to build intelligent assistants for domains such as news aggregation, research summaries, and real-time trend tracking.