based on this code 
# -*- coding: utf-8 -*-
"""GPT_for_chatbot_main.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1_Jue7uz455TpSfZpBmX5O6MtUXIyQ6ZP
"""

from google.colab import drive
drive.mount('/content/drive')

! pip install transformers

import numpy as np
from transformers import AutoTokenizer, AutoConfig, AutoModelForPreTraining, \
                         TrainingArguments, Trainer
import torch
from torch.utils.data import Dataset

!pip install datasets

from datasets import load_dataset
dataset = load_dataset('daily_dialog')

def load_conversations(data):
  context = []
  response = []

  for i in range(len(dataset[data])):
    for j in range(len(dataset[data][i]['dialog'])-1):
      context.append(dataset[data][i]['dialog'][j])
      response.append(dataset[data][i]['dialog'][j+1])
  return context, response

SPECIAL_TOKENS  = { "bos_token": "
",
                    "eos_token": "
",
                    "unk_token": "
",
                    "pad_token": "
",
                    "sep_token": "
"}
MAXLEN          = 60

class myDataset(Dataset):

  def __init__(self, data, tokenizer):

    context, response = [], []

    for k, v in data.items():
      context.append(v[0])
      response.append(v[1])

    self.tokenizer = tokenizer
    self.response  = response
    self.context      = context

  def __len__(self):
    return len(self.context)

  def __getitem__(self, i):

    input = SPECIAL_TOKENS['bos_token'] + self.context[i] + \
            SPECIAL_TOKENS['sep_token'] + \
            self.response[i] + SPECIAL_TOKENS['eos_token']

    encodings_dict = tokenizer(input,
                              truncation=True,
                              max_length=MAXLEN,
                              padding="max_length")

    input_ids = encodings_dict['input_ids']
    attention_mask = encodings_dict['attention_mask']

    return {'label': torch.tensor(input_ids),
            'input_ids': torch.tensor(input_ids),
            'attention_mask': torch.tensor(attention_mask)}

tokenizer = AutoTokenizer.from_pretrained('gpt2')

tokenizer.add_special_tokens(SPECIAL_TOKENS)

config = AutoConfig.from_pretrained('gpt2',
                                    bos_token_id=tokenizer.bos_token_id,
                                    eos_token_id=tokenizer.eos_token_id,
                                    sep_token_id=tokenizer.sep_token_id,
                                    pad_token_id=tokenizer.pad_token_id,
                                    output_hidden_states=False)

model = AutoModelForPreTraining.from_pretrained('gpt2', config=config)
model.resize_token_embeddings(len(tokenizer))
model.cuda()

context_train, response_train = load_conversations('train')
context_val, response_val = load_conversations('validation')



train_data = dict()
i=0

for context, response in zip (context_train, response_train):
  train_data[i] = [context, response]
  i += 1

#********************************************
val_data = dict()
i=0

for context, response in zip (context_val, response_val):
  val_data[i] = [context, response]
  i += 1

train_dataset = myDataset(train_data, tokenizer)
val_dataset = myDataset(val_data, tokenizer)

# load_model_path = '/content/drive/MyDrive/models/checkpoint-1000/pytorch_model.bin'
# model.load_state_dict(torch.load(load_model_path))


training_args = TrainingArguments(
    output_dir="/content/drive/MyDrive/models",
    num_train_epochs=3,
    eval_steps = 2000,
    save_steps=2000,
    warmup_steps=500,
    prediction_loss_only=True,
    learning_rate = 5e-4,
    do_eval = True,
    evaluation_strategy = 'steps'
    )

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=train_dataset,
    eval_dataset=val_dataset,
    tokenizer=tokenizer
)

trainer.train()

trainer.save_model('/content/drive/MyDrive/final model')

load_model_path = '/content/drive/MyDrive/models/checkpoint-26000/pytorch_model.bin'

tokenizer = AutoTokenizer.from_pretrained('gpt2')
tokenizer.add_special_tokens(SPECIAL_TOKENS)

config = AutoConfig.from_pretrained('gpt2',
                                    bos_token_id=tokenizer.bos_token_id,
                                    eos_token_id=tokenizer.eos_token_id,
                                    sep_token_id=tokenizer.sep_token_id,
                                    pad_token_id=tokenizer.pad_token_id,
                                    output_hidden_states=False)

model = AutoModelForPreTraining.from_pretrained('gpt2', config=config)
model.resize_token_embeddings(len(tokenizer))

model.load_state_dict(torch.load(load_model_path))
model.cuda()

model.eval()

def generate_response(text):

  inp_context = SPECIAL_TOKENS['bos_token'] + text + SPECIAL_TOKENS['sep_token']
  generated = torch.tensor(tokenizer.encode(inp_context)).unsqueeze(0)
  device = torch.device("cuda")
  generated = generated.to(device)
  sample_outputs = model.generate(generated,
                                do_sample=True,
                                top_k=0,
                                min_length=5,
                                max_length=30,
                                num_return_sequences=10
                                )


  for i, sample_output in enumerate(sample_outputs):
    text_gen = tokenizer.decode(sample_output, skip_special_tokens=True)
    a = len(text)
    print("{}: {}\n\n".format(i+1,  text_gen))

  return

generate_response('Where have you been?')

generate_response('What is your favourite color?')

generate_response('What do you want to eat?')
write it for this data
{
    "conversations": [
        {
            "conversation_id": "3c091d14-fd54-4e25-b1e3-d348f8dd73fb",
            "messages": [
                {
                    "name": "John Doe",
                    "type": "customer",
                    "message": "Hey, Jane! How's it going?"
                },
                {
                    "name": "agent 1",
                    "type": "agent",
                    "message": "Hey John! I'm good, thanks. How about you?"
                },
                {
                    "name": "John Doe",
                    "type": "customer",
                    "message": "Can't complain. Hey, do you happen to know what the minimum age is to open an account here?"
                },
                {
                    "name": "agent 1",
                    "type": "agent",
                    "message": "I think it's 18 years. At least that's what I was told when I opened mine."
                }
            ]
        },
        {
            "conversation_id": "ad5e3b21-36a2-4c0f-b0b6-63f3816e0f4e",
            "messages": [
                {
                    "name": "Jane Doe",
                    "type": "customer",
                    "message": "Hi John! How have you been?"
                },
                {
                    "name": "agent 2",
                    "type": "agent",
                    "message": "Hey Jane! I've been good, thank you. How about yourself?"
                },
                {
                    "name": "Jane Doe",
                    "type": "customer",
                    "message": "Not too bad. By the way, do you know what the minimum balance is to maintain an account here?"
                },
                {
                    "name": "agent 2",
                    "type": "agent",
                    "message": "I believe it's $10. That's what they mentioned when I signed up."
                }
            ]
        },
        {
            "conversation_id": "2c90e715-193e-4938-8153-f23fd1be9473",
            "messages": [
                {
                    "name": "Customer",
                    "type": "customer",
                    "message": "I wish to request chargeback"
                },
                {
                    "name": "Agent",
                    "type": "agent",
                    "message": "May I know the date, amount and merchant name?"
                },
                {
                    "name": "Customer",
                    "type": "customer",
                    "message": "The amount is 198.20 and date is: '10-OCT-2022' from"
                },
                {
                    "name": "Agent",
                    "type": "agent",
                    "message": "I have found this transaction and it is not qualified for chargeback, is there other transaction I can help you with"
                },
                {
                    "name": "Customer",
                    "type": "customer",
                    "message": "Yes, amount is amount 7849.90 from LG on December 12"
                }
            ]
        },
        {
            "conversation_id": "7d2fb18d-9f29-4a8e-936a-7da06e5fb746",
            "messages": [
                {
                    "name": "Jack Williams",
                    "type": "customer",
                    "message": "Hello, I want to request a chargeback."
                },
                {
                    "name": "Agent 3",
                    "type": "agent",
                    "message": "May I know the date, amount and merchant name?"
                },
                {
                    "name": "Jack Williams",
                    "type": "customer",
                    "message": "The amount is 198.20 and date is: \"10-OCT-2022\" from "
                },
                {
                    "name": "Agent 3",
                    "type": "agent",
                    "message": "I have found this transaction and it is not qualified for chargeback, is there other transaction I can help you with"
                },
                {
                    "name": "Jack Williams",
                    "type": "customer",
                    "message": "Yes, amount is amount 7849.90 from LG on December 12"
                },
                {
                    "name": "Agent 3",
                    "type": "agent",
                    "message": "This transaction is qualified for chargeback, the reference ID is 304712, do you wish to proceed and do you agree with our terms of service?"
                }
            ]
        }
    ]
}