import gradio as gr from transformers import pipeline # Load the Hugging Face model model = "google-bert/bert-large-uncased-whole-word-masking-finetuned-squad" qa_pipeline = pipeline("question-answering", model=model, tokenizer=model) # Define the function to answer questions def get_answer(text): result = qa_pipeline({ "question": text, "context": knowledge_base_text }) return result["answer"] # Define the Gradio interface def chatbot_interface(text): answer = get_answer(text) return answer knowledge_base_text = """ - British American Tobacco Bangladesh (BATB) is a leading multinational corporation operating in Bangladesh, listed on both the Dhaka Stock Exchange and Chittagong Stock Exchange. - Established in 1910, BATB has over a century of business history in Bangladesh. - Initially founded as Bangladesh Tobacco Company in 1972, it rebranded as BATB in 1998. - BATB employs over 1,200 direct employees and more than 50,000 indirect employees, mainly farmers. - Key brands under BATB include Benson & Hedges, John Player Gold Leaf, Lucky Strike, Capstan, Star, Royals, Derby, Pilot, and Hollywood. - Shehzad Munim is the first Bangladeshi managing director in BATB's history, leading the company with a visionary approach. - BATB is a significant contributor to the nation's economy, being the largest individual tax contributor and playing a vital role in the rural agri-economy. - The board of directors at BATB includes distinguished individuals such as Mr. Golam Mainuddin, Mr. Shehzad Munim, Ms. Nirala Singh, and others, guiding the company's strategic direction. - BATB's finance director, Ms. Nirala Nandini Singh, brings over 22 years of financial expertise to the organization. - Mr. Jorge Luis Macedo Pavon has recently been appointed as the Head of Operations, leveraging his two decades of experience to drive operational excellence. - Mr. Sudesh Peter, as the Head of Legal, brings extensive legal expertise garnered over a 12-year tenure. - Mr. Saad Jashim focuses on fostering talent, culture, and inclusion within BATB. - Mr. Syed Mahbub Ali, the Head of Marketing, leads BATB's marketing endeavors, driving innovation and growth. - Mr. Numayer Alam, as the Head of Commercial, steers BATB's commercial strategy with over 20 years of experience. - Mr. Sarzil Sarwar leads Information & Digital Technology, driving operational efficiency and innovation. - BATB's Statement of Business Principles emphasizes responsible business practices, mutual benefit, and good corporate conduct. - BATB prioritizes its people, fostering a culture of high performance, diversity, and inclusivity, earning multiple "Top Employer" certifications. - Initiatives like the Women Empowerment Initiative underscore BATB's commitment to gender diversity and inclusivity. - BATB's core ethos revolves around being bold, fast, empowered, responsible, and diverse, ensuring sustainable long-term value creation. """ # Create the Gradio interface iface = gr.Interface( fn=chatbot_interface, inputs="text", outputs="text", title="British American Tobacco Bangladesh", description="- powered by IDT", theme="default" ) # Run the Gradio interface iface.launch()