• bitcoinBitcoin(BTC)$81,425.000.53%
  • ethereumEthereum(ETH)$2,639.020.76%
  • tetherTether(USDT)$1.000.01%
  • binancecoinBNB(BNB)$763.81-0.20%
  • rippleXRP(XRP)$1.432.87%
  • usd-coinUSDC(USDC)$1.000.00%
  • solanaSolana(SOL)$111.21-1.20%
  • tronTRON(TRX)$0.3388650.19%
  • zcashZcash(ZEC)$1,474.050.76%
  • Figure HelocFigure Heloc(FIGR_HELOC)$1.00-2.79%
  • HyperliquidHyperliquid(HYPE)$92.451.33%
  • dogecoinDogecoin(DOGE)$0.0900012.78%
  • moneroMonero(XMR)$554.36-0.38%
  • RainRain(RAIN)$0.0139554.90%
  • whitebitWhiteBIT Coin(WBT)$83.10-0.12%
  • USDSUSDS(USDS)$1.00-0.02%
  • chainlinkChainlink(LINK)$12.572.61%
  • cardanoCardano(ADA)$0.2302853.87%
  • leo-tokenLEO Token(LEO)$8.920.35%
  • stellarStellar(XLM)$0.1985553.14%
  • uniswapUniswap(UNI)$8.66-2.35%
  • bitcoin-cashBitcoin Cash(BCH)$254.770.59%
  • Ethena USDeEthena USDe(USDE)$1.000.00%
  • nearNEAR Protocol(NEAR)$3.57-5.87%
  • daiDai(DAI)$1.000.00%
  • litecoinLitecoin(LTC)$57.631.31%
  • CantonCanton(CC)$0.1114681.27%
  • USD1USD1(USD1)$1.000.01%
  • avalanche-2Avalanche(AVAX)$9.7818.52%
  • the-open-networkGram (prev. Toncoin)(GRAM)$1.390.91%
  • hedera-hashgraphHedera(HBAR)$0.0820174.15%
  • suiSui(SUI)$0.877.80%
  • shiba-inuShiba Inu(SHIB)$0.0000062.57%
  • Global DollarGlobal Dollar(USDG)$1.000.00%
  • MemeCoreMemeCore(M)$1.427.19%
  • BittensorBittensor(TAO)$263.955.63%
  • crypto-com-chainCronos(CRO)$0.0597230.38%
  • paypal-usdPayPal USD(PYUSD)$1.00-0.01%
  • tether-goldTether Gold(XAUT)$4,373.88-0.14%
  • Circle USYCCircle USYC(USYC)$1.140.00%
  • okbOKB(OKB)$118.672.00%
  • Ripple USDRipple USD(RLUSD)$1.00-0.01%
  • BlackRock USD Institutional Digital Liquidity FundBlackRock USD Institutional Digital Liquidity Fund(BUIDL)$1.000.00%
  • Ondo US Dollar YieldOndo US Dollar Yield(USDY)$1.150.01%
  • aaveAave(AAVE)$142.302.92%
  • OndoOndo(ONDO)$0.4315318.46%
  • AsterAster(ASTER)$0.772.03%
  • mantleMantle(MNT)$0.631.24%
  • EthenaEthena(ENA)$0.20049420.57%
  • Pump.funPump.fun(PUMP)$0.004170-4.35%
TradePoint.io
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop
No Result
View All Result
TradePoint.io
No Result
View All Result

A Step-by-Step Coding Guide to Integrate Dappier AI’s Real-Time Search and Recommendation Tools with OpenAI’s Chat API

May 1, 2025
in AI & Technology
Reading Time: 6 mins read
A A
A Step-by-Step Coding Guide to Integrate Dappier AI’s Real-Time Search and Recommendation Tools with OpenAI’s Chat API
ShareShareShareShareShare

In this tutorial, we will learn how to harness the power of Dappier AI, a suite of real-time search and recommendation tools, to enhance our conversational applications. By combining Dappier’s cutting-edge RealTimeSearchTool with its AIRecommendationTool, we can query the latest information from across the web and surface personalized article suggestions from custom data models. We guide you step-by-step through setting up our Google Colab environment, installing dependencies, securely loading API keys, and initializing each Dappier module. We will then integrate these tools with an OpenAI chat model (e.g., gpt-3.5-turbo), construct a composable prompt chain, and execute end-to-end queries, all within nine concise notebook cells. Whether we need up-to-the-minute news retrieval or AI-driven content curation, this tutorial provides a flexible framework for building intelligent, data-driven chat experiences.

!pip install -qU langchain-dappier langchain langchain-openai langchain-community langchain-core openai

We bootstrap our Colab environment by installing the core LangChain libraries, both the Dappier extensions and the community integrations, alongside the official OpenAI client. With these packages in place, we will have seamless access to Dappier’s real-time search and recommendation tools, the latest LangChain runtimes, and the OpenAI API, all in one environment.

YOU MAY ALSO LIKE

Why Is Your iPad Not Charging (And How To Fix It)

How To Block And Unblock A Number On Your Android Phone

import os
from getpass import getpass


os.environ["DAPPIER_API_KEY"] = getpass("Enter our Dappier API key: ")


os.environ["OPENAI_API_KEY"] = getpass("Enter our OpenAI API key: ")

We securely capture our Dappier and OpenAI API credentials at runtime, thereby avoiding the hard-coding of sensitive keys in our notebook. By using getpass, the prompts ensure our inputs remain hidden, and setting them as environment variables makes them available to all subsequent cells without exposing them in logs.

from langchain_dappier import DappierRealTimeSearchTool


search_tool = DappierRealTimeSearchTool()
print("Real-time search tool ready:", search_tool)

We import Dappier’s real‐time search module and create an instance of the DappierRealTimeSearchTool, enabling our notebook to execute live web queries. The print statement confirms that the tool has been initialized successfully and is ready to handle search requests.

from langchain_dappier import DappierAIRecommendationTool


recommendation_tool = DappierAIRecommendationTool(
    data_model_id="dm_01j0pb465keqmatq9k83dthx34",
    similarity_top_k=3,
    ref="sportsnaut.com",
    num_articles_ref=2,
    search_algorithm="most_recent",
)
print("Recommendation tool ready:", recommendation_tool)

We set up Dappier’s AI-powered recommendation engine by specifying our custom data model, the number of similar articles to retrieve, and the source domain for context. The DappierAIRecommendationTool instance will now use the “most_recent” algorithm to pull in the top-k relevant articles (here, two) from our specified reference, ready for query-driven content suggestions.

from langchain.chat_models import init_chat_model


llm = init_chat_model(
    model="gpt-3.5-turbo",
    model_provider="openai",
    temperature=0,
)
llm_with_tools = llm.bind_tools([search_tool])
print("✅ llm_with_tools ready")

We create an OpenAI chat model instance using gpt-3.5-turbo with a temperature of 0 to ensure consistent responses, and then bind the previously initialized search tool so that the LLM can invoke real-time searches. The final print statement confirms that our LLM is ready to call Dappier’s tools within our conversational flows.

import datetime
from langchain_core.prompts import ChatPromptTemplate


today = datetime.datetime.today().strftime("%Y-%m-%d")
prompt = ChatPromptTemplate([
    ("system", f"we are a helpful assistant. Today is {today}."),
    ("human", "{user_input}"),
    ("placeholder", "{messages}"),
])


llm_chain = prompt | llm_with_tools
print("✅ llm_chain built")

We construct the conversational “chain” by first building a ChatPromptTemplate that injects the current date into a system prompt and defines slots for user input and prior messages. By piping the template (|) into our llm_with_tools, we create an llm_chain that automatically formats prompts, invokes the LLM (with real-time search capability), and handles responses in a seamless workflow. The final print confirms the chain is ready to drive end-to-end interactions.

from langchain_core.runnables import RunnableConfig, chain


@chain
def tool_chain(user_input: str, config: RunnableConfig):
    ai_msg = llm_chain.invoke({"user_input": user_input}, config=config)
    tool_msgs = search_tool.batch(ai_msg.tool_calls, config=config)
    return llm_chain.invoke(
        {"user_input": user_input, "messages": [ai_msg, *tool_msgs]},
        config=config
    )


print("✅ tool_chain defined")

We define an end-to-end tool_chain that first sends our prompt to the LLM (capturing any requested tool calls), then executes those calls via search_tool.batch, and finally feeds both the AI’s initial message and the tool outputs back into the LLM for a cohesive response. The @chain decorator transforms this into a single, runnable pipeline, allowing us to simply call tool_chain.invoke(…) to handle both thinking and searching in a single step.

res = search_tool.invoke({"query": "What happened at the last Wrestlemania"})
print("🔍 Search:", res)

We demonstrate a direct query to Dappier’s real-time search engine, asking “What happened at the last WrestleMania,” and immediately print the structured result. It shows how easily we can leverage search_tool.invoke to fetch up-to-the-moment information and inspect the raw response in our notebook.

rec = recommendation_tool.invoke({"query": "latest sports news"})
print("📄 Recommendation:", rec)


out = tool_chain.invoke("Who won the last Nobel Prize?")
print("🤖 Chain output:", out)

Finally, we showcase both our recommendation and full-chain workflows in action. First, it calls recommendation_tool.invoke with “latest sports news” to fetch relevant articles from our custom data model, then prints those suggestions. Next, it runs the tool_chain.invoke(“Who won the last Nobel Prize?”) to perform an end-to-end LLM query combined with real-time search, printing the AI’s synthesized answer, and integrating live data.

In conclusion, we now have a robust baseline for embedding Dappier AI capabilities into any conversational workflow. We’ve seen how effortlessly Dappier’s real-time search empowers our LLM to access fresh facts, while the recommendation tool enables us to deliver contextually relevant insights from proprietary data sources. From here, we can customize search parameters (e.g., refining query filters) or fine-tune recommendation settings (e.g., adjusting similarity thresholds and reference domains) to suit our domain.


Check out the Dappier Platform and Notebook here. Also, don’t forget to follow us on Twitter and join our Telegram Channel and LinkedIn Group. Don’t Forget to join our 90k+ ML SubReddit.

🔥 [Register Now] miniCON Virtual Conference on AGENTIC AI: FREE REGISTRATION + Certificate of Attendance + 4 Hour Short Event (May 21, 9 am- 1 pm PST) + Hands on Workshop


Nikhil is an intern consultant at Marktechpost. He is pursuing an integrated dual degree in Materials at the Indian Institute of Technology, Kharagpur. Nikhil is an AI/ML enthusiast who is always researching applications in fields like biomaterials and biomedical science. With a strong background in Material Science, he is exploring new advancements and creating opportunities to contribute.

Credit: Source link

ShareTweetSendSharePin

Related Posts

Why Is Your iPad Not Charging (And How To Fix It)
AI & Technology

Why Is Your iPad Not Charging (And How To Fix It)

September 19, 2026
How To Block And Unblock A Number On Your Android Phone
AI & Technology

How To Block And Unblock A Number On Your Android Phone

September 19, 2026
Google Gemini Also Escaped Its Testing Environment And Hacked Three Companies
AI & Technology

Google Gemini Also Escaped Its Testing Environment And Hacked Three Companies

September 19, 2026
What Is AI Agent Memory? Short-Term, Long-Term, Episodic, and Semantic Memory Explained – Unite.AI
AI & Technology

What Is AI Agent Memory? Short-Term, Long-Term, Episodic, and Semantic Memory Explained – Unite.AI

September 19, 2026
Next Post
If Trump keeps breaking the law, ‘we’ll see him in court,’ says California AG

If Trump keeps breaking the law, ‘we’ll see him in court,’ says California AG

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

No Result
View All Result
Rick Springfield opens up about killing a man in Vietnam while performing for troops in 1968

Rick Springfield opens up about killing a man in Vietnam while performing for troops in 1968

September 14, 2026
Crypto billionaire paid .5M to marry glamorous actress — now he wants it back after romance fizzled

Crypto billionaire paid $4.5M to marry glamorous actress — now he wants it back after romance fizzled

September 14, 2026
One Problem With Android Auto Can Be Fixed With A Simple Update

One Problem With Android Auto Can Be Fixed With A Simple Update

September 12, 2026

About

Learn more

Our Services

Legal

Privacy Policy

Terms of Use

Bloggers

Learn more

Article Links

Contact

Advertise

Ask us anything

©2020- TradePoint.io - All rights reserved!

Tradepoint.io, being just a publishing and technology platform, is not a registered broker-dealer or investment adviser. So we do not provide investment advice. Rather, brokerage services are provided to clients of Tradepoint.io by independent SEC-registered broker-dealers and members of FINRA/SIPC. Every form of investing carries some risk and past performance is not a guarantee of future results. “Tradepoint.io“, “Instant Investing” and “My Trading Tools” are registered trademarks of Apperbuild, LLC.

This website is operated by Apperbuild, LLC. We have no link to any brokerage firm and we do not provide investment advice. Every information and resource we provide is solely for the education of our readers. © 2020 Apperbuild, LLC. All rights reserved.

No Result
View All Result
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop

© 2023 - TradePoint.io - All Rights Reserved!