RC35. Preliminary Tinkerings with the OpenAI API
Daily dispatches from my 12 weeks at the Recurse Center in Summer 2023
I’ve been curious to do a little tinkering with the OpenAI API since early on in batch, when a fellow recurser casually demo’ed a GPT pipeline and suddenly all was demystified, but I never got around to it. And then last week another recurser showed off a project involving multiple LLM and stable diffusion pipelines. So today I let loose.
Maybe it would be cool, I thought, to run a Google search and then scrape each of the results and have GPT summarize the text from each hit? This is redundant on the one hand, since, if it’s summaries of popular or relevant websites that you want, just asking ChatGPT would be easier. But what if you wanted GPT to be able to summarize more recent material from after it was trained? I figured this way you can run your search and get a quick survey of Google’s top hits before deciding whether to click through. As an added bonus, this prototype preserves the source of the summary in the form of the origin URL, so you have a citation if you want (I do).
Totalling a couple dozen lines of code, this program
- takes as a CLI argument the search query
- uses
requests
to get the JSON-formatted results of the search using the Google API - parses the JSON response and loops through each of the hits, extracting the text with BeautifulSoup
- passes the lightly cleaned page text to the OpenAI API along with some system messages specifying a request for a summary of the page text in light of the original query
- prints GPT-3.5’s results to stdout
> python3 search.py "fourth of july 2023 los angeles"
Result 1:
65+ 4th of July Celebrations in Los Angeles 2023
https://momsla.com/best-fourth-of-july-celebrations-in-los-angeles/
In 2023, there are several Fourth of July celebrations happening in Los Angeles. One of the largest free parties is the Gloria Molina Grand Park's 4th of July Block Party, which includes live music, a digital playground for children, and a drone show instead of traditional fireworks. The Los Angeles Dodgers will also be playing a game against the Pittsburgh Pirates, followed by a fireworks show. Universal Studios Hollywood will have a July 4th Fireworks Spectacular included with admission tickets, and the Hollywood Bowl will have a special performance by The Beach Boys with fireworks. Disneyland will have its own celebration, and LEGOLAND California will have special activities and a fireworks show. Other events include Councilman Bob Blumenfield's July 4th Extravaganza in Woodland Hills and various events in the Conejo Valley and Thousand Oaks area.
Result 2:
The Best Fourth of July Events in Los Angeles | Discover Los Angeles
https://www.discoverlosangeles.com/things-to-do/the-best-fourth-of-july-events-in-los-angeles
In Los Angeles, there are several exciting Fourth of July events to celebrate Independence Day. One of the signature events is the Fourth of July Block Party at Grand Park, which features food, music, and performances by artists like Maya Jupiter and DJ Ethos. The block party also includes a dazzling drone show over The Music Center Plaza. Another option is La Lo La Rooftop at the AC Hotel DTLA, which is hosting "A Celebration of the California Cowboy" with a family-style Santa Maria BBQ, live music, and Red, White & Blue Sangria. Dodger Stadium offers Friday Night Fireworks after select home games, including on July 4th when the Dodgers host the Pittsburgh Pirates. Alamo Drafthouse in Downtown LA is screening the classic film "Jaws" on July 4th, complete with interactive experiences and themed drinks. Universal Studios Hollywood celebrates with a fireworks display, live music performances, and specially themed décor. Additionally, the Hollywood Bowl is hosting The Beach Boys
Result 6:
4th of July Fireworks in Los Angeles & Best Spots to See Them in 2023
https://www.timeout.com/los-angeles/things-to-do/4th-of-july-events-where-to-see-fireworks-in-la
In 2023, there are several places in Los Angeles where you can see Fourth of July fireworks. One popular spot is the Rose Bowl in Pasadena, where an MLS match between the L.A. Galaxy and LAFC will be followed by a fireworks show. While tickets for the match may be sold out, you can still watch the fireworks from the areas around the Rose Bowl. Another great location is Marina del Rey, where fireworks explode over the marina channel. Spectators can gather at Burton Chace Park, Fisherman's Village, Marina "Mother's" Beach, waterfront hotels and restaurants, and even on boats to enjoy the show. Keep in mind that these locations may be crowded, so plan accordingly.
Result 7:
July Fourth Fireworks Spectacular with The Beach Boys | Hollywood ...
https://www.hollywoodbowl.com/events/performances/2277/2023-07-04/july-fourth-fireworks-spectacular-with-the-beach-boys
On July 4, 2023, the Hollywood Bowl in Los Angeles will be hosting the July Fourth Fireworks Spectacular with The Beach Boys. This event is a favorite summer tradition in LA and will feature The Beach Boys performing their chart-topping hits such as "Surfin' USA," "I Get Around," and "Fun, Fun, Fun." The Hollywood Bowl Orchestra, conducted by Thomas Wilkins, will accompany the band, and there will be a spectacular fireworks display to end the night. The event will take place at 7:30 PM, and there are discounted tickets available for children aged 12 and under.
Result 9:
Celebrate Independence Day Safely at a Public Fireworks Display ...
https://www.lafd.org/news/celebrate-independence-day-safely-public-fireworks-display
On July 4, 2023, there will be several professional fireworks shows in Los Angeles. Some of the locations include the Los Angeles Civic Center - Grand Park 4th of July Block Party, Dodger Stadium, Hollywood Bowl, Marina del Rey, Pacific Palisades, Porter Ranch, San Pedro, and Woodland Hills. It is important to note that all fireworks, including "safe and sane" varieties, are illegal for personal use in the City of Los Angeles. Attending a professional fireworks show is the safest and smartest way to celebrate Independence Day. For more information on public admission, parking, and other details, it is recommended to contact the specific venue or organization hosting the show.
Result 10:
Where to See 4th of July Fireworks in Los Angeles 2023
https://mommypoppins.com/los-angeles-kids/4th-of-july-fireworks-los-angeles-orange-county
There are several places in Los Angeles where you can see fireworks on the Fourth of July in 2023. Some popular locations include the Rose Bowl in Pasadena, where they host an annual fireworks show, and the Hollywood Bowl, which also puts on a spectacular display. Other options include the Grand Park in downtown LA, where they have a free Fourth of July Block Party with live music and fireworks, and the Queen Mary in Long Beach, which hosts a fireworks show over the water. Additionally, many cities in the surrounding area, such as Santa Monica and Marina del Rey, also have their own fireworks displays.
I mean… Am I ever going to use this to perform a search? Of any kind? Nope. It’s definitely tedious and annoying and not worth the pennies each search costs. But, the exercise served its purpose, and my toes are now wet.
Next up: experimenting with ways of cumulatively summarizing large texts using GPT.