Spaces:
Runtime error
Runtime error
Ilke Ileri commited on
Commit ·
7242003
1
Parent(s): a1e3c35
Add keyword-based sales filter to redirect off-topic questions
Browse files81 unmodified lines82838485868781 unmodified linesif not prompt:return jsonify({"error": "No prompt provided"}), 400# Gemma formatında promptformatted_prompt = f"<start_of_turn>user\n{prompt}<end_of_turn>\n<start_of_turn>model\n"81 unmodified lines82838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912081 unmodified linesif not prompt:return jsonify({"error": "No prompt provided"}), 400# Sales-only keyword filtersales_keywords = ['sale', 'price', 'objection', 'close', 'deal', 'customer', 'prospect','lead', 'pitch', 'negotiate', 'client', 'business', 'product', 'service','wisemate', 'revenue', 'quota', 'conversion', 'crm', 'follow up']# Check if question is sales-relatedprompt_lower = prompt.lower()is_sales_related = any(keyword in prompt_lower for keyword in sales_keywords)# If not sales-related, return redirect messageif not is_sales_related and len(prompt.split()) > 3: # Only filter if it's a real questionredirect_message = "I'm Daniel from Wisemate, and I specialize in sales and business topics. I can help you with sales techniques, handling objections, closing deals, and Wisemate's services. How can I assist you with your sales needs?"return jsonify({"id": "chatcmpl-redirect","object": "chat.completion","created": int(__import__('time').time()),"model": MODEL_NAME,"choices": [{"index": 0,"message": {"role": "assistant","content": redirect_message},"finish_reason": "stop"}],"usage": {"prompt_tokens": 0,"completion_tokens": 0,"total_tokens": 0}}), 200# Gemma formatında promptformatted_prompt = f"<start_of_turn>user\n{prompt}<end_of_turn>\n<start_of_turn>model\n"
app.py+33