|
|
|
|
|
|
|
|
|
|
|
import gradio as gr |
|
|
import pandas as pd |
|
|
from transformers import pipeline |
|
|
import datetime |
|
|
|
|
|
|
|
|
|
|
|
print("Loading AI Model... Please wait.") |
|
|
classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli") |
|
|
|
|
|
|
|
|
def process_sales_lead(customer_name, company, interaction_text): |
|
|
|
|
|
labels = ["Sales Opportunity", "Technical Support", "General Inquiry", "Urgent RFQ"] |
|
|
|
|
|
|
|
|
result = classifier(interaction_text, labels) |
|
|
top_intent = result['labels'][0] |
|
|
confidence_score = round(result['scores'][0] * 100, 2) |
|
|
|
|
|
|
|
|
priority = "LOW" |
|
|
if top_intent in ["Sales Opportunity", "Urgent RFQ"] and confidence_score > 70: |
|
|
priority = "HIGH" |
|
|
elif confidence_score > 50: |
|
|
priority = "MEDIUM" |
|
|
|
|
|
|
|
|
output_data = { |
|
|
"Timestamp": datetime.datetime.now().strftime("%Y-%m-%d %H:%M"), |
|
|
"Customer": customer_name, |
|
|
"Company": company, |
|
|
"Detected Intent": top_intent, |
|
|
"AI Confidence (%)": confidence_score, |
|
|
"Priority Level": priority |
|
|
} |
|
|
|
|
|
|
|
|
return f"Intent: {top_intent} ({confidence_score}%)", f"Priority: {priority}", output_data |
|
|
|
|
|
|
|
|
with gr.Blocks(theme=gr.themes.Soft()) as demo: |
|
|
gr.Markdown("# 🚀 Sales Ops: AI Lead Scoring Hub") |
|
|
gr.Markdown("### Proof of Concept: Automating Repetitive Manual Lead Triaging") |
|
|
|
|
|
with gr.Row(): |
|
|
with gr.Column(): |
|
|
name = gr.Textbox(label="Customer Name", placeholder="e.g., John Doe") |
|
|
company = gr.Textbox(label="Company", placeholder="e.g., TechCorp") |
|
|
text = gr.TextArea(label="Interaction Text (Email/Log)", |
|
|
placeholder="e.g., I need a quote for 500 units of the 5G connector...") |
|
|
submit_btn = gr.Button("Analyze Lead", variant="primary") |
|
|
|
|
|
with gr.Column(): |
|
|
intent_out = gr.Label(label="AI Analysis") |
|
|
priority_out = gr.Textbox(label="System Priority Action") |
|
|
json_out = gr.JSON(label="Cleaned Data for SAP/Salesforce Ingestion") |
|
|
|
|
|
submit_btn.click( |
|
|
fn=process_sales_lead, |
|
|
inputs=[name, company, text], |
|
|
outputs=[intent_out, priority_out, json_out] |
|
|
) |
|
|
|
|
|
|
|
|
demo.launch(debug=True) |
|
|
|