GPT-4 based Chatbot on set of documents

Hi All,

I am developing a chatbot which will take some set of document as context and user can ask any question from the document. If question is out of the context then GPT-4 is returning as I dont have information about the same.

I want to implement this as conversational chatbot which will preserve the previous context and user can ask follow up questions. In the current implementation GPT will search in the whole document context.

It will be of great help if someone will reply with the correct resolution?

Now I am using below prompt :

prompt = f"“”
Given the following extracted parts of a long document and a question, create a final answer.
If you don’t know the answer, just say that you don’t know. Don’t try to make up an answer.
QUESTION: {query}
=========
{" “.join([f"Content: {doc.text}” for doc in kb])}
“”"

Body content to request:

body = {
“model”: “gpt-4-32k”,
“task”: “chat/completions”,
“model-params”: {
“messages”: [{“role”: “user”, “content”: prompt}],
“temperature”: 0.1
}
}

Any leads will be appreciated… !!!

You will have to use threads, I highly recommend to use nodejs and the vercel/ai sdk to build your chatbot!

You can check my github project OpenAssistantGPT to see how I have built my chatbot https://github.com/marcolivierbouch/OpenAssistantGPT/blob/main/chatbotjs/src/Chat.tsx