Spaces:
Runtime error
Runtime error
File size: 5,902 Bytes
d303fae 32832c1 2919379 d303fae 2919379 d303fae 32832c1 2e53d82 32832c1 440a112 18f5154 32832c1 18f5154 32832c1 18f5154 32832c1 440a112 18f5154 2e53d82 32832c1 7912ee6 | 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | import gradio as gr
from chatterbot import ChatBot
# Create object of ChatBot class
bot = ChatBot('Buddy')
# Inport ListTrainer
from chatterbot.trainers import ListTrainer
f = open('data.txt','r').read().splitlines()
#print(f)
#trainer = ListTrainer(bot)
#trainer.train(f)
def answer(q):
school = "Dear [teacher/principal name],\nI am writing to request a [number of days]-day leave from school starting from [start date] to [end date] as I am attending a family engagement ceremony.I will make sure to complete all pending assignments by [date] and resume classes on [date] with full concentration. I would be really grateful if you can consider my request and grant me the leave.Thank you for your time and consideration.\nSincerely,\n[Student Name]"
office = "Dear [Manager's / boss Name],\nI am writing to kindly request a [number of days]-day leave of absence from work, beginning [date] and ending [date].\nI will be attending a personal event which cannot be rescheduled. I have already taken care of all pending tasks, and I am confident that the team is prepared for my absence.The office has always been supportive of my needs, and for that I am grateful. I look forward to returning refreshed and ready to work hard on [date]. \nThank you for considering my request.\nSincerely,\n[Your Name]"
normal = "Dear [mom/dad],\nI hope this letter finds you in good spirits. I just wanted to take a moment to express how grateful I am for you. You’re always there for me when I need it most and you’ve helped me through some tough times in my life. I may not always show it, but I appreciate everything you’ve done for me more than you’ll ever know. \nI know that I don’t always tell you how much I love you, but please know that no matter what, I will always be here for you. Offering whatever love, support, advice, or a shoulder to lean on that you may need. You’ve been the most constant thing in my life and I can’t thank you enough for that. I love you, and I hope we can both make time for each other as often as possible. Always and Forever, \nYour Loving [Daughter/son]"
friend = "Dear [Friend],\nI hope that this letter finds you well. I wanted to take the opportunity to reach out and let you know that I'm thinking of you.\nThese days can be hard, and I know that having the support of friends can make all the difference. I'm here for you if you ever need to talk, vent, or just listen. I want you to know that you are never alone, and that I'm always available.\nYou deserve to be happy and to find peace and joy in your life. I'm so proud of you, and I admire your strength and courage. You're one of the strongest people I know.So no matter what you're dealing with, know that I am here for you. Take care of yourself and know that I'm always sending you love.With love and gratitude,\n[Your Name]"
cover = "Dear [Hiring Manager],\nI am writing to express my interest in the [Position Title] role at [Company Name]. With a background in [relevant skills or experiences], I feel confident that I would make an excellent addition to your team.\\Throughout my career, I have demonstrated a passion for [area of expertise] and consistently achieved results that exceed expectations. My enthusiasm for both deep technical knowledge and client-facing experiences has enabled me to lead successful projects on tight deadlines, develop innovative solutions to difficult business challenges, and drive process improvement initiatives. I believe these strengths make me a great fit for this role and the opportunity to work with [Company Name].\\I am confident I could bring my diverse set of experiences to the team and contribute to the success of the organization. For example, at my most recent position as a [Previous Job Holder], I was [describe accomplishments]. In addition, I have a firm understanding of [relevant technical skill] and can provide support to colleagues when needed.\\I am excited by the prospect of joining [Company Name] and look forward to discussing how my skills and experience can be beneficial in a more detailed manner. Thank you for your time and consideration.\nSincerely,\n[Your Name]"
q=q.lower()
if "leave" in q:
if "school" in q or "class" in q or "teacher" in q or "principal" in q or "sir" in q or "medam" in q:
if "day" in q:
return "Dear [Teacher/sir],\\I am writing to inform you that I will not be able to attend school on [day]. I have a family obligation that I must fulfill and will be unable to come into school that day. I apologize for the inconvenience and appreciate your understanding. I will make sure to keep up with the assignments and lectures I miss so that I don't fall behind in my studies.\\Thank you for your time and understanding.\\Sincerely, \\[Name]\\"
return school
if "office" in q or "menager" in q or "boss" in q:
return office
if "friend" in q:
return friend
if "mom" in q or "father" in q or "brother" in q or "sister" in q:
if "today" in q:
return "Dear Mom,\\I hope this letter finds you doing well. I am very sorry to disappoint you, but I have to inform you that I will not be able to come and visit you today. I know I promised that I would, but due to some circumstances I must stay back and take care of things here.\\I understand that this is not the ideal situation and it must be quite upsetting for you. Please accept my sincerest apologies for not being able to fulfill my promise. I promise to make it up to you soon.\\I hope you understand my situation. I love and miss you every day and I can't wait to see you again soon.\\Love,\\Your daughter\\"
return normal
if "cover" in q:
return cover
def greet(name):
return answer(name)
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch() |