- 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.
πΊ 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
Python
βοΈ Initialize Clients
Set up theOpenAI 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 registerget_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.

