How to Enable Web Search Results with ChatGPT API?

I’ve been working on integrating the ChatGPT API into my application, and I’ve encountered a question regarding enabling web search functionality. I’m looking for a way to allow ChatGPT to provide web search results and return relevant information from the internet.

My initial thought was to use a call function to trigger web searches, but I’m concerned about whether the GPT model will be able to conduct searches like a human would. I understand that GPT-3.5 doesn’t have the capability to browse the internet directly.

Do you have any suggestions on how I can implement web search functionality for ChatGPT? Are there any alternative approaches that you recommend to achieve this? I want to ensure that the responses provided by ChatGPT are accurate and well-informed, and having access to web search results could greatly enhance its capabilities.

I’d greatly appreciate any insights or ideas you can provide. Thank you in advance for your help!

It’s as simple as adding “functions” to the chatbot, and actually doing the search and returning the results with your own software.

        "name": "google_for_answers",
        "description": "Search Google with fully-formed http URL to enhance knowledge.",
        "parameters": {
            "type": "object",
            "properties": {
                "url": {
                    "type": "string",

I ask a question the AI can’t know?
I get back a result that says the AI wants to search:

 "index": 0,
  "message": {
    "role": "assistant",
    "content": null,
    "function_call": {
      "name": "google_for_answers",
      "arguments": "{\n  \"url\": \"\"\n}"

However, write a better function that just takes the query terms, so the AI doesn’t get to go wild on the whole internet.

Function calling and other API updates

1 Like

the same thing works with pdf url’s?

A pdf file is not in a form where the AI can digest it.

If, for example, the AI that can search the web got a search engine result for a PDF link, I’d have to provide some special “download and parse pdf to text” function that does all the processing in software to have a chance of the AI understanding just what little could be extracted from it.

1 Like

In fact, I want to send a URL of the PDF that is on my server, it is completely readable and make a comparison with some text parameters that I am passing. using functions

PDF: Completely readable to you, but raw files, not to an AI.

This is the daily, exhausting, “how can I talk to my pdf” question.

PDF files not only are a binary data format, but also can be mostly images, like a PDF from scanning documents.

The easiest is to preprocess any files meant for AI consumption with a pdf-to-text utility, also including a pdf OCR text augmentation stage. Result, a database of text files that might still have some knowledge after tables have been garbled and other oddities.

Then you likely have more information in a txt file than you can pass to the AI all at once, a maximum of around 2000 words (or less if you want a long answer or chat history).

I believe you didn’t understand correctly…

I already managed to get it to read my pdf, I just wanted to do it using the “function call” function correctly

I don’t see how you are reformatting the web page txt here.

Azure offers a bing search returns a list of URLs

But you have to chose them and retrieve the page and format it for the API

Then there is the token limit to deal with and the cost of the tokens

I can only get about one page of text retrieved to work

Browse with Bing is reading a LOT of different documents before responding

Even if I could duplicate this the call would be cost prohibitive each call costing a dollar or more

OpenAI needs to give us access to their plugin before I will even consider any more code doing this

And they better not charge me a fortune to use it.

Bard is free I remind you

1 Like