Skip to main content
You can also check this cookbook in colab here This notebook demonstrates how to set up and leverage LangChain’s powerful chaining capabilities combined with Dappier’s DappierRealTimeSearchTool for real-time market insights and trading strategies. By integrating real-time financial news, stock trends, and advanced language models, this notebook walks you through an innovative approach to identifying top investment opportunities and crafting data-driven trading strategies. In this notebook, you’ll explore:
  • LangChain: A versatile framework for chaining together language models and other components to create sophisticated AI-driven workflows. It enables seamless integration of LLMs with external tools and data sources, making it ideal for tasks like summarization, question-answering, and more.
  • Dappier: A platform connecting LLMs and Agentic AI agents to real-time, rights-cleared data from trusted sources, specializing in domains like web search, finance, and news. It delivers enriched, prompt-ready data, empowering AI with verified and up-to-date information for diverse applications.
  • OpenAI: A leading provider of advanced AI models capable of natural language understanding, contextual reasoning, and content generation. It enables intelligent, human-like interactions and supports a wide range of applications across various domains.
  • LangSmith: A platform for debugging, testing, and monitoring LangChain applications. It provides detailed tracing and analytics to help you understand and optimize the performance of your AI workflows.
This setup not only demonstrates a practical application of AI-driven real-time market insights and trading strategies but also provides a flexible framework that can be adapted to other real-world scenarios requiring real-time financial data integration from Dappier and advanced language model capabilities. Disclaimer: This notebook is for educational and informational purposes only. It does not constitute financial or trading advice. Trading in financial markets involves risk, and you should consult with a qualified financial advisor before making any investment decisions.

Watch the Video Guide

If you prefer a visual walkthrough, check out the accompanying video guide below:

πŸ“¦ Installation

First, install the Langchain Dappier integration package with all its dependencies:
Python

πŸ”‘ Setting Up API Keys

You’ll need to set up your API keys for Dappier, OpenAI and LangSmith You can go to here to get API Key from Dappier with free credits. The API Key could be found under Settings -> Profile.
Python
Your can go to here to get API Key from Open AI.
Python
Your can go to here to get API Key from LangSmith.
Python

πŸ›°οΈ Access Real Time Data with Dappier Tool

The DappierRealTimeSearchTool is a powerful tool designed to empower AI applications with real-time, up-to-date information across diverse domains such as news, weather, travel, and financial markets. By integrating seamlessly with LangChain, it enables developers to retrieve and process real-time data efficiently. Key features include access to the latest news, weather updates, travel deals, financial news, stock prices, and AI-enhanced insights for accurate and fast information retrieval. With its easy-to-use API and customizable parameters, the tool is ideal for building dynamic, data-driven applications that require real-time intelligence. In this section, we will search for the latest news related to Langchain as an example. Explore a wide range of data models in our marketplace at marketplace.dappier.com. For list of all parameters supported for Dappier retriever visit Dappier docs.
Python
πŸŽ‰ Dappier effortlessly retrieves the latest on Langchain AI, providing valuable data for AI integration!

πŸ“ˆπŸ’° Real-Time Market Insights & Trading Strategies

This section sets up an automated workflow where LangChain and the DappierRealTimeSearchTool collaborate to generate real-time market insights and trading strategies. We will guide the system in retrieving real-time financial news and stock trends, leveraging OpenAI models to analyze data and craft dynamic, actionable trading recommendations.
Python
Define the task prompt
Python
Here we set up our language model and the Dappier real-time search tool. For list of all parameters supported for Dappier retriever visit Dappier docs. Explore a wide range of data models in our marketplace at marketplace.dappier.com.
Python
Setup a function to handle the streaming output from the language model.
Python
Create a function to process any tool calls made by the language model.
Python
Setup a function to finally generate a trading strategy using real-time data
Python
Execute the trading strategy generator
Python

🌟 Highlights

This notebook has guided you through setting up and running a Langchain RAG workflow with Dappier for a generating Real-Time Market Analysis & Trading Strategy. You can adapt and expand this example for various other scenarios requiring advanced web information retrieval and AI collaboration. Key tools utilized in this notebook include:
  • LangChain: A versatile framework for chaining together language models and other components to create sophisticated AI-driven workflows. It enables seamless integration of LLMs with external tools and data sources, making it ideal for tasks like summarization, question-answering, and more.
  • Dappier: A platform connecting LLMs and Agentic AI agents to real-time, rights-cleared data from trusted sources, specializing in domains like web search, finance, and news. It delivers enriched, prompt-ready data, empowering AI with verified and up-to-date information for diverse applications.
  • OpenAI: A leading provider of advanced AI models capable of natural language understanding, contextual reasoning, and content generation. It enables intelligent, human-like interactions and supports a wide range of applications across various domains.
  • LangSmith: A platform for debugging, testing, and monitoring LangChain applications. It provides detailed tracing and analytics to help you understand and optimize the performance of your AI workflows.
This comprehensive setup allows you to adapt and expand the example for various scenarios requiring advanced web information retrieval, AI collaboration, and multi-source data aggregation.