Satyam0077 commited on
Commit
1c3e7e5
·
verified ·
1 Parent(s): f564d0e

Update chatbot_engine.py

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