Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,87 +1,38 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
from sentence_transformers import SentenceTransformer, util
|
|
|
|
| 3 |
|
| 4 |
# Load semantic similarity model
|
| 5 |
model = SentenceTransformer('all-MiniLM-L6-v2')
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
"What services do you offer?": "We offer managed IT services, cybersecurity, cloud consulting, server management, data backups, compliance support, and more.",
|
| 12 |
-
"Do you support remote workers?": "Yes, we offer secure remote access, VPN setup, and remote IT support for distributed teams.",
|
| 13 |
-
"How do I get help from your team?": "You can reach support via email at support@sofTouchSystems.com or by calling 1-800-555-1234.",
|
| 14 |
-
"Can you monitor our network 24/7?": "Absolutely. We offer continuous network monitoring and real-time threat alerts.",
|
| 15 |
-
"Do you provide on-site support?": "Yes, we provide both remote and on-site support depending on your business needs.",
|
| 16 |
-
"Do you offer backup and disaster recovery services?": "Yes, we offer cloud, local, and hybrid backups, plus full disaster recovery planning.",
|
| 17 |
-
"What industries do you specialize in?": "We work with small to mid-sized businesses and nonprofits, especially across Central and South Texas.",
|
| 18 |
-
"Can you help us migrate to the cloud?": "Yes, we manage cloud migrations to AWS, Azure, Google Workspace, and private cloud platforms.",
|
| 19 |
-
"Do you offer monthly service contracts?": "Yes, we offer flexible managed IT service plans based on your business size and needs.",
|
| 20 |
-
"What does a managed service provider do?": "We proactively manage and secure your IT systems so you can focus on running your business.",
|
| 21 |
-
"Do you offer cybersecurity assessments?": "Yes, we offer comprehensive cybersecurity audits and recommendations for improvement.",
|
| 22 |
-
"Can you manage our email systems?": "Yes, we provide secure and reliable email hosting and management services.",
|
| 23 |
-
"How often do you perform updates and patches?": "We patch systems regularly, usually weekly, and critical updates are handled immediately.",
|
| 24 |
-
"What is your response time for emergencies?": "We respond to emergencies within 1 hour, and most issues are resolved same-day.",
|
| 25 |
-
"Can you support Apple/Mac devices?": "Yes, we support both Windows and Apple environments.",
|
| 26 |
-
"Do you manage printers and other devices?": "Yes, we can manage printers, scanners, and other networked devices.",
|
| 27 |
-
"Do you offer firewall setup and management?": "Yes, we install and manage business-grade firewalls and advanced threat protection.",
|
| 28 |
-
"Can you help with password management?": "Yes, we offer password policy enforcement and integrate password manager solutions.",
|
| 29 |
-
"How do you protect against ransomware?": "We use endpoint protection, backup redundancy, and real-time threat detection.",
|
| 30 |
-
"What happens if our internet goes down?": "We help you set up failover connections and local network resilience options.",
|
| 31 |
-
"Do you help with IT compliance?": "Yes, we support HIPAA, PCI-DSS, and general IT compliance frameworks.",
|
| 32 |
-
"Can you set up Microsoft 365 or Google Workspace?": "Yes, we offer licensing, setup, migration, and management for both platforms.",
|
| 33 |
-
"How do I request a service call?": "You can email, call, or use our customer portal to request service anytime.",
|
| 34 |
-
"Do you offer antivirus software?": "Yes, we provide managed antivirus and endpoint protection as part of our packages.",
|
| 35 |
-
"Can you help us reduce IT costs?": "Yes, we optimize systems and consolidate services to cut unnecessary expenses.",
|
| 36 |
-
"Do you help with technology planning?": "Absolutely. We provide long-term IT roadmapping and infrastructure planning.",
|
| 37 |
-
"What is the onboarding process like?": "We do a full audit, deploy monitoring tools, and start support within 1–2 weeks.",
|
| 38 |
-
"Do you offer data encryption?": "Yes, we implement encryption for devices, cloud storage, and data in transit.",
|
| 39 |
-
"Can we keep our current hardware?": "Yes, we assess your equipment and integrate it where possible to save costs.",
|
| 40 |
-
"What makes you different from other MSPs?": "We're veteran-owned, Texas-based, and known for fast response and friendly service.",
|
| 41 |
-
"Do you train employees on cybersecurity?": "Yes, we offer phishing simulations and security awareness training.",
|
| 42 |
-
"What’s included in your managed services?": "Monitoring, help desk, patches, backups, security, and strategic advice.",
|
| 43 |
-
"Can you integrate third-party apps or CRMs?": "Yes, we work with CRMs, ERPs, and other business platforms.",
|
| 44 |
-
"Do you offer VoIP phone system support?": "Yes, we can help with VoIP setup, support, and vendor coordination.",
|
| 45 |
-
"Can you help us set up secure remote desktop access?": "Yes, we use tools like RDP over VPN and encrypted remote agents.",
|
| 46 |
-
"Do you offer documentation for our systems?": "Yes, we provide IT documentation so you always know what’s in place.",
|
| 47 |
-
"What kind of reports will I get?": "You’ll receive monthly reports on uptime, patches, security events, and more.",
|
| 48 |
-
"Is there a contract required?": "We offer both contract and no-contract month-to-month options.",
|
| 49 |
-
"How fast can we get started?": "We can start with a discovery call immediately and usually onboard within 5–10 business days.",
|
| 50 |
-
"Do you offer IT strategy consulting?": "Yes, we help align your tech decisions with your business goals.",
|
| 51 |
-
"Can you help with business continuity planning?": "Absolutely. We create BCPs tailored to your specific risk profile.",
|
| 52 |
-
"Do you offer mobile device management?": "Yes, we secure and monitor business smartphones, tablets, and laptops.",
|
| 53 |
-
"What’s your pricing structure like?": "We offer fixed monthly pricing, tiered service plans, and pay-as-you-go support.",
|
| 54 |
-
"Do you work with nonprofits?": "Yes, we serve many nonprofits and offer discounted rates for 501(c)(3) organizations.",
|
| 55 |
-
"Do you help with internet setup?": "Yes, we assist with ISP selection, router/firewall setup, and cabling.",
|
| 56 |
-
"Can you help us prevent phishing attacks?": "Yes, we use anti-phishing tools, filtering, and user training.",
|
| 57 |
-
"Will we have a dedicated point of contact?": "Yes, every client gets an account manager and dedicated tech lead.",
|
| 58 |
-
"Do you support cloud storage?": "Yes, we manage OneDrive, Google Drive, Dropbox, and other cloud platforms.",
|
| 59 |
-
"How do you back up email?": "We provide email archiving, daily backups, and retention policy management."
|
| 60 |
-
}
|
| 61 |
|
| 62 |
-
# Precompute embeddings for questions
|
| 63 |
-
|
| 64 |
-
faq_embeddings = model.encode(faq_questions, convert_to_tensor=True)
|
| 65 |
-
|
| 66 |
-
import difflib
|
| 67 |
|
| 68 |
def velma(message, history):
|
| 69 |
-
#
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
#
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
#
|
| 76 |
-
|
|
|
|
| 77 |
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
|
|
|
|
|
|
| 81 |
else:
|
| 82 |
return "I'm still learning. Try asking about our services, support, cybersecurity, or backups."
|
| 83 |
|
| 84 |
-
|
| 85 |
iface = gr.ChatInterface(
|
| 86 |
fn=velma,
|
| 87 |
title="VELMA© - Virtual Engagement Liaison & Messaging Assistant",
|
|
@@ -123,8 +74,7 @@ iface = gr.ChatInterface(
|
|
| 123 |
background: #e05d00 !important;
|
| 124 |
}
|
| 125 |
""",
|
| 126 |
-
|
| 127 |
-
theme=gr.themes.Soft() # Optional: Start with a clean theme
|
| 128 |
)
|
| 129 |
|
| 130 |
-
iface.launch(share=True)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
from sentence_transformers import SentenceTransformer, util
|
| 4 |
+
import torch
|
| 5 |
|
| 6 |
# Load semantic similarity model
|
| 7 |
model = SentenceTransformer('all-MiniLM-L6-v2')
|
| 8 |
|
| 9 |
+
# Load CSV FAQ file
|
| 10 |
+
df = pd.read_csv("faq.csv")
|
| 11 |
+
questions = df['question'].tolist()
|
| 12 |
+
answers = df['answer'].tolist()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
# Precompute embeddings for all questions
|
| 15 |
+
faq_embeddings = model.encode(questions, convert_to_tensor=True)
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
def velma(message, history):
|
| 18 |
+
# Encode the user input
|
| 19 |
+
user_embedding = model.encode(message, convert_to_tensor=True)
|
| 20 |
+
|
| 21 |
+
# Compute cosine similarities
|
| 22 |
+
cosine_scores = util.pytorch_cos_sim(user_embedding, faq_embeddings)[0]
|
| 23 |
+
|
| 24 |
+
# Find the index of the best match
|
| 25 |
+
top_match_idx = torch.argmax(cosine_scores).item()
|
| 26 |
+
top_score = cosine_scores[top_match_idx].item()
|
| 27 |
|
| 28 |
+
# Define a minimum confidence threshold
|
| 29 |
+
threshold = 0.5
|
| 30 |
+
|
| 31 |
+
if top_score >= threshold:
|
| 32 |
+
return answers[top_match_idx]
|
| 33 |
else:
|
| 34 |
return "I'm still learning. Try asking about our services, support, cybersecurity, or backups."
|
| 35 |
|
|
|
|
| 36 |
iface = gr.ChatInterface(
|
| 37 |
fn=velma,
|
| 38 |
title="VELMA© - Virtual Engagement Liaison & Messaging Assistant",
|
|
|
|
| 74 |
background: #e05d00 !important;
|
| 75 |
}
|
| 76 |
""",
|
| 77 |
+
theme=gr.themes.Soft()
|
|
|
|
| 78 |
)
|
| 79 |
|
| 80 |
+
iface.launch(share=True)
|