Skip to main content

llama-index tools weather, climate, air quality and geocoding integration

Project description

Measure Space Weather, Climate, Air Quality and Geocoding Tool

pip install llama-index-tools-measurespace

This tool connects to the MeasureSpace's API, using the measure-space-api Python package. You must initialize the tool with corresponding API keys from MeasureSpace and OpenAI (if you use OpenAI).

The tool has access to the following functions:

  • hourly weather forecast (next 5 days)
  • daily weather forecast (next 15 days)
  • daily climate forecast (next 10 months)
  • daily air quality forecast (next 5 days)
  • get latitude and longitude from given city names
  • get nearest city for given latitude and longitude

Usage

Assume you have an .env file with the following content:

GEOCODING_API_KEY=<your-geocoding-api-key>
HOURLY_WEATHER_API_KEY=<your-hourly-weather-api-key>
DAILY_WEATHER_API_KEY=R<your-daily-weather-api-key>
DAILY_CLIMATE_API_KEY=<your-daily-climate-api-key>
AIR_QUALITY_API_KEY=<your-air-quality-api-key>
OPENAI_API_KEY=<your-openai-api-key>

Note that you only need the API keys if you need the services.

from llama_index.tools.measurespace import MeasureSpaceToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
from dotenv import load_dotenv
import os

load_dotenv()

api_keys = {
    "hourly_weather": os.getenv("HOURLY_WEATHER_API_KEY"),
    "daily_weather": os.getenv("DAILY_WEATHER_API_KEY"),
    "daily_climate": os.getenv("DAILY_CLIMATE_API_KEY"),
    "air_quality": os.getenv("AIR_QUALITY_API_KEY"),
    "geocoding": os.getenv("GEOCODING_API_KEY"),
}

tool_spec = MeasureSpaceToolSpec(api_keys)
agent = FunctionAgent(
    tools=tool_spec.to_tool_list(),
    llm=OpenAI(model="gpt-4.1"),
)

print(await agent.run("How's the temperature for New York in next 3 days?"))
print(await agent.run("What's the latitude and longitude of New York?"))

# get a list of tools
for tool in tool_spec.to_tool_list():
    print(tool.metadata.name)

# Use a specific tool
tool_spec.get_daily_weather_forecast("New York")
tool_spec.get_latitude_longitude_from_location("New York")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_tools_measurespace-0.2.1.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file llama_index_tools_measurespace-0.2.1.tar.gz.

File metadata

File hashes

Hashes for llama_index_tools_measurespace-0.2.1.tar.gz
Algorithm Hash digest
SHA256 5cd46054b60eba8bac2de079d4c910e68d98d8b24a1b8e96e22088050acb5de7
MD5 72fd4e37c0d8d10d707df34ac7e212f4
BLAKE2b-256 c5ad1bdef86dbefb4678e88a5158d31e7100c9a9dd9ad18388d77035ec19e4b0

See more details on using hashes here.

File details

Details for the file llama_index_tools_measurespace-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_tools_measurespace-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 358ab9a2be3fce4e1313b63afd9785d5a53dc43cf1bab62f4701868a95a98fb9
MD5 dc89091317cb3f1bd5e1aae3f6c35669
BLAKE2b-256 cc2fd7794b4e05d8feb75d1ef0907171bb4963d3076eb7acb143fe20c2f2d373

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page