import gradio as gr from transformers import pipeline import random # List of backend servers (simulated instances of the pipeline) backend_servers = [ pipeline("question-answering", model="google-bert/bert-large-uncased-whole-word-masking-finetuned-squad"), pipeline("question-answering", model="google-bert/bert-large-uncased-whole-word-masking-finetuned-squad"), pipeline("question-answering", model="google-bert/bert-large-uncased-whole-word-masking-finetuned-squad") ] # Function to select a backend server in a round-robin manner def select_backend(): return random.choice(backend_servers) # Define the function to answer questions def get_answer(text): backend = select_backend() result = backend(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'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. - For any technical support , laptop , monitor , mouse , headphone , keyboard, password , credentials & hardware issue, you should contact Mamun Nasir Bhai & his number 01730372426 . - Service desk contact number 01313703069 - To take leave & employee leave request portal link is "bat.sharepoint.com/sites/NextGearInduction/NextGear/SitePages/System-Links.aspx" - turquoise is located in 1st floor near IDT floor . - Opal and Amber is located 2nd floor near CoRA floor - for SIM, talktime , Mobile Rechage , Top up related issue , Please contact Faizava Tabassum 01332523269 - To request any hardware like mouse , headphone , keyboard , laptop you should access this link https://batnowprod.service-now.com/sp - For employee offboarding , you should contact to service desk 01313703069 . - Service desk is located at HO 1st floor & Annes near basketball ground. - for SAP , wifi , network related issue , you should contact Md. Monirul Islam & his contact number 01730372426 """ iface = gr.Interface( fn=chatbot_interface, inputs="text", outputs="text", css="footer{display:none !important}", title="British American Tobacco Bangladesh", description="- powered by IDT", theme='compact' ) iface.launch()