import os
import requests
from planck_helpers import PlanckManualLogger
with PlanckManualLogger(
api_key=os.environ["PLANCK_API_KEY"],
raise_on_error=True,
) as logger:
def call_weather(recorder):
response = requests.get(
"https://weather.example/current",
params={"location": "Bogotá, Colombia"},
timeout=10,
)
response.raise_for_status()
body = response.json()
recorder.append_results(body)
return body
result = logger.log_request(
request={
"_type": "tool",
"toolName": "weather_api",
"input": {"location": "Bogotá, Colombia"},
},
operation=call_weather,
additional_headers={
"Planck-Session-Id": "user-123",
"Planck-Property-Environment": "production",
},
provider="custom",
)