PeacebinfLow commited on
Commit
dd39fa5
·
verified ·
1 Parent(s): 0c2b50c

Create knowledge/mindseye_knowledge.py

Browse files
engine_03/knowledge/mindseye_knowledge.py ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import List, Dict
2
+ import random
3
+
4
+ FACTS: List[Dict] = [
5
+ {
6
+ "id": "mindseye_overview",
7
+ "title": "What is MindsEye?",
8
+ "keywords": [
9
+ "what is mindseye",
10
+ "what is minds eye",
11
+ "mindseye os",
12
+ "minds eye os",
13
+ "mindseye overview",
14
+ "os overview",
15
+ "system overview",
16
+ ],
17
+ "answer": (
18
+ "MindsEye is a multi-surface AI operating system being built under "
19
+ "SAGEWORKS AI. It treats data as time-labeled binary flows across "
20
+ "devices, browsers, and cloud services.\n\n"
21
+ "Instead of random scripts everywhere, you get:\n"
22
+ "- A shared sense of **time** for all events\n"
23
+ "- Ledgers that remember what agents did and why\n"
24
+ "- Layers like LAW-N / LAW-T / Workspace / SQL / Cloud Fabric that "
25
+ "cooperate instead of fighting each other."
26
+ ),
27
+ },
28
+ {
29
+ "id": "workspace_layer",
30
+ "title": "Workspace Automation Layer",
31
+ "keywords": [
32
+ "workspace",
33
+ "gmail",
34
+ "docs",
35
+ "sheets",
36
+ "drive",
37
+ "workspace automation",
38
+ "google workspace",
39
+ "apps script",
40
+ ],
41
+ "answer": (
42
+ "The Workspace layer is the front-of-house for MindsEye.\n\n"
43
+ "Gmail, Docs, Sheets, and Drive events land here first. They get:\n"
44
+ "- Labeled with time and context\n"
45
+ "- Routed into flows\n"
46
+ "- Optionally logged into ledgers\n\n"
47
+ "It’s the part that makes MindsEye feel like an assistant living "
48
+ "inside your existing tools, not just another random bot."
49
+ ),
50
+ },
51
+ {
52
+ "id": "ledger_layer",
53
+ "title": "MindsEye Ledger / Time-Labeled Truth",
54
+ "keywords": [
55
+ "ledger",
56
+ "google ledger",
57
+ "time labeled",
58
+ "time-labeled",
59
+ "tlb",
60
+ "binary ledger",
61
+ ],
62
+ "answer": (
63
+ "The ledger layer is where MindsEye becomes ruthless about time.\n\n"
64
+ "Every event, prompt, and response becomes a **time-labeled row**. "
65
+ "Agents can look back and see:\n"
66
+ "- What happened\n"
67
+ "- When it happened\n"
68
+ "- Which node or agent acted\n\n"
69
+ "That lets MindsEye reason over history instead of treating each prompt "
70
+ "like amnesia mode."
71
+ ),
72
+ },
73
+ {
74
+ "id": "law_n_layer",
75
+ "title": "LAW-N — Network-Native Layer",
76
+ "keywords": [
77
+ "law-n",
78
+ "law n",
79
+ "lawn",
80
+ "network layer",
81
+ "network-native",
82
+ "api graph",
83
+ "service graph",
84
+ ],
85
+ "answer": (
86
+ "LAW-N is the network-native layer of MindsEye.\n\n"
87
+ "Instead of hard-coding API calls everywhere, LAW-N treats services, "
88
+ "agents, and tools as a **graph of time-aware nodes**. Each node knows:\n"
89
+ "- What data it consumes\n"
90
+ "- What it outputs\n"
91
+ "- How it fits into the wider flow."
92
+ ),
93
+ },
94
+ {
95
+ "id": "roadmap",
96
+ "title": "MindsEye Roadmap",
97
+ "keywords": [
98
+ "roadmap",
99
+ "what next",
100
+ "next steps",
101
+ "plan",
102
+ "how to scale",
103
+ ],
104
+ "answer": (
105
+ "High-level roadmap:\n\n"
106
+ "1. Sandbox — this Space: local chatbot + flow studio.\n"
107
+ "2. Glue — bridge sandbox into ledgers + Workspace flows.\n"
108
+ "3. Network — orchestrate services via LAW-N.\n"
109
+ "4. Full Stack — OS experience across web, mobile, and cloud."
110
+ ),
111
+ },
112
+ ]
113
+
114
+ GENERIC_FALLBACKS = [
115
+ "I don’t have that topic wired into the sandbox brain yet. Try asking about MindsEye, the ledger, LAW-N, the roadmap, or SAGEWORKS.",
116
+ "This version of the bot is intentionally small. If this topic matters, it probably deserves its own node or ledger later.",
117
+ ]
118
+
119
+ GREETING_TRIGGERS = [
120
+ "hi", "hello", "hey", "yo", "morning", "afternoon", "evening", "sup", "what's up", "whats up"
121
+ ]
122
+
123
+
124
+ def normalize(text: str) -> str:
125
+ return text.strip().lower()
126
+
127
+
128
+ def is_greeting(message: str) -> bool:
129
+ msg = normalize(message)
130
+ return any(trigger in msg for trigger in GREETING_TRIGGERS)
131
+
132
+
133
+ def greeting_reply() -> str:
134
+ options = [
135
+ "Yo 👋 This is the MindsEye sandbox brain. No APIs, just local logic.",
136
+ "Hey 👋 You’re talking to the MindsEye sandbox bot — the tiny version before the 21-repo beast shows up.",
137
+ "Hi 👋 This is the clean-slate MindsEye chatbot. Ask about MindsEye, the ledger, LAW-N, or the roadmap.",
138
+ ]
139
+ return random.choice(options)
140
+
141
+
142
+ def find_best_fact(user_message: str) -> str:
143
+ msg = normalize(user_message)
144
+
145
+ if is_greeting(msg):
146
+ return greeting_reply()
147
+
148
+ # Exact keyword match
149
+ for fact in FACTS:
150
+ for kw in fact["keywords"]:
151
+ if kw in msg:
152
+ return fact["answer"]
153
+
154
+ # Soft scoring
155
+ best_fact = None
156
+ best_score = 0
157
+ tokens = set(msg.split())
158
+
159
+ for fact in FACTS:
160
+ score = 0
161
+ for kw in fact["keywords"]:
162
+ for token in kw.split():
163
+ if token in tokens:
164
+ score += 1
165
+ if score > best_score:
166
+ best_score = score
167
+ best_fact = fact
168
+
169
+ if best_fact and best_score > 0:
170
+ return best_fact["answer"]
171
+
172
+ return random.choice(GENERIC_FALLBACKS)