- 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 finance, web search, and news. It delivers enriched, prompt-ready data, empowering AI with verified and up-to-date information for diverse applications.
- Stock Market Analysis: A real-world use case where the assistant reasons over live stock price changes, breaking news, and trade volume in the last 24 hours to deliver a comprehensive financial analysis and investment strategy for a selected company.
πΊ 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
Python
βοΈ Initialize Clients
Set up theOpenAI and Dappier Python SDK clients.
Python
π°οΈ Define the Dappier Tool Function
This function will be called by the LLM to fetch real-time stock market data, including the latest news and trades.Python
π Define the User Prompt
This prompt instructs the assistant to gather recent news, trades, and performance metrics, and generate an investment strategy based on those findings.Python
π§ Define the Tool Schema for OpenAI
Weβll registerdappier_real_time_stock_analysis 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 Stock Analysis & Strategy
Run the full conversation and stream the final response as the investment report and strategy.Python
π Highlights
This notebook has guided you through setting up and running a real-time stock analysis workflow using OpenAI Function Calling and Dappier. You can adapt and expand this example for various other scenarios requiring live financial insights, contextual understanding, and intelligent decision-making. 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 finance, news, and trading. 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.

