AI doesn't need to transform every aspect of our software to be transformative.
Here's a real-life anecdote: for a personal mini project, a little scheduled script that reads information from one of my calendars and does some useful administrative stuff with it, I had the need to read, parse, and process an iCal .ics file. Turns out these files are strange beasts that handle timezone information in a baroque fashion - the file can include timezone declarations, each with an arbitrary name and a set of rules to determine how the timezone behaves, including DST switches. Events in the rest of the file can then refer back to these timezones. In a calendar with many event invites from different people whose calendar is in different timezones, you can end up with a long list of timezones, each with their own peculiar name. It is then the responsibility of the library or program to reconcile all of that and make available to the user a unified view in one timezone. Outlook and Apple handle this well. Many libraries and tools (including Google Calendar and all Python libraries I tested) don't. Instead, they work better with the usual standardised timezone identifiers you can find in a lot of modern software (like "Europe/Paris").
After spending almost two hours debugging it became clear that with no usable tools or libraries, I would have to write code to parse and translate the timezones myself. This is evidently doable (it's part of the standard and has been implemented successfully in some software) and had I been a few decades younger or if at least it weren't so late at night, I might have been tempted to have a go at it.
And then I had an idea: if it's easy for me, a tired human, to read and understand these timezone definitions at a glance, AI can do this too. What if instead of spending hours implementing the code to parse and translate iCal timezones I'd just ask AI to do this task? 5 minutes later the problem was solved. I guessed correctly that such a simple task can be accomplished without difficulty and at low price and latency using the smaller GPT-3.5-turbo model. Using my usual toolkit of structured input/output with JSON, Pydantic, and Instructor, I added a call to pass the timezone definitions from the file and get them back as a mapping from custom name to standard timezone. It worked perfectly on the first attempt.
# An iCal VTIMEZOME component looks like this: | |
# | |
# BEGIN:VTIMEZONE | |
# TZID:Romance Standard Time | |
# BEGIN:STANDARD | |
# DTSTART:16010101T030000 | |
# TZOFFSETFROM:+0200 | |
# TZOFFSETTO:+0100 | |
# RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10 | |
# END:STANDARD | |
# BEGIN:DAYLIGHT | |
# DTSTART:16010101T020000 | |
# TZOFFSETFROM:+0100 | |
# TZOFFSETTO:+0200 | |
# RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3 | |
# END:DAYLIGHT | |
# END:VTIMEZONE | |
vtimezones = {str(vtimezone.get('TZID')): vtimezone.to_ical().decode('utf-8') for vtimezone in cal.walk('VTIMEZONE')} | |
for vtimezone in cal.walk('VTIMEZONE'): | |
cal.subcomponents.remove(vtimezone) | |
class TZMapping(BaseModel): | |
ical_tz: str | |
pytz_tz: str | |
class TZMappings(BaseModel): | |
mappings: List[TZMapping] | |
result = ai.chat.completions.create( | |
model="gpt-3.5-turbo", | |
response_model=TZMappings, | |
messages=[ | |
{ | |
"role": "system", | |
"content": ( | |
"Inspect the provided iCal timezones and provide the corresponding pytz timezones. " + | |
"Return a mapping from the key of the user-provided iCal timezone to the value of the corresponding pytz timezone.") | |
}, | |
{ | |
"role": "user", | |
"content": json.dumps(vtimezones) | |
} | |
] | |
) | |
tzmap = {tzm.ical_tz: tzm.pytz_tz for tzm in result.mappings} | |
# tzmap looks like this: | |
# {'Romance Standard Time': 'Europe/Paris', ...} |
That's it. My little script doesn't chat with me, doesn't try to be my best friend or loyal assistant, doesn't do any semantic interpretation of data sets, nothing like that. It's a perfectly boring read-some-data-and-move-it-from-here-to-there script, with the only novelty being that one of the functions, instead of being written in pure Python, is implemented by AI. It saved me hours of work and made the task possible (I would have probably given up if I had to implement this myself - life's too short).
It’s like finding a shortcut through a maze, quietly efficient. Your method turns the complex into the approachable, and that’s a story worth telling.
Cheers to practical creativity!
Great example! I have found that the only problem AI has is the expectations of humans. For example, of course it provides wrong answers. There is no system that communicates in human language that dos not. Only calculators that only produce numbers are consistent.