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 for dynamic travel planning. By integrating real-time data and automated function execution, this notebook walks you through a practical approach to creating adaptive travel plans. 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: A platform connecting LLMs to real-time, rights-cleared data from trusted sources, specializing in domains like web search, weather, and commerce. It delivers enriched, prompt-ready data, empowering AI with verified and up-to-date information for diverse applications.
  • Dynamic Travel Planning: A real-world use case where the assistant reasons over live data to generate a customized 2-day itinerary for New York City based on the latest news, weather, and hotel deals.
This setup not only demonstrates a flexible architecture for building intelligent assistants but also serves as a foundation for developing other real-world applications requiring real-time information retrieval, structured tool use, and contextual decision-making.

πŸ“Ί 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, 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
Your can go to here to get API Key from Open AI.
Python

βš™οΈ Initialize Clients

Set up the OpenAI and Dappier Python SDK clients.
Python

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

This function will be called by the LLM to fetch real-time info.
Python

πŸ“‹ Define the User Prompt

This prompt instructs the assistant to gather news, weather, and hotel data, and then create an itinerary.
Python

🧠 Define the Tool Schema for OpenAI

We’ll register dappier_real_time_search as a callable tool for OpenAI’s function calling.
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 Travel Itinerary

Run the full conversation and stream the final response as the itinerary.
Python

🌟 Highlights

This notebook has guided you through setting up and running a real-time travel planner workflow using OpenAI Function Calling and Dappier. You can adapt and expand this example for various other scenarios requiring live data integration, contextual understanding, and intelligent response generation. 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: A platform connecting LLMs to real-time, rights-cleared data from trusted sources, specializing in domains like web search, weather, and news. It delivers enriched, prompt-ready data, empowering AI with verified and up-to-date information for diverse applications.
  • Streamed Response Generation: Leverages OpenAI’s streaming capability to output responses incrementally, improving performance and responsiveness when generating long-form content.
This comprehensive setup allows you to adapt and expand the example for various scenarios requiring real-time information retrieval, AI-powered orchestration, and live content generation.