From 45679e49d07dc98e80a29f0fe09baf4f4f6bb37c Mon Sep 17 00:00:00 2001 From: Yogananda Muthaiah Date: Sun, 1 Dec 2024 09:49:49 +0100 Subject: [PATCH] Update chapter8.md --- chapter8.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/chapter8.md b/chapter8.md index 216a7c5..12c2d63 100644 --- a/chapter8.md +++ b/chapter8.md @@ -1 +1,27 @@ -chapter4.md \ No newline at end of file +## Chapter 8: Integration with external APIs +By using LangChain to integrate with external APIs, you can build AI applications that leverage richer sources of information. + +``` +from langchain.utilities import OpenWeatherMapAPIWrapper +from langchain.agents import initialize_agent, Tool +from langchain.llms import OpenAI + +# OpenWeatherMap API +weather = OpenWeatherMapAPIWrapper() + + +tools = [ + Tool( + name="Weather", + func=weather.run, + description="useful for when you need to answer questions about the weather" + ) +] + + +agent = initialize_agent(tools, OpenAI(temperature=0), agent="zero-shot-react-description", verbose=True) + + +agent.run("What's the weather like in Munich right now?") + +```