天气
OpenWeatherMap 是一款开源天气服务提供商
此加载器使用 pyowm Python 包从 OpenWeatherMap 的 OneCall API 获取天气数据。您必须使用您的 OpenWeatherMap API 令牌和您想要获取天气数据的城市的名称来初始化加载器。
from langchain_community.document_loaders import WeatherDataLoader
API 参考:WeatherDataLoader
%pip install --upgrade --quiet pyowm
# Set API key either by passing it in to constructor directly
# or by setting the environment variable "OPENWEATHERMAP_API_KEY".
from getpass import getpass
OPENWEATHERMAP_API_KEY = getpass()
loader = WeatherDataLoader.from_params(
["chennai", "vellore"], openweathermap_api_key=OPENWEATHERMAP_API_KEY
)
documents = loader.load()
documents