SarowarSaurav commited on
Commit
7aa4bbc
1 Parent(s): 9178f13

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -13
app.py CHANGED
@@ -1,7 +1,9 @@
1
  import gradio as gr
 
2
 
3
  # Define the knowledge base as a dictionary
4
  knowledge_base = {
 
5
  "SOP": "Sales Operations Planning / Standard Operational Procedure / Start of Production",
6
  "NTO": "Net Turnover",
7
  "D&A": "Data & Analytics",
@@ -2522,7 +2524,6 @@ knowledge_base = {
2522
  "RLL": "Research Launch Leader",
2523
  "RLM": "Research Launch Manager",
2524
 
2525
-
2526
  }
2527
 
2528
  # Define the Gradio interface function
@@ -2531,19 +2532,40 @@ def chatbot_interface(acronym):
2531
  if acronym in knowledge_base:
2532
  response = f"Answer: {knowledge_base[acronym]}"
2533
  else:
2534
- response = "Not found in the BATCCAPEDIA"
 
 
 
 
2535
  return response
2536
 
2537
  # Create the Gradio interface
2538
- iface = gr.Interface(
2539
- fn=chatbot_interface,
2540
- inputs="text",
2541
- outputs="text",
2542
- css="footer{display:none !important}",
2543
- title="BATB Acronym Finder",
2544
- description="Dictionary of Abbreviations & Acronyms",
2545
- theme='default'
2546
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2547
 
2548
- # Launch the interface
2549
- iface.launch()
 
1
  import gradio as gr
2
+ import difflib
3
 
4
  # Define the knowledge base as a dictionary
5
  knowledge_base = {
6
+ "USP" : "Unique Selling Point",
7
  "SOP": "Sales Operations Planning / Standard Operational Procedure / Start of Production",
8
  "NTO": "Net Turnover",
9
  "D&A": "Data & Analytics",
 
2524
  "RLL": "Research Launch Leader",
2525
  "RLM": "Research Launch Manager",
2526
 
 
2527
  }
2528
 
2529
  # Define the Gradio interface function
 
2532
  if acronym in knowledge_base:
2533
  response = f"Answer: {knowledge_base[acronym]}"
2534
  else:
2535
+ closest_match = difflib.get_close_matches(acronym, knowledge_base.keys(), n=1)
2536
+ if closest_match:
2537
+ response = f"No exact match found in BATCCAPEDIA. Did you mean '{closest_match[0]}'?"
2538
+ else:
2539
+ response = "Not found in BATCCAPEDIA"
2540
  return response
2541
 
2542
  # Create the Gradio interface
2543
+ css = """
2544
+ .gradio-container {
2545
+ background: rgb(14, 43, 99);
2546
+ display: flex;
2547
+ flex-direction: column;
2548
+ align-items: center;
2549
+ }
2550
+ footer {
2551
+ display: none !important;
2552
+ }
2553
+ """
2554
+
2555
+ # HTML content for the logo
2556
+ html_content = """
2557
+ <div style="text-align: center; margin-bottom: 20px;">
2558
+ <img src="https://i.ibb.co/82Qf4rc/APMEA-CENTRAL-White.png" border="0" alt='BAT Bangladesh Logo' style='max-width: 300px;'>
2559
+ </div>
2560
+ """
2561
+
2562
+ with gr.Blocks(css=css) as demo:
2563
+ gr.HTML(html_content)
2564
+ gr.Interface(
2565
+ fn=chatbot_interface,
2566
+ inputs=gr.Textbox(label="Acronym", placeholder="Enter Acronym Here"),
2567
+ outputs=gr.Textbox(label="Answer"),
2568
+ theme='default',
2569
+ )
2570
 
2571
+ demo.launch(allowed_paths=["."])