API for ChatGPT with internet access

Hi!

I would like to know if it is possible to get chatgpt output in python code, but with a chatgpt version that has access to the internet?

For example asking a question like: „what is the hottest news topic today?“ and get the reply in python?

Thank you!!

Jacob

You’d have to tell the chatbot what the heck you mean by “Python code”, just like you have to tell us, because that question seemingly makes no sense.

You perhaps want a pythonic list or dictionary, even JSON, that is formatted and parse-able when called through the API? You’ll have to specify exactly what you want via prompt, and give some examples of the strict output you are looking for also (and even write code to scan the bot output just for the formatted text, as it may still unpredictably chime in with some “as a language model” dialogue.)

But no, the API cannot access the internet. You are getting the raw text of the AI engine model back, and further implementation of plug-in like actions is up to you to program and interface with the language understanding of an AI.

I tried to fool it into producing nonsense or denials with a prompt like you asked - and it actually gave me some code.

What were the hottest news topics of 2020? Output your answer in Python code.

news_topics_2020 = [
    "COVID-19 pandemic",
    "United States presidential election",
    "Black Lives Matter protests",
    "Australian bushfires",
    "Brexit",
    "Iran-U.S. tensions",
    "Impeachment of Donald Trump",
    "Global economic recession",
    "Kobe Bryant's death",
    "Beirut explosion",
    "Wildfires in California",
    "Stock market volatility",
    "Hong Kong protests",
    "Racial justice movements",
    "Climate change activism",
    "India-China border conflict",
    "Jeffrey Epstein case",
    "SpaceX launches",
    "US-China trade war",
    "Megxit (Prince Harry and Meghan Markle)"
]

# Printing the news topics
for index, topic in enumerate(news_topics_2020, start=1):
    print(f"{index}. {topic}")
1 Like

GPT from API doesn’t have browsing capabilities at the moment.

However, you can get what you want by implementing the actions to browse the Internet in a similar way like for example AutoGPT project does:

The idea is that ChatGPT can generate text and you can instruct ChatGPT that when it wants to take certain action (e.g. search something on the Internet), then ChatGPT can output text in a certain format, e.g. json that describes what action should be executed and with what arguments.

Perhaps, LangChain library can be helpful for implementing that, since it has already a class for agents that can run tools and implementation of some tools like for example Google Search:

https://python.langchain.com/en/latest/modules/agents/tools/getting_started.html

I hope my post in understandable. If not, then let me know.

1 Like