import gradio
from transformers import pipeline

# Initialize the Hugging Face model
model = pipeline(model='EleutherAI/gpt-j-6b')


# Define the chatbot function
def chatbot(input_text):

    prompt = f"Give the answer of the given input in context from the bhagwat geeta. give suggestions to user which are based upon the meanings of shlok in bhagwat geeta, input = {input_text}"
    # Generate a response from the Hugging Face model
    response = model(prompt, max_length=250, do_sample=True)[0]['generated_text'].strip()
  
    # Return the bot response
    return response

# Define the Gradio interface
gradio_interface = gradio.Interface(
    fn=chatbot,
    inputs='text',
    outputs='text',
    title='Chatbot',
    description='A weird chatbot conversations experience.',
    examples=[
        ['Hi, how are you?']
    ]
)

# Launch the Gradio interface
gradio_interface.launch()