Spaces:
Sleeping
Sleeping
import gradio as gr | |
# Define the knowledge base as a dictionary | |
knowledge_base = { | |
"SOP": "Sales Operations Planning / Standard Operational Procedure / Start of Production", | |
"NTO": "Net Turnover", | |
"D&A": "Data & Analytics", | |
"HOF":"Head of Function", | |
"APFO": "Adjusted Profit from Operations", | |
"LEP": "Limited Edition Pack", | |
"AD": "Area Director", | |
"IDT" : "Information & Digital Technology", | |
"CORA" : "Corporate & Regulatory Affairs", | |
"EOB" : "End of Business Day", | |
"OOO" :"Out of Office", | |
} | |
# Define the Gradio interface function | |
def chatbot_interface(acronym): | |
acronym = acronym.strip().toUpperCase() # Remove leading/trailing whitespace and convert to uppercase | |
if (acronym in knowledge_base): | |
response = f"Answer: {knowledge_base[acronym]}" | |
else: | |
response = "Not found in the BATCCAPEDIA" | |
return response | |
# HTML code to add the logo | |
header_html = """ | |
<div style="text-align: center; margin-bottom: 20px;"> | |
<img src="https://www.batbangladesh.com/imgs/BAT_Bangladesh_Logo.png" alt="BAT Bangladesh Logo" style="max-width: 200px;"> | |
</div> | |
""" | |
# Create the Gradio interface | |
iface = gr.Interface( | |
fn=chatbot_interface, | |
inputs="text", | |
outputs="text", | |
css="footer{display:none !important}", | |
title="BATB Acronym Finder", | |
description="Dictionary of Abbreviations & Acronyms", | |
theme='default', | |
header_html=header_html | |
) | |
# Launch the interface | |
iface.launch() | |