ChatGPT For Your Website

How to add ChatGPT search to your website

Introduction

If you don’t want to use a tool like ModernQuery to add generative AI search to your website, you can add ChatGPT search to your website with some programming steps.

The easy way

ModernQuery is an out of the box solution for adding ChatGPT to your website. Just click the signup link above and you’ll be on your way.

Looking for the fastest way to enhance your on-site search?

Our no-code search solution will drop in to your existing website.

Get a Free Demo
  • Plug and play: no complex configuration
  • Search-as-you-type
  • ChatGPT integrated search
  • Manually adjust results ordering

Rendering the site

To add ChatGPT to your website, first you’ll need a way to store all of the content of your website in an easily crawlable/indexable fashion. The trick here is that while most content management systems store your website pages as fields in separate tables, you really need a way to look at the fully rendered page so that the indexer can see the content the same way the user sees it. This is necessary for storing the vector embeddings that the OpenAI needs.

There are a few ways to render the whole site:

  • Some content management systems allow you to get the rendered page using an internal method or function. Drupal’s search API, for example, provides the ability to get a “fully rendered page”. This is an ideal setup; you can hook into the Drupal API to extract the fully rendered page and store it in a database.

  • Other content management systems allow you to hook into the indexing process for its internal search, and you may be able to grab the fully rendered page from there.

  • Otherwise, you’ll need to crawl the frontend of your site or otherwise get the page content from the frontend. There are crawling packages for PHP, Python, and NodeJS that will help with this.

Ultimately, you need the fully rendered content of the pages in a database, which you’ll then pass to an indexer.

Indexing the content

Next, you’ll need to set up a vector store on a cloud provider. Amazon’s OpenSearch can store vectors, which are essentially numeric representations of text. OpenAI uses those vectors to process the text on your site.

The rendered output from step 1 above will need to be parsed (remove anything you don’t want the indexer to see), and you’ll need to extract the vectors using the OpenAI SDK, then store them in the vector database.

Putting it all together

Once you have the vectors stored, you’ll need to write code using a library like Langchain to parse the incoming prompt, reference your vector store, pass it to the OpenAI API and give back the appropriate response.

Conclusion

Adding ChatGPT to your website search is very do-able with existing libraries, APIs, and SDKs, but it does require quite a few programming steps unless you use a ready-to-go SaaS solution like ModernQuery.