天气
OpenWeatherMap 是一个开源的气象服务提供商
此加载器使用pyowm Python包从OpenWeatherMap的OneCall API获取天气数据。您必须使用您的OpenWeatherMap API令牌和您想要获取天气数据的城市名称来初始化加载器。
from langchain_community.document_loaders import WeatherDataLoader
API Reference: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