Spaces:
Build error
Build error
| import gradio as gr | |
| from transformers import pipeline | |
| import crewai | |
| # Load an open-source reasoning model | |
| conversation_model = pipeline("text-classification", model="tiiuae/falcon-7b-instruct") | |
| # Define conversation steps | |
| STEPS = [ | |
| "Salutations", | |
| "Welcome message", | |
| "Validating customer account", | |
| "Asking for problem", | |
| "Working on issue", | |
| "Escalating if not able to handle", | |
| "Informing customer about solutions", | |
| "Asking customers if they have any other issue", | |
| "Saying 'Have a great day'" | |
| ] | |
| def detect_steps(transcript): | |
| detected_steps = [] | |
| for step in STEPS: | |
| result = conversation_model(transcript, return_all_scores=True) | |
| # Simple heuristic: If model confidence is above 0.5 for the step, mark it as completed | |
| step_detected = any(label["label"].lower() in step.lower() and label["score"] > 0.5 for label in result[0]) | |
| if step_detected: | |
| detected_steps.append(f"✔️ {step}") | |
| else: | |
| detected_steps.append(f"❌ {step}") | |
| return "\n".join(detected_steps) | |
| # Gradio interface | |
| demo = gr.Interface( | |
| fn=detect_steps, | |
| inputs=gr.Textbox(placeholder="Paste live transcript here..."), | |
| outputs=gr.Textbox(label="Detected Steps"), | |
| title="Live Conversation Step Detector", | |
| description="Paste a live transcript of a conversation between an Agent and a Customer. The AI will detect and mark completed steps." | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |