Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix user agent string in example weather tool #22

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

csquared
Copy link

Hi team! Cool project! I wanted to get started making my own tools and figured I'd start with running the weather tool example. However, I ran into an issue this is easily fixed by this PR. I also included an example of running the tool in the README because I was trying to run it from the use_tool_package directly and getting import errors.

I had to throw in a print statement to get the following message:

❯ python -m tool_use_package.weather_tool_example
<html>
<head>
<title>Access blocked</title>
</head>
<body>
<h1>Access blocked</h1>

<p>You have been blocked because you have violated the
<a href="https://operations.osmfoundation.org/policies/nominatim/">usage policy</a>
of OSM's Nominatim geocoding service. Please be aware that OSM's resources are
limited and shared between many users. The usage policy is there to ensure that
the service remains usable for everybody.</p>

<p>Please review the terms and make sure that your
software adheres to the terms. You should in particular verify that you have set a
<b>custom HTTP referrer or HTTP user agent</b> that identifies your application, and
that you are not overusing the service with massive bulk requests.</p>

<p>If you feel that this block is unjustified or remains after you have adopted
your usage, you may contact the Nominatim system administrator at
nominatim@openstreetmap.org to have this block lifted.</p>
</body>
</head>

It appears the default "User-Agent" from the python requests library has been blocked on this API.
Setting a custom User-Agent header solved it.

With this small change, the weather tool now runs as expected:

❯ python -m tool_use_package.weather_tool_example

Based on the weather data, the current temperature in San Francisco is 10.8°C (51.4°F). It's a bit chilly and breezy, with winds around 8 km/h (5 mph) coming from the west. The weathercode of 3 indicates overcast skies.

Given those weather conditions, here are my recommendations for what to wear today in San Francisco:

- A warm jacket or coat, since the temperature is on the cool side. A light to medium weight jacket should be sufficient.

- Long pants rather than shorts, to keep your legs warm in the chilly air. Jeans or other casual pants are a good choice.

- A light sweater or long-sleeve shirt to layer underneath your jacket for added warmth.

- Closed-toed shoes like sneakers or casual shoes. You probably don't need boots since no rain is indicated.

- A light scarf could be good to protect against the breeze, especially if you'll be outside for extended periods.

- Sunglasses are optional since it's overcast, but it does look like it will be daytime (is_day: 1).

So in summary - dress in layers with a jacket, long pants, closed shoes and consider a light scarf for the wind. The key is to stay warm in the cool, breezy weather while still being comfortable as you go about your day in San Francisco. Let me know if you need any other suggestions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant