Custom ChatGPT Chatbot with UI

Sarang Mete
2 min readMar 10, 2023

--

Since the release of ChatGPT, everyone is thinking about how to use that in our business/domain. ChatGPT can answer any question as it is trained on whole internet. Can ChatGPT answer specific questions about my business/website?

I’ve tried to solve this problem in my recent project. I’ve used recently released chatgpt api.

### Chatbot High Level

1. User asks a query related to website or any random query

2. Chatbot will look for an answer in following 3 areas according to the order:

a. Chat history

b. Website pages

c. Whole internet(like a general chatgpt)

### Chatbot Core Logic Steps

1. Accept any website URL, scrape all pages within the same domain of that website. I’ve used openai’s tutorial on website QA for scraping

2. Create embeddings of text data of that website

3. User asks a query

4. Generate user query embeddings. Used “text-embedding-ada-002”

4. Look for an answer in chat history using openai’s chat completion api. Used “gpt-3.5-turbo”

5. If answer not found, then find most relevant website data embeddings(using cosine similarity) .Append this most relevant text to chat history and again use chat completion api to get the answer

6. If still answer not found(it is most likley a random query) then, chatgpt can answer as it does usually(use whole internet)

7.Easily customizable to any input any data source(documents etc.) instead of only website name

Image by Author

I’ve created a complete end to end project here.

If you liked the article or have any suggestions/comments, please share them below!

Let’s connect and discuss on LinkedIn

--

--