Langchain
We're excited to partner with Langchain as their recommended search tool! 🚀 See the Langchain blog for more details.
Tavily API can now empower your Langchain application with real time online information optimized for RAG.
How to use Tavily API with Langchain​
import os
from langchain_community.utilities.tavily_search import TavilySearchAPIWrapper
from langchain.agents.agent_toolkits import create_conversational_retrieval_agent
from langchain_openai import ChatOpenAI
from langchain_community.tools.tavily_search.tool import TavilySearchResults
# set up API key
os.environ["TAVILY_API_KEY"] = "..."
os.environ["OPENAI_API_KEY"] = "..."
# set up the agent
llm = ChatOpenAI(model_name="gpt-4", temperature=0.7)
search = TavilySearchAPIWrapper()
tavily_tool = TavilySearchResults(api_wrapper=search)
# initialize the agent
agent = create_conversational_retrieval_agent(
llm,
tools=[tavily_tool],
verbose=True,
)
# run the agent
agent.invoke("What happened in the latest burning man floods?")
Result:​
> Entering new AgentExecutor chain...
Invoking: `tavily_search_results_json` with `{'query': 'latest burning man floods news'}`
[{'url': 'https://www.cbsnews.com/news/flooding-burning-man-shelter-in-place/', 'content': 'Watch CBS News\nNevada flooding forces Burning Man attendees to shelter in place\nUpdated on:\nSeptember 2, 2023 / 10:04 PM EDT\n/ CBS/AP\nThousands of Burning Man attendees trudged in sloppy mud on Saturday — many barefoot or wearing plastic bags on their feet — as flooding from storms swept through the Nevada desert, forcing organizers to close vehicular access to the counterculture festival. Vehicular gates will be closed for the remainder of the event, which began on Aug. 27 and was scheduled to end on Monday, according to the U.S. Bureau of Land Management, which oversees the Black Rock Desert where the festival is being held. "\nDue to recent rainfall, the Bureau of Land Management and the Pershing County Sheriff\'s Office officials have closed the entrance to Burning Man for the remainder of the event. Superstar DJ and music producer Diplo shared a video to social media Saturday afternoon that showed several people riding on the back of a truck leaving the festival, one of whom appeared to be comedian Chris Rock.\n Mike Jed, a festivalgoer, and fellow campers made a bucket toilet so people didn\'t have to trudge as often through the mud to reach the portable toilets.\n'}, {'url': 'https://www.npr.org/2023/09/03/1197497458/the-latest-on-the-burning-man-flooding', 'content': "There are also reports that at least one person has died at the counterculture festival about a hundred miles north of Reno, Nev. Earlier this afternoon, I caught up with NPR's Claudia Peschiutta, who's at her first burn, and she told me it's muddy where she is, but that she and her camp family have been making the best of things.\n National\nThe latest on the Burning Man flooding\nClaudia Peschiutta\nAuthorities are investigating a death at the Burning Man festival in the Nevada desert after tens of thousands of people are stuck in camps because of rain.\n SCOTT DETROW, HOST:\nKnee-deep mud, warnings to conserve food and water, orders to shelter in place - this is all at Burning Man 2023 after torrential rains turned the Black Rock Desert into miles and miles of mud. I mean, mostly what I've seen from my personal experience is just any sort of need that you have, somebody, whether friend or neighbor or stranger, will jump in to help you out in some way. And I should mention that desert Wi-Fi is doing the best as it can as we talk to you, dropping in and out."}, {'url': 'https://www.nbcnews.com/news/us-news/live-blog/live-updates-burning-man-flooding-keeps-thousands-stranded-nevada-site-rcna103193', 'content': "Profile\nSections\ntv\nFeatured\nMore From NBC\nFollow NBC News\nnews Alerts\nThere are no new alerts at this time\nBurning Man flooding keeps thousands stranded at Nevada site as authorities investigate 1 death\nBurning Man attendees struggling to get home\n70,000+ stuck at Burning Man: When will they be able to get out?\n Thousands still stranded at Burning Man after torrential rain\nBurning Man revelers unfazed by deluge and deep mud\nReuters\nThousands of Burning Man attendees partied hard on Sunday despite downpours that turned the Nevada desert where the annual arts and music festival takes place into a sea of sticky mud and led officials to order the multitudes to shelter in place.\n Neal Katyal warns hiking in the mud\ncan be 'worse than walking on ice'\nDoha Madani\nNeal Katyal, the former acting U.S. solicitor general, is among the Burning Man attendees who decided to take the risk and hike out of the festival grounds.\n Videos posted to his Instagram story show Diplo walking through mud before, he says, he hitchhiked to Gerlach and Reno to make a flight to Washington, D.C.\n“I just got done DJ’ing for three hours, after walking f---ing for four hours out of the desert and taking a flight, mud still on my face,” he said in a video posted to his Instagram story last night.\n Burning Man memes are swamping social media\nAngela Yang\nAs heavy rain turns Burning Man 2023 into a muddy mess, a deluge of unsympathetic jokes has swamped the internet outside Black Rock City, the temporary location built annually for the nine-day festival in the remote desert of Nevada.\n"}, {'url': 'https://www.cnn.com/us/live-news/nevada-desert-burning-man-weather-rain-09-03-23/index.html', 'content': 'The festival’s 2023 theme is “Animalia,” which the Burning Man website explains, “will celebrate the animal world and our place in it — animals real and imagined, mythic and remembered — and explore the curious mental constructs that allow us to believe that imagined animals are real, real animals are imagined, and that somehow, despite all evidence to the contrary, mankind is somehow not part of the animal kingdom.”\n Thousands stranded at Burning Man festival after heavy rains\nBy Maureen Chowdhury, Steve Almasy and Matt Meyer, CNN\nWhat we\'re covering\nPresident Biden has been briefed on the situation at Burning Man festival\nFrom CNN\'s Betsy Klein\nPresident Joe Biden was briefed Sunday on the situation at the Burning Man festival in Black Rock Desert, Nevada, according to a White House official.\n View Katyal\'s post below:\nSome of the 70,000 people stranded at Burning Man are walking out of the site, sheriff\'s office says\nFrom CNN\'s Melissa Alonso\nThere are currently "a little over 70,000" people stranded at the Burning Man festival in Nevada due to the mud and flooding, Pershing County Sheriff’s Sgt. Burning Man organizers working to provide cell service and medical resources as attendees shelter in place\nFrom CNN\'s Nouran Salahieh\xa0and\xa0Emma Tucker\nBurning Man organizers say they are placing mobile cell trailers around the battered festival grounds, configuring their Wi-Fi system for public access, and sending buses to nearby Gerlach, Nevada, to pick up people who might have walked out of the desert and ferry them to Reno.\n Festivalgoers are managing to have a good time despite being stuck in the mud, attendee says\nDawne Looney, a Burning Man festival attendee, says people are making the best of the situation despite the heavy rain and mud stranding an estimated 70,000 of them in the desert.\n'}, {'url': 'https://abcnews.go.com/US/burning-man-flooding-happened-stranded-festivalgoers/story?id=102908331', 'content': '"\nTop Stories\nMacy\'s Thanksgiving Day Parade temporarily halted by pro-Palestinian protesters\nGuns N\' Roses singer Axl Rose accused of alleged 1989 sexual assault by former model\nFBI: Rainbow Bridge crash, explosion not connected to terrorism\nToxic chemical spill from Kentucky train derailment forces residents to flee homes\nHezbollah fires rockets at north Israel after an airstrike kills 5 of the group\'s senior fighters\nABC News Live\n24/7 coverage of breaking news and live events ABC News\nVideo\nLive\nShows\nElection 2024\n538\nStream on\nBurning Man flooding: What happened to stranded festivalgoers?\n In response to the unusual weather, event organizers shut down traffic in or out of what is called Black Rock City -- where the festival is held in the desert -- including the local airport.\n MORE: These US regions will experience scorching temperatures for the remainder of Labor Day weekend\nOn Sunday, mobile cell trailers to boost cell service and charging stations were placed around the festival grounds amid the recovery efforts, according to organizers.\n This is typically the driest time of the year for the desert, and it does not take much rain to make the desert floor a mud bath.\n'}]The latest Burning Man festival, held in Nevada's Black Rock Desert, was hit by severe flooding due to storms, forcing thousands of attendees to shelter in place as the normally dry desert was turned into a muddy landscape. The vehicular gates were closed for the remainder of the event, a decision taken by the U.S. Bureau of Land Management and the Pershing County Sheriff's Office. There were reports of one death at the festival and authorities are investigating the incident. Despite the harsh conditions, festival attendees were seen making the best of the situation.
The festival, which began on August 27, 2023, and was supposed to end on September 4, 2023, saw over 70,000 attendees stuck due to the flooding. To aid attendees, festival organizers provided mobile cell trailers to boost cell service and charging stations around the festival grounds. They also worked on providing medical resources and public Wi-Fi access.
Notably, many attendees, including celebrities like DJ Diplo, were seen leaving the festival by hitchhiking or walking through the mud. The floods led to a flurry of social media activity, including both messages of support and unsympathetic jokes. The President, Joe Biden, was also briefed on the situation at the festival.
> Finished chain.