Spaces:
Sleeping
Sleeping
Update chatbot_engine.py
Browse files- chatbot_engine.py +77 -71
chatbot_engine.py
CHANGED
|
@@ -1,71 +1,77 @@
|
|
| 1 |
-
import random
|
| 2 |
-
from
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
"
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
"
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
"
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
"
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import random
|
| 2 |
+
from intent_mapper import detect_intent
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def load_text(filename: str) -> str:
|
| 6 |
+
with open(filename, "r", encoding="utf-8") as f:
|
| 7 |
+
return f.read().strip()
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
# Load knowledge files (FLAT FILES)
|
| 11 |
+
PROFILE = load_text("futurelab_profile.txt")
|
| 12 |
+
SERVICES = load_text("services.txt")
|
| 13 |
+
WORKSHOPS = load_text("workshops.txt")
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
INTRO_LINES = [
|
| 17 |
+
"Good question.",
|
| 18 |
+
"Sure, let me explain.",
|
| 19 |
+
"Here’s a quick overview.",
|
| 20 |
+
"Happy to clarify.",
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
FOLLOW_UP_LINES = [
|
| 24 |
+
"Let me know if you’d like more details.",
|
| 25 |
+
"You can also ask about our services or workshops.",
|
| 26 |
+
]
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def get_response(user_input: str) -> str:
|
| 30 |
+
intent = detect_intent(user_input)
|
| 31 |
+
intro = random.choice(INTRO_LINES)
|
| 32 |
+
follow_up = random.choice(FOLLOW_UP_LINES)
|
| 33 |
+
|
| 34 |
+
if intent == "profile":
|
| 35 |
+
return f"{intro}\n\n{PROFILE}\n\n{follow_up}"
|
| 36 |
+
|
| 37 |
+
if intent == "focus":
|
| 38 |
+
return (
|
| 39 |
+
"Futurelab Studios focuses on AI enablement and adoption. "
|
| 40 |
+
"We help organizations and individuals apply AI in practical, "
|
| 41 |
+
"responsible ways through consulting, education, and AI-first tools."
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
if intent == "consulting":
|
| 45 |
+
return (
|
| 46 |
+
"Yes, Futurelab Studios provides AI consulting. "
|
| 47 |
+
"We work with organizations to identify real business use cases, "
|
| 48 |
+
"design AI-driven workflows, and support responsible AI adoption."
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
if intent == "adoption":
|
| 52 |
+
return (
|
| 53 |
+
"Futurelab helps organizations adopt AI by combining strategic "
|
| 54 |
+
"consulting, hands-on workshops, and the development of custom "
|
| 55 |
+
"AI tools that fit naturally into existing workflows."
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
if intent == "global":
|
| 59 |
+
return (
|
| 60 |
+
"Yes, Futurelab Studios works with a global audience. "
|
| 61 |
+
"We collaborate with organizations and professionals across "
|
| 62 |
+
"different regions and design our AI solutions and workshops "
|
| 63 |
+
"to be globally relevant."
|
| 64 |
+
)
|
| 65 |
+
|
| 66 |
+
if intent == "services":
|
| 67 |
+
return f"{intro}\n\n{SERVICES}\n\n{follow_up}"
|
| 68 |
+
|
| 69 |
+
if intent == "workshops":
|
| 70 |
+
return f"{intro}\n\n{WORKSHOPS}\n\n{follow_up}"
|
| 71 |
+
|
| 72 |
+
# Brand-safe fallback
|
| 73 |
+
return (
|
| 74 |
+
"I can help you understand what Futurelab Studios does, "
|
| 75 |
+
"how we help organizations adopt AI, or what services "
|
| 76 |
+
"and workshops we offer."
|
| 77 |
+
)
|