aa-agent-tools 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aa_agent_tools-0.1.0/PKG-INFO +434 -0
- aa_agent_tools-0.1.0/README.md +418 -0
- aa_agent_tools-0.1.0/pyproject.toml +37 -0
- aa_agent_tools-0.1.0/src/aa_agent_tools/__init__.py +125 -0
- aa_agent_tools-0.1.0/src/aa_agent_tools/_http.py +88 -0
- aa_agent_tools-0.1.0/src/aa_agent_tools/_util.py +34 -0
- aa_agent_tools-0.1.0/src/aa_agent_tools/apis.py +60 -0
- aa_agent_tools-0.1.0/src/aa_agent_tools/data.py +163 -0
- aa_agent_tools-0.1.0/src/aa_agent_tools/email_tools.py +100 -0
- aa_agent_tools-0.1.0/src/aa_agent_tools/errors.py +36 -0
- aa_agent_tools-0.1.0/src/aa_agent_tools/fun.py +111 -0
- aa_agent_tools-0.1.0/src/aa_agent_tools/images.py +27 -0
- aa_agent_tools-0.1.0/src/aa_agent_tools/py.typed +0 -0
- aa_agent_tools-0.1.0/src/aa_agent_tools/space.py +55 -0
- aa_agent_tools-0.1.0/src/aa_agent_tools/text_tools.py +83 -0
- aa_agent_tools-0.1.0/src/aa_agent_tools/weather.py +68 -0
- aa_agent_tools-0.1.0/src/aa_agent_tools/web.py +92 -0
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: aa-agent-tools
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: aa_agent_tools - a friendly, Pyodide-ready toolbox of cool functions for kid-built agents (web search, fetch pages, email, AI, weather, and tons of fun stuff).
|
|
5
|
+
Author: obaodelana
|
|
6
|
+
Author-email: obaodelana <obaloluwa.dev@gmail.com>
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Intended Audience :: Education
|
|
10
|
+
Classifier: Topic :: Education
|
|
11
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Project-URL: Homepage, https://github.com/obaodelana/aa_agent_tools
|
|
14
|
+
Project-URL: Documentation, https://github.com/obaodelana/aa_agent_tools
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# 🛠️ aa_agent_tools
|
|
18
|
+
|
|
19
|
+
**A friendly toolbox of cool functions for kid-built agents.**
|
|
20
|
+
|
|
21
|
+
`aa_agent_tools` gives your Python agents super-powers: search the web, read pages,
|
|
22
|
+
send emails, check the weather, grab space pictures from NASA, roll dice, fetch
|
|
23
|
+
cat facts, and a whole lot more — **38 functions**, all listed below with
|
|
24
|
+
copy-paste examples.
|
|
25
|
+
|
|
26
|
+
> 🔑 **You bring the API keys.** We never store them. Just pass them as
|
|
27
|
+
> arguments when you call a function. Look for the 🔑 badge below (those need a
|
|
28
|
+
> key) and the 🆓 badge (those are totally free, no key at all!).
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 🎉 Quick start
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
import aa_agent_tools as aa
|
|
36
|
+
|
|
37
|
+
# No key needed — just fun!
|
|
38
|
+
print(aa.get_joke())
|
|
39
|
+
print(aa.get_cat_fact())
|
|
40
|
+
print(aa.get_pokemon("pikachu")["types"])
|
|
41
|
+
print(aa.flip_coin())
|
|
42
|
+
print(aa.number_fact(7))
|
|
43
|
+
|
|
44
|
+
# With a key you supply
|
|
45
|
+
results = aa.search_web("cute penguins", api_key="YOUR_BRAVE_KEY")
|
|
46
|
+
print(results)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Want the pretty, searchable version? Open the
|
|
50
|
+
**[📖 HTML Reference Page](docs/reference.html)** in your browser.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## 📖 The full function reference
|
|
55
|
+
|
|
56
|
+
Every function is listed below, grouped by what it does. Each one shows a
|
|
57
|
+
short, friendly description and a copy-paste example you can try right away.
|
|
58
|
+
|
|
59
|
+
- 🔑 = needs an API key (you pass it as an argument)
|
|
60
|
+
- 🆓 = totally free, no key needed
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
### 🌐 Web & Search
|
|
65
|
+
|
|
66
|
+
#### `search_web(query, api_key)` 🔑
|
|
67
|
+
Search the internet with Brave and get back a tidy list of results (title,
|
|
68
|
+
link, snippet).
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
results = aa.search_web("best robots for kids", api_key="YOUR_BRAVE_KEY")
|
|
72
|
+
print(results)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
#### `search_images(query, api_key, count=5)` 🔑
|
|
76
|
+
Search for pictures on the web using Brave Search.
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
pics = aa.search_images("puppies", api_key="YOUR_BRAVE_KEY")
|
|
80
|
+
print(pics[0]["url"])
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
#### `fetch_page(url)` 🆓
|
|
84
|
+
Download any web page and turn it into clean text (Markdown). Great for reading
|
|
85
|
+
articles.
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
text = aa.fetch_page("https://en.wikipedia.org/wiki/Penguin")
|
|
89
|
+
print(text[:300])
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
### ✉️ Email
|
|
95
|
+
|
|
96
|
+
#### `send_email(to, subject, body, *, smtp_host, username, password)` 🔑
|
|
97
|
+
Send a plain-text email through almost any email provider's SMTP server.
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
aa.send_email(
|
|
101
|
+
to="friend@example.com",
|
|
102
|
+
subject="Hello from my agent!",
|
|
103
|
+
body="My robot wrote this.",
|
|
104
|
+
smtp_host="smtp.gmail.com",
|
|
105
|
+
username="you@gmail.com",
|
|
106
|
+
password="app-password",
|
|
107
|
+
)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### `send_email_gmail(to, subject, body, *, gmail, app_password)` 🔑
|
|
111
|
+
Send an email using a Gmail account (use a 16-character app password).
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
aa.send_email_gmail(
|
|
115
|
+
to="friend@example.com",
|
|
116
|
+
subject="hi!",
|
|
117
|
+
body="sent from aa_agent_tools",
|
|
118
|
+
gmail="you@gmail.com",
|
|
119
|
+
app_password="abcd efgh ijkl mnop",
|
|
120
|
+
)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
### 🤖 Any API
|
|
126
|
+
|
|
127
|
+
#### `call_api(url, api_key=None, *, method="GET", ...)` 🆓
|
|
128
|
+
Call almost **any** REST API in one line. You give it a URL and (if the API
|
|
129
|
+
needs one) a key. No key needed for public APIs.
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
city = input("Enter your city: ")
|
|
133
|
+
data = aa.call_api(
|
|
134
|
+
"https://api.weatherapi.com/v1/current.json?key=key&q={city}&aqi=no"
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
current = data["current"]
|
|
138
|
+
|
|
139
|
+
print(current["temp_c"])
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
### 🌤️ Weather
|
|
145
|
+
|
|
146
|
+
#### `get_weather(city, api_key)` 🔑
|
|
147
|
+
Get the current weather for any city in the world (OpenWeatherMap).
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
w = aa.get_weather("London", api_key="YOUR_OWM_KEY")
|
|
151
|
+
print(f"{w['temp']}°C and {w['description']}")
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
#### `get_forecast(city, api_key, days=3)` 🔑
|
|
155
|
+
Get a short multi-day forecast for a city (OpenWeatherMap).
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
fc = aa.get_forecast("Tokyo", api_key="YOUR_OWM_KEY", days=3)
|
|
159
|
+
print(fc)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
### 🚀 Space
|
|
165
|
+
|
|
166
|
+
#### `space_image(date=None, api_key="DEMO_KEY")` 🆓
|
|
167
|
+
Get NASA's Astronomy Picture of the Day (`"DEMO_KEY"` works for light use).
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
pic = aa.space_image()
|
|
171
|
+
print(pic["title"], pic["url"])
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
#### `near_earth_objects(api_key="DEMO_KEY", *, start_date=None, end_date=None)` 🆓
|
|
175
|
+
List asteroids flying near Earth in a date range (NASA NeoWs).
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
aa.near_earth_objects(api_key="DEMO_KEY", start_date="2024-01-01", end_date="2024-01-07")
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
#### `mars_photo(*, sol=1000, api_key="DEMO_KEY")` 🆓
|
|
182
|
+
Fetch a real photo taken by a rover on Mars (NASA).
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
print(aa.mars_photo(sol=1000, api_key="DEMO_KEY"))
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
### 🎉 Fun & Games
|
|
191
|
+
|
|
192
|
+
#### `get_joke()` 🆓
|
|
193
|
+
Get a random, clean joke with a setup and punchline.
|
|
194
|
+
|
|
195
|
+
```python
|
|
196
|
+
j = aa.get_joke()
|
|
197
|
+
print(j["setup"]); print(j["punchline"])
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
#### `get_advice()` 🆓
|
|
201
|
+
Get a random piece of (silly but wise) advice.
|
|
202
|
+
|
|
203
|
+
```python
|
|
204
|
+
print(aa.get_advice())
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
#### `get_cat_fact()` 🆓
|
|
208
|
+
Get a random fact about cats.
|
|
209
|
+
|
|
210
|
+
```python
|
|
211
|
+
print(aa.get_cat_fact())
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
#### `get_cat_image()` 🆓
|
|
215
|
+
Get a link to a random photo of a cat.
|
|
216
|
+
|
|
217
|
+
```python
|
|
218
|
+
print(aa.get_cat_image())
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
#### `get_dog_image()` 🆓
|
|
222
|
+
Get a random photo of a good dog.
|
|
223
|
+
|
|
224
|
+
```python
|
|
225
|
+
print(aa.get_dog_image())
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
#### `get_quote()` 🆓
|
|
229
|
+
Get an inspirational quote and who said it.
|
|
230
|
+
|
|
231
|
+
```python
|
|
232
|
+
q = aa.get_quote()
|
|
233
|
+
print(f'"{q["text"]}" - {q["author"]}')
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
#### `roll_dice(sides=6)` 🆓
|
|
237
|
+
Roll a die with any number of sides (default 6).
|
|
238
|
+
|
|
239
|
+
```python
|
|
240
|
+
print(aa.roll_dice(20))
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
#### `flip_coin()` 🆓
|
|
244
|
+
Flip a coin: returns `"heads"` or `"tails"`.
|
|
245
|
+
|
|
246
|
+
```python
|
|
247
|
+
print(aa.flip_coin())
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
#### `random_number(min_value=1, max_value=100)` 🆓
|
|
251
|
+
Pick a random whole number between two values.
|
|
252
|
+
|
|
253
|
+
```python
|
|
254
|
+
print(aa.random_number(1, 100))
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
#### `pick_one(*items)` 🆓
|
|
258
|
+
Randomly pick one item from the ones you list.
|
|
259
|
+
|
|
260
|
+
```python
|
|
261
|
+
print(aa.pick_one("red", "green", "blue"))
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
#### `get_pokemon(name="pikachu")` 🆓
|
|
265
|
+
Look up a Pokémon by name: its type, height, and a picture.
|
|
266
|
+
|
|
267
|
+
```python
|
|
268
|
+
p = aa.get_pokemon("charizard")
|
|
269
|
+
print(p["name"], p["types"])
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
### 📚 Knowledge
|
|
275
|
+
|
|
276
|
+
#### `wikipedia_summary(title)` 🆓
|
|
277
|
+
Get a short, friendly summary of almost any Wikipedia topic.
|
|
278
|
+
|
|
279
|
+
```python
|
|
280
|
+
info = aa.wikipedia_summary("Aurora")
|
|
281
|
+
print(info["summary"])
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
#### `define_word(word)` 🆓
|
|
285
|
+
Get the dictionary definition and an example sentence for a word.
|
|
286
|
+
|
|
287
|
+
```python
|
|
288
|
+
d = aa.define_word("serendipity")
|
|
289
|
+
print(d["definitions"][0])
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
#### `number_fact(number)` 🆓
|
|
293
|
+
Get a fun, fact-packed description of any number (works offline!).
|
|
294
|
+
|
|
295
|
+
```python
|
|
296
|
+
print(aa.number_fact(7))
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
#### `country_info(name)` 🆓
|
|
300
|
+
Get a friendly snapshot of a country using Wikipedia.
|
|
301
|
+
|
|
302
|
+
```python
|
|
303
|
+
c = aa.country_info("Japan")
|
|
304
|
+
print(c["summary"][:80])
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
#### `convert_money(amount, from_currency, to_currency)` 🆓
|
|
308
|
+
Convert money between currencies using live rates (no key needed).
|
|
309
|
+
|
|
310
|
+
```python
|
|
311
|
+
print(aa.convert_money(10, "USD", "EUR"))
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
#### `shorten_url(url)` 🆓
|
|
315
|
+
Make a long URL short using the free is.gd service.
|
|
316
|
+
|
|
317
|
+
```python
|
|
318
|
+
print(aa.shorten_url("https://example.com/very/long/path"))
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
### 🖼️ Images
|
|
324
|
+
|
|
325
|
+
#### `get_photo(query, api_key)` 🔑
|
|
326
|
+
Search free stock photos on Pexels and get image links.
|
|
327
|
+
|
|
328
|
+
```python
|
|
329
|
+
for url in aa.get_photo("mountains", api_key="YOUR_PEXELS_KEY"):
|
|
330
|
+
print(url)
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
#### `random_image(*, width=400, height=300, seed=None)` 🆓
|
|
334
|
+
Get a random photo of any size (no key needed).
|
|
335
|
+
|
|
336
|
+
```python
|
|
337
|
+
print(aa.random_image(width=600, height=400, seed="sunset"))
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
### 🧰 Text Tools
|
|
343
|
+
|
|
344
|
+
#### `hash_text(text, *, algorithm="sha256")` 🆓
|
|
345
|
+
Turn text into a fixed "fingerprint" hash (sha256 by default).
|
|
346
|
+
|
|
347
|
+
```python
|
|
348
|
+
print(aa.hash_text("hello"))
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
#### `base64_encode(text)` 🆓
|
|
352
|
+
Encode text into Base64 (a common way to pack data).
|
|
353
|
+
|
|
354
|
+
```python
|
|
355
|
+
print(aa.base64_encode("hi"))
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
#### `base64_decode(text)` 🆓
|
|
359
|
+
Decode Base64 text back to normal text.
|
|
360
|
+
|
|
361
|
+
```python
|
|
362
|
+
print(aa.base64_decode("aGk="))
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
#### `make_qr(text, *, size=200)` 🆓
|
|
366
|
+
Make a QR code image for text or a link (returns a URL).
|
|
367
|
+
|
|
368
|
+
```python
|
|
369
|
+
print(aa.make_qr("https://example.com"))
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
#### `convert_units(value, from_unit, to_unit)` 🆓
|
|
373
|
+
Convert between length or weight units.
|
|
374
|
+
|
|
375
|
+
```python
|
|
376
|
+
print(aa.convert_units(1, "mi", "km")) # ~1.609
|
|
377
|
+
print(aa.convert_units(1, "kg", "lb")) # ~2.205
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
#### `count_words(text)` 🆓
|
|
381
|
+
Count how many words are in some text.
|
|
382
|
+
|
|
383
|
+
```python
|
|
384
|
+
print(aa.count_words("one two three"))
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
#### `reverse_text(text)` 🆓
|
|
388
|
+
Reverse a string backwards.
|
|
389
|
+
|
|
390
|
+
```python
|
|
391
|
+
print(aa.reverse_text("abc")) # cba
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
#### `is_palindrome(text)` 🆓
|
|
395
|
+
Is the text the same forwards and backwards?
|
|
396
|
+
|
|
397
|
+
```python
|
|
398
|
+
print(aa.is_palindrome("Racecar")) # True
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
## 🔑 Where to get API keys
|
|
404
|
+
|
|
405
|
+
Most "cool" functions need a free key from the service. You only need the ones
|
|
406
|
+
you want to use:
|
|
407
|
+
|
|
408
|
+
- **Brave Search** (web & image search): https://brave.com/search/api/
|
|
409
|
+
- **OpenWeatherMap** (weather): https://openweathermap.org/api
|
|
410
|
+
- **NASA** (space): https://api.nasa.gov/ — use `"DEMO_KEY"` for light use
|
|
411
|
+
- **Pexels** (stock photos): https://www.pexels.com/api/
|
|
412
|
+
- **Gmail** (email): create an *app password* at https://myaccount.google.com/apppasswords
|
|
413
|
+
|
|
414
|
+
Functions that need **no key at all**: `get_joke`, `get_advice`, `get_cat_fact`,
|
|
415
|
+
`get_cat_image`, `get_dog_image`, `get_quote`, `roll_dice`, `flip_coin`,
|
|
416
|
+
`random_number`, `pick_one`, `get_pokemon`, `wikipedia_summary`, `define_word`,
|
|
417
|
+
`number_fact`, `country_info`, `convert_money`, `shorten_url`, `random_image`,
|
|
418
|
+
`fetch_page`, `call_api` (key optional), and all the **Text Tools**.
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
|
|
422
|
+
## 🛠️ Development
|
|
423
|
+
|
|
424
|
+
```bash
|
|
425
|
+
uv build # build wheel + sdist
|
|
426
|
+
PYTHONPATH=src python make_reference.py # regenerate docs/reference.html
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
The build produces a pure-Python wheel tagged `py3-none-any`, which is exactly
|
|
430
|
+
what `micropip` needs inside Pyodide.
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
Made with 💛 for young coders and the agents they build.
|