Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # মডেল ১: লিড অ্যানালাইসিস (Fast & Light) | |
| classifier = pipeline("zero-shot-classification", model="valhalla/distilbart-mnli-12-1") | |
| # মডেল ২: অটো-রিপ্লাই (GPT-2 ব্যবহার করছি যা সব সিস্টেমে খুব দ্রুত রান করে) | |
| generator = pipeline("text-generation", model="gpt2") | |
| def advanced_ai_agent(text): | |
| if not text or text.strip() == "": | |
| return "⚠️ Empty", 0, "N/A", "Please enter a message first." | |
| try: | |
| # ১. ইনটেন্ট অ্যানালাইসিস | |
| labels = ["High Intent", "Low Intent", "Enterprise", "Urgent"] | |
| res = classifier(text, labels) | |
| intent = res["labels"][0] | |
| # ২. স্কোরিং লজিক | |
| score = 0 | |
| msg_lower = text.lower() | |
| if "enterprise" in msg_lower: score += 50 | |
| if "urgent" in msg_lower or "asap" in msg_lower: score += 20 | |
| if "demo" in msg_lower or "price" in msg_lower: score += 20 | |
| priority = "🔥 HOT" if score >= 70 else "⚡ WARM" if score >= 40 else "❄️ COLD" | |
| # ৩. অটো-রিপ্লাই জেনারেশন (GPT-2 দিয়ে প্রফেশনাল ড্রাফট) | |
| prompt = f"Professional reply to: {text}\nReply:" | |
| gen_res = generator(prompt, max_length=50, num_return_sequences=1) | |
| response = gen_res[0]['generated_text'].split("Reply:")[-1].strip() | |
| return priority, score, intent.upper(), response | |
| except Exception as e: | |
| return "❌ Error", 0, "ERROR", f"System busy. Try again." | |
| # ইন্টারফেস ডিজাইন | |
| with gr.Blocks(theme=gr.themes.Monochrome()) as demo: | |
| gr.Markdown("# 🚀 AI Sales Command Center (v2.0 Advanced)") | |
| gr.Markdown("UIU-CSE Student Project | Advanced Lead Intelligence") | |
| with gr.Row(): | |
| with gr.Column(scale=2): | |
| lead_input = gr.Textbox(label="📥 Customer Message", placeholder="Paste text here...", lines=8) | |
| run_btn = gr.Button("🧠 ANALYZE WITH AI", variant="primary") | |
| with gr.Column(scale=1): | |
| status_label = gr.Label(label="Lead Priority") | |
| score_num = gr.Number(label="Lead Score") | |
| intent_box = gr.Textbox(label="Detected Intent") | |
| with gr.Row(): | |
| reply_box = gr.Textbox(label="🤖 AI Suggested Reply (Draft)", lines=5) | |
| run_btn.click( | |
| fn=advanced_ai_agent, | |
| inputs=lead_input, | |
| outputs=[status_label, score_num, intent_box, reply_box] | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() |