File size: 893 Bytes
5813654 45dfc95 5813654 45dfc95 5813654 45dfc95 5813654 45dfc95 5813654 45dfc95 5813654 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import gradio
from transformers import pipeline
# Initialize the Hugging Face model
model = pipeline(model='google/flan-t5-large')
# 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() |