With the new Completions function calling API you can actually enable ChatGPT to access the internet. I did a few quick experiments where I provided it with a function called get_extracted_url_contents
. See how it made use of it:
Get News
Script: https://github.com/akirk/cli-chatgpt/blob/main/get-news.php
$ php get-news.php
Prompt: Get some news from a random US news website on the internet.
Fetching https://www.cnn.com by request of ChatGPT.
AI (239 tokens used):
According to CNN, the breaking news is that the former US president has been arraigned on 37 federal charges involving the alleged mishandling of highly classified military documents. This is a historic first.
Or from a German website:
Prompt: Get some news from a random German news website on the internet. Please only respond in English.
Fetching https://www.spiegel.de/international by request of ChatGPT.
AI (1363 tokens used):
Here are some news headlines from SPIEGEL International:
- “Ukraine’s President Calls on NATO to Set Clear ‘Red Lines’ for Russia” – Ukrainian President Volodymyr Zelensky has urged NATO to establish clear “red lines” to deter further aggression from Russia. Zelensky made these remarks during a visit to Brussels.
- “German Cabinet Approves New COVID-19 Restrictions, Including Nationwide Vaccination Mandate” – The German government has approved new measures to combat the spread of COVID-19, including a nationwide vaccination mandate for certain groups of people. These measures come as Germany faces a surge in COVID-19 cases.
- “Turkey Summons German Ambassador Over ‘AfD-Led’ Turkish Ship Inspection” – Turkey has summoned the German ambassador to protest against the inspection of a Turkish ship by a German frigate in the Mediterranean Sea. The inspection was led by a member of the far-right Alternative for Germany (AfD) party.
- “European Court of Justice Rules Hungary’s NGO Law Violates EU Law” – The European Court of Justice has ruled that Hungary’s controversial law that restricts the activities of non-governmental organizations (NGOs) violates EU law. The law required NGOs that receive funding from abroad to register as “foreign-funded organizations.”
Please note that these are just a few selected headlines. For more information, you can visit the SPIEGEL International website.
One more try for a specific site:
Prompt: Get some news from ORF. Please only respond in English.
Fetching https://orf.at/ by request of ChatGPT.
AI (1286 tokens used):
Here are some news headlines from ORF:
- Document affair: Trump declares “not guilty”
- Babler presents his new team
- Johnson vs. Sunak: Insults keeping the British on edge
- Slovenia wants to keep borders with Croatia open
- WKStA secures data in the Chancellor’s Office
- Alaba is about to reach the next milestone
- Alpine climate in winter is significantly too mild
- IAEA “very concerned” about fighting near Zaporizhia nuclear power plant
- NATO hopes Ukrainian successes will force Moscow to negotiate
Please note that these are only the headlines and more details can be found on the ORF website.
Summarize URLs
Script: https://github.com/akirk/cli-chatgpt/blob/main/summarize-url.php
$ php summarize-url.php https://alex.kirk.at/2023/02/02/what-is-matrix/
Fetching https://alex.kirk.at/2023/02/02/what-is-matrix/ by request of ChatGPT.
AI (1340 tokens used):
Matrix is an open-source internet-based chat system that operates on a federated model similar to email. It allows users to send and receive messages through homeservers, which maintain up-to-date copies of chat rooms. Matrix rooms can be either unencrypted and openly discoverable or end-to-end encrypted and invite-only, with encryption keys shared between users’ client software. There is a wide selection of Matrix clients available for different platforms, and a WordPress plugin called Chatrix has been developed to embed Matrix into WordPress posts or pages.
Research
Script: https://github.com/akirk/cli-chatgpt/blob/main/research.php
Here it required several runs to get the right response since it tried to access a lot of invalid URLs. But it eventually managed.
$ php research.php
Prompt: Research on the internet who won the ATP French Open 2023 but don’t use a search engine.
Fetching https://en.wikipedia.org/wiki/2023_French_Open by request of ChatGPT.
AI (1085 tokens used):
According to the information on the Wikipedia page for the 2023 French Open, Novak Djokovic won the ATP Men’s Singles championship.
Things also worked out in the end when I gave it the ability to do multipel requests:
$ php research.php
Prompt: Research on wikipedia who won the (both men’s and women’s) ATP French Open 2023. If you cannot find a result, ask for a subsequent a function call.
Fetching https://en.wikipedia.org/wiki/2023_French_Open_%E2%80%93_Men%27s_Singles by request of ChatGPT.PHP Warning: file_get_contents(https://en.wikipedia.org/wiki/2023_French_Open_%E2%80%93_Men%27s_Singles): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
Fetching https://en.wikipedia.org/wiki/2023_French_Open_%E2%80%93_Women%27s_Singles by request of ChatGPT.PHP Warning: file_get_contents(https://en.wikipedia.org/wiki/2023_French_Open_%E2%80%93_Women%27s_Singles): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
Fetching https://en.wikipedia.org/wiki/2023_French_Open by request of ChatGPT.
AI (1630 tokens used):
The winner of the men’s singles ATP French Open 2023 is Novak Djokovic, and the winner of the women’s singles ATP French Open 2023 is Iga ÅšwiÄ…tek.
This has been just a quick exploration following OpenAI’s announcement. Curious how we’ll leverage this better in future!