@misterscan/sesi 1.1.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -8
- package/bin/sesi.js +35 -34
- package/dist/ai-runtime.d.ts +5 -0
- package/dist/ai-runtime.d.ts.map +1 -1
- package/dist/ai-runtime.js +157 -7
- package/dist/ai-runtime.js.map +1 -1
- package/dist/builtins.d.ts +1 -1
- package/dist/builtins.d.ts.map +1 -1
- package/dist/builtins.js +114 -1
- package/dist/builtins.js.map +1 -1
- package/dist/interpreter.d.ts +6 -1
- package/dist/interpreter.d.ts.map +1 -1
- package/dist/interpreter.js +210 -36
- package/dist/interpreter.js.map +1 -1
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +2 -0
- package/dist/parser.js.map +1 -1
- package/dist/sesi.bundled.js +534 -107
- package/dist/types.d.ts +9 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/docs/ARCHITECTURE.md +9 -9
- package/docs/BUILTINS.md +87 -8
- package/docs/DISTRIBUTED_SYSTEMS.md +1 -1
- package/docs/IMAGE_GENERATION.md +82 -1
- package/docs/IMPLEMENTATION_SUMMARY.md +544 -533
- package/docs/QUICKSTART.md +41 -1
- package/docs/README.md +19 -13
- package/docs/ROADMAP.md +10 -11
- package/docs/SPECIFICATION.md +37 -14
- package/docs/SYSTEMS_REASONING.md +35 -11
- package/docs/bakery_logo.png +0 -0
- package/docs/coffee_mug.png +0 -0
- package/docs/desk_lamp.png +0 -0
- package/docs/logo.png +0 -0
- package/docs/notebook.png +0 -0
- package/docs/sesi_ai_chronicles.md +209 -0
- package/examples/16_modules.sesi +28 -0
- package/examples/17_http_client.sesi +29 -0
- package/examples/18_parallel_requests.sesi +37 -0
- package/main/chatbot.sesi +36 -0
- package/main/conversational_classifier_weights.json +45 -0
- package/main/conversational_sentences.json +304 -0
- package/main/epochs.sesi +94 -0
- package/main/gpu_orchestrator.sesi +36 -0
- package/main/hardware_diagnostics.sesi +118 -0
- package/main/inference.sesi +54 -0
- package/main/native_chatbot.sesi +180 -0
- package/main/native_synthesizer.sesi +83 -0
- package/main/nn_personas_trainer.sesi +302 -0
- package/main/nn_responses_trainer.sesi +269 -0
- package/main/nn_sentences_trainer.sesi +330 -0
- package/main/personas.json +124 -0
- package/main/personas_classifier_weights.json +45 -0
- package/main/playground.sesi +3 -1
- package/main/predictive_typing.sesi +127 -0
- package/main/query_brain.sesi +45 -0
- package/main/response_classifier_weights.json +45 -0
- package/main/retro_chat.html +239 -0
- package/main/retro_chat_generator.sesi +745 -0
- package/main/sesi_ai.sesi +158 -0
- package/main/sesi_db_chatbot.sesi +261 -0
- package/main/terminal_chat.py +385 -0
- package/main/tests/temp_math_mod.sesi +3 -0
- package/main/tests/test_image_input.sesi +40 -0
- package/main/tests/test_v2_features.sesi +48 -0
- package/main/unified_sesi_ai.sesi +334 -0
- package/main/varied_responses.json +304 -0
- package/package.json +11 -5
- package/main/atm_deposit.sesi +0 -37
- package/main/atm_withdraw.sesi +0 -37
- package/main/data.txt +0 -1
- package/main/math_aggregator.sesi +0 -15
- package/main/math_generator.sesi +0 -7
- package/main/math_processor.sesi +0 -23
- package/main/tax_calculator.sesi +0 -15
- package/main/vault.sesi +0 -15
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import random
|
|
3
|
+
import time
|
|
4
|
+
import sys
|
|
5
|
+
import math
|
|
6
|
+
|
|
7
|
+
# Force system stdout to use UTF-8 encoding to prevent Windows cp1252 character maps exceptions
|
|
8
|
+
try:
|
|
9
|
+
sys.stdout.reconfigure(encoding='utf-8')
|
|
10
|
+
except Exception:
|
|
11
|
+
pass
|
|
12
|
+
|
|
13
|
+
# Color codes for terminal aesthetics
|
|
14
|
+
RESET = "\033[0m"
|
|
15
|
+
BOLD = "\033[1m"
|
|
16
|
+
GREEN = "\033[32m"
|
|
17
|
+
CYAN = "\033[36m"
|
|
18
|
+
MAGENTA = "\033[35m"
|
|
19
|
+
YELLOW = "\033[33m"
|
|
20
|
+
BLUE = "\033[34m"
|
|
21
|
+
RED = "\033[31m"
|
|
22
|
+
WHITE = "\033[37m"
|
|
23
|
+
|
|
24
|
+
# HSL-aligned color palette for terminal visual excellence
|
|
25
|
+
COLOR_AUDIO = CYAN
|
|
26
|
+
COLOR_MECH = YELLOW
|
|
27
|
+
COLOR_SYS = MAGENTA
|
|
28
|
+
|
|
29
|
+
VOCAB = ["synthesizer", "vinyl", "record", "wood", "gears", "clock", "compiler", "framework", "memory", "offline"]
|
|
30
|
+
CLASSES = ["audio", "mechanical", "systems"]
|
|
31
|
+
|
|
32
|
+
def print_ascii_header():
|
|
33
|
+
print(BOLD + CYAN + "======================================================================" + RESET)
|
|
34
|
+
print(BOLD + BLUE + " [NEURAL] SESI NATIVELY NEURAL-EMPATHETIC TERMINAL CHAT REPL v4.0" + RESET)
|
|
35
|
+
print(BOLD + CYAN + "======================================================================" + RESET)
|
|
36
|
+
print(WHITE + "Welcome, Operator! Interactive neural dial-in gateway is online.")
|
|
37
|
+
print("Zero-shot character bios trained offline. Synapses fully operational.\n" + RESET)
|
|
38
|
+
|
|
39
|
+
def get_persona_category(persona):
|
|
40
|
+
desc = (persona["personality"] + " " + persona["tone"]).lower()
|
|
41
|
+
audio_keys = ["synthesizer", "jazz", "music", "audio", "chiptune", "beatmaker", "record"]
|
|
42
|
+
mech_keys = ["wood", "furniture", "watch", "clock", "gears", "game boy", "botanist", "architect"]
|
|
43
|
+
|
|
44
|
+
for k in audio_keys:
|
|
45
|
+
if k in desc:
|
|
46
|
+
return "audio"
|
|
47
|
+
for k in mech_keys:
|
|
48
|
+
if k in desc:
|
|
49
|
+
return "mechanical"
|
|
50
|
+
return "systems"
|
|
51
|
+
|
|
52
|
+
def build_markov_brain(category, responses):
|
|
53
|
+
# Slice the 300 varied responses based on category pool
|
|
54
|
+
if category == "audio":
|
|
55
|
+
corpus_responses = responses[0:100]
|
|
56
|
+
elif category == "mechanical":
|
|
57
|
+
corpus_responses = responses[100:200]
|
|
58
|
+
else:
|
|
59
|
+
corpus_responses = responses[200:300]
|
|
60
|
+
|
|
61
|
+
full_text = " ".join(corpus_responses)
|
|
62
|
+
words = full_text.split()
|
|
63
|
+
w_len = len(words)
|
|
64
|
+
|
|
65
|
+
transitions = {}
|
|
66
|
+
for i in range(w_len - 1):
|
|
67
|
+
w1 = words[i]
|
|
68
|
+
w2 = words[i+1]
|
|
69
|
+
if w1 not in transitions:
|
|
70
|
+
transitions[w1] = []
|
|
71
|
+
transitions[w1].append(w2)
|
|
72
|
+
|
|
73
|
+
return transitions, words, w_len
|
|
74
|
+
|
|
75
|
+
def walk_complete_sentence_penalized(transitions, words_list, c_len, start_word):
|
|
76
|
+
current_word = start_word
|
|
77
|
+
sentence = [current_word.capitalize()]
|
|
78
|
+
history = [current_word]
|
|
79
|
+
steps = 1
|
|
80
|
+
max_steps = 22
|
|
81
|
+
|
|
82
|
+
while steps < max_steps:
|
|
83
|
+
if current_word.endswith((".", "!", "?")):
|
|
84
|
+
break
|
|
85
|
+
|
|
86
|
+
choices = transitions.get(current_word, [])
|
|
87
|
+
next_word = ""
|
|
88
|
+
|
|
89
|
+
if not choices:
|
|
90
|
+
# Fallback: select random non-repeating word from vocab list
|
|
91
|
+
attempts = 0
|
|
92
|
+
found_candidate = False
|
|
93
|
+
while attempts < 15:
|
|
94
|
+
candidate = random.choice(words_list)
|
|
95
|
+
if candidate not in history[-15:]:
|
|
96
|
+
next_word = candidate
|
|
97
|
+
found_candidate = True
|
|
98
|
+
break
|
|
99
|
+
attempts += 1
|
|
100
|
+
if not found_candidate:
|
|
101
|
+
next_word = random.choice(words_list)
|
|
102
|
+
else:
|
|
103
|
+
# Select transition choice with 15-word lookback & bigram blocking
|
|
104
|
+
attempts = 0
|
|
105
|
+
found_candidate = False
|
|
106
|
+
while attempts < 20:
|
|
107
|
+
candidate = random.choice(choices)
|
|
108
|
+
is_repeat = False
|
|
109
|
+
|
|
110
|
+
# 1. 15-word lookback window check
|
|
111
|
+
if candidate in history[-15:]:
|
|
112
|
+
is_repeat = True
|
|
113
|
+
|
|
114
|
+
# 2. Strict Bigram Blocking check
|
|
115
|
+
if not is_repeat:
|
|
116
|
+
for b_idx in range(len(history) - 1):
|
|
117
|
+
p1 = history[b_idx]
|
|
118
|
+
p2 = history[b_idx + 1]
|
|
119
|
+
if p1 == current_word and p2 == candidate:
|
|
120
|
+
is_repeat = True
|
|
121
|
+
break
|
|
122
|
+
|
|
123
|
+
if not is_repeat:
|
|
124
|
+
next_word = candidate
|
|
125
|
+
found_candidate = True
|
|
126
|
+
break
|
|
127
|
+
attempts += 1
|
|
128
|
+
|
|
129
|
+
if not found_candidate:
|
|
130
|
+
next_word = random.choice(choices)
|
|
131
|
+
|
|
132
|
+
sentence.append(next_word)
|
|
133
|
+
history.append(next_word)
|
|
134
|
+
current_word = next_word
|
|
135
|
+
steps += 1
|
|
136
|
+
|
|
137
|
+
result = " ".join(sentence)
|
|
138
|
+
if not result.endswith((".", "!", "?")):
|
|
139
|
+
result += "."
|
|
140
|
+
return result
|
|
141
|
+
|
|
142
|
+
def predict_neural_class(user_msg, weights, biases):
|
|
143
|
+
# Normalize input and extract features
|
|
144
|
+
words = [w.lower().replace(".", "").replace("!", "").replace("?", "").strip() for w in user_msg.split()]
|
|
145
|
+
x = [0.0] * len(VOCAB)
|
|
146
|
+
for i, keyword in enumerate(VOCAB):
|
|
147
|
+
if keyword in words:
|
|
148
|
+
x[i] = 1.0
|
|
149
|
+
|
|
150
|
+
# Matrix vector multiplication
|
|
151
|
+
outputs = [0.0] * len(CLASSES)
|
|
152
|
+
for c in range(len(CLASSES)):
|
|
153
|
+
val = biases[c]
|
|
154
|
+
for i in range(len(VOCAB)):
|
|
155
|
+
val += x[i] * weights[c][i]
|
|
156
|
+
outputs[c] = val
|
|
157
|
+
|
|
158
|
+
# Softmax probabilities
|
|
159
|
+
try:
|
|
160
|
+
e_x = [math.exp(v) for v in outputs]
|
|
161
|
+
sum_e_x = sum(e_x)
|
|
162
|
+
probs = [v / sum_e_x for v in e_x]
|
|
163
|
+
except Exception:
|
|
164
|
+
probs = [0.33, 0.33, 0.33]
|
|
165
|
+
|
|
166
|
+
max_idx = probs.index(max(probs))
|
|
167
|
+
return CLASSES[max_idx], probs
|
|
168
|
+
|
|
169
|
+
def render_probability_bars(probs):
|
|
170
|
+
bar_len = 16
|
|
171
|
+
out_lines = []
|
|
172
|
+
colors = [COLOR_AUDIO, COLOR_MECH, COLOR_SYS]
|
|
173
|
+
labels = ["AUDIO ", "MECH ", "SYSTEM"]
|
|
174
|
+
|
|
175
|
+
for i in range(3):
|
|
176
|
+
p = probs[i]
|
|
177
|
+
filled = int(round(p * bar_len))
|
|
178
|
+
bar = "█" * filled + "▒" * (bar_len - filled)
|
|
179
|
+
pct = p * 100.0
|
|
180
|
+
out_lines.append(f" {colors[i]}[ {labels[i]} {bar} ({pct:5.1f}%) ]{RESET}")
|
|
181
|
+
return "\n".join(out_lines)
|
|
182
|
+
|
|
183
|
+
# Dynamic Varied Empathetic Prefix Dictionary to prevent prefix loops
|
|
184
|
+
EMPATHETIC_VARIATIONS = {
|
|
185
|
+
# Match cases
|
|
186
|
+
("audio", "audio"): [
|
|
187
|
+
"The resonant audio waves strike a deep harmonic balance in my core! ",
|
|
188
|
+
"Your rhythmic frequency perfectly matches my acoustic focus! ",
|
|
189
|
+
"That statement vibrates at exactly the right pitch and groove! ",
|
|
190
|
+
"A beautiful sonic resonance aligns our conversational pathways here! "
|
|
191
|
+
],
|
|
192
|
+
("mechanical", "mechanical"): [
|
|
193
|
+
"The precise physical alignments of your statement click together like a masterfully crafted gear! ",
|
|
194
|
+
"Your words have absolute structural integrity, locked in perfect spatial precision! ",
|
|
195
|
+
"That fits flawlessly, like a fine gemstone fitted into a museum timepiece escapement! ",
|
|
196
|
+
"A magnificent mechanical cohesion! Every segment of your logic is perfectly synced! "
|
|
197
|
+
],
|
|
198
|
+
("systems", "systems"): [
|
|
199
|
+
"Your structural logic converges warning-free under our tight memory constraints! ",
|
|
200
|
+
"A clean thread execution! Your statement optimizes perfectly in-memory! ",
|
|
201
|
+
"Highly optimized telemetry! Your logic compiles with zero friction! ",
|
|
202
|
+
"That is an exceptionally clean, low-latency construct you have deployed! "
|
|
203
|
+
],
|
|
204
|
+
|
|
205
|
+
# Mismatch cases (bridges)
|
|
206
|
+
# Native: audio
|
|
207
|
+
("audio", "mechanical"): [
|
|
208
|
+
"Just like the gears of a mechanical clock, the tape reels of my vintage tape recorder rotate in perfect synchronization! ",
|
|
209
|
+
"While you describe physical structures, I hear them as rhythmic acoustic spacing and mechanical beats! ",
|
|
210
|
+
"Bridging physical leverage to acoustic latency: mechanical ticking is just natural chiptune rhythm! "
|
|
211
|
+
],
|
|
212
|
+
("audio", "systems"): [
|
|
213
|
+
"Just like a compiled systems loop, a rhythmic audio sample loops indefinitely without latency! ",
|
|
214
|
+
"Routing database streams feels a lot like managing discrete sound waves through a digital synthesizer! ",
|
|
215
|
+
"Systems architectures and audio tracks both require low latency and high-fidelity routing! "
|
|
216
|
+
],
|
|
217
|
+
|
|
218
|
+
# Native: mechanical
|
|
219
|
+
("mechanical", "audio"): [
|
|
220
|
+
"Just like the rhythmic beats of a synthesizer, the repeating ticks of my mechanical escapement keep perfect physical timing! ",
|
|
221
|
+
"I can translate that musical groove into physical rotational kinetic energy! ",
|
|
222
|
+
"Acoustic waveforms have their own beautiful geometry, just like the teeth of fine wooden gears! "
|
|
223
|
+
],
|
|
224
|
+
("mechanical", "systems"): [
|
|
225
|
+
"Just like a warning-free software compiler, the carefully cut wood gears of my mechanical clock require absolute structural precision! ",
|
|
226
|
+
"Software compilers build virtual structures, but watchmaking builds them in physical memory! ",
|
|
227
|
+
"Tight constraints are physical to me: gears must mesh with absolute zero margin of code error! "
|
|
228
|
+
],
|
|
229
|
+
|
|
230
|
+
# Native: systems
|
|
231
|
+
("systems", "audio"): [
|
|
232
|
+
"Just like a resonant audio sound wave, a high-performance database queries and reverberates in perfect memory synchronization! ",
|
|
233
|
+
"Acoustic channels are just low-level physical packet networks carrying complex waveforms! ",
|
|
234
|
+
"Your rhythmic tone maps perfectly to an optimized circular array buffer processing data! "
|
|
235
|
+
],
|
|
236
|
+
("systems", "mechanical"): [
|
|
237
|
+
"Just like the physical leverage of mechanical gears, our system compilers leverage low-level pointers to optimize execution speed! ",
|
|
238
|
+
"Mechanical segments translate beautifully to hardware memory addresses and clock cycles! ",
|
|
239
|
+
"I bridge physical wood structures to logical system memory layouts: both require absolute architecture! "
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
def get_empathetic_prefix(partner_native, predicted):
|
|
244
|
+
key = (partner_native, predicted)
|
|
245
|
+
if key in EMPATHETIC_VARIATIONS:
|
|
246
|
+
choices = EMPATHETIC_VARIATIONS[key]
|
|
247
|
+
return random.choice(choices)
|
|
248
|
+
return ""
|
|
249
|
+
|
|
250
|
+
def main():
|
|
251
|
+
# 1. Load Persona Database
|
|
252
|
+
try:
|
|
253
|
+
with open("main/personas.json", "r") as f:
|
|
254
|
+
parsed_personas = json.load(f)
|
|
255
|
+
personas = parsed_personas["personas"]
|
|
256
|
+
except Exception as e:
|
|
257
|
+
print(RED + "Error: Failed to load main/personas.json!" + RESET)
|
|
258
|
+
return
|
|
259
|
+
|
|
260
|
+
# 2. Load Responses Corpus
|
|
261
|
+
try:
|
|
262
|
+
with open("main/varied_responses.json", "r") as f:
|
|
263
|
+
parsed_responses = json.load(f)
|
|
264
|
+
responses = parsed_responses["responses"]
|
|
265
|
+
except Exception as e:
|
|
266
|
+
print(RED + "Error: Failed to load main/varied_responses.json!" + RESET)
|
|
267
|
+
return
|
|
268
|
+
|
|
269
|
+
# 3. Load Calibrated Neural Weights
|
|
270
|
+
try:
|
|
271
|
+
with open("main/response_classifier_weights.json", "r") as f:
|
|
272
|
+
weights_data = json.load(f)
|
|
273
|
+
weights = weights_data["weights"]
|
|
274
|
+
biases = weights_data["biases"]
|
|
275
|
+
except Exception as e:
|
|
276
|
+
print(RED + "Error: Failed to load main/response_classifier_weights.json!" + RESET)
|
|
277
|
+
print("Please train your response classifier weights first by running the Sesi trainer!")
|
|
278
|
+
return
|
|
279
|
+
|
|
280
|
+
print_ascii_header()
|
|
281
|
+
|
|
282
|
+
# 4. Print beautiful interactive directory
|
|
283
|
+
print(BOLD + WHITE + "[ DIRECTORY ] AVAILABLE CONVERSATIONAL EXPERTS:" + RESET)
|
|
284
|
+
print(BLUE + "-" * 70 + RESET)
|
|
285
|
+
for i, p in enumerate(personas):
|
|
286
|
+
cat = get_persona_category(p)
|
|
287
|
+
if cat == "audio":
|
|
288
|
+
color = COLOR_AUDIO
|
|
289
|
+
elif cat == "mechanical":
|
|
290
|
+
color = COLOR_MECH
|
|
291
|
+
else:
|
|
292
|
+
color = COLOR_SYS
|
|
293
|
+
|
|
294
|
+
print(f"[{BOLD}{i:2d}{RESET}] {color}{p['name']:22s}{RESET} (Age: {p['age']}) [{BOLD}{cat.upper()}{RESET}]")
|
|
295
|
+
print(BLUE + "-" * 70 + RESET)
|
|
296
|
+
|
|
297
|
+
# 5. User selection loop
|
|
298
|
+
while True:
|
|
299
|
+
try:
|
|
300
|
+
choice = input(BOLD + WHITE + "\n>> Select persona number [0-19]: " + RESET).strip()
|
|
301
|
+
if choice.lower() == "exit":
|
|
302
|
+
print("Goodbye!")
|
|
303
|
+
return
|
|
304
|
+
idx = int(choice)
|
|
305
|
+
if 0 <= idx < len(personas):
|
|
306
|
+
partner = personas[idx]
|
|
307
|
+
break
|
|
308
|
+
else:
|
|
309
|
+
print(RED + "Please enter a valid index between 0 and 19." + RESET)
|
|
310
|
+
except ValueError:
|
|
311
|
+
print(RED + "Please enter a numeric index." + RESET)
|
|
312
|
+
|
|
313
|
+
# 6. Initialize dynamic neural brains
|
|
314
|
+
partner_native = get_persona_category(partner)
|
|
315
|
+
partner_color = COLOR_AUDIO if partner_native == "audio" else (COLOR_MECH if partner_native == "mechanical" else COLOR_SYS)
|
|
316
|
+
|
|
317
|
+
print(BOLD + "\n[+] LOADING CALIBRATED 10x3 NEURAL WEIGHTS...")
|
|
318
|
+
time.sleep(0.4)
|
|
319
|
+
print(GREEN + "[ok] Synapses calibrated. Initializing speech transitions..." + RESET)
|
|
320
|
+
|
|
321
|
+
# Pre-build vocabulary brains for all 3 categories dynamically
|
|
322
|
+
brains = {
|
|
323
|
+
"audio": build_markov_brain("audio", responses),
|
|
324
|
+
"mechanical": build_markov_brain("mechanical", responses),
|
|
325
|
+
"systems": build_markov_brain("systems", responses)
|
|
326
|
+
}
|
|
327
|
+
time.sleep(0.4)
|
|
328
|
+
print(GREEN + "[ok] All vocabulary matrices mapped. Speech brain active!\n" + RESET)
|
|
329
|
+
|
|
330
|
+
print("=" * 70)
|
|
331
|
+
print(f"[ONLINE] {BOLD}{partner['name']}{RESET} (Age: {partner['age']}) is ONLINE!")
|
|
332
|
+
print(f"[CLASS] {BOLD}Personality Class:{RESET} {partner_color}{partner_native.upper()}{RESET}")
|
|
333
|
+
print(f"[BIO] {BOLD}Bio Description:{RESET} {partner['personality']}")
|
|
334
|
+
print(f"[TONE] {BOLD}Conversational Tone:{RESET} {partner['tone']}")
|
|
335
|
+
print(BOLD + WHITE + "Type your message below! Type 'exit' or 'quit' to shut down connection." + RESET)
|
|
336
|
+
print("=" * 70 + "\n")
|
|
337
|
+
|
|
338
|
+
# 7. Interactive Neural-Empathetic Loop
|
|
339
|
+
while True:
|
|
340
|
+
try:
|
|
341
|
+
user_msg = input(BOLD + WHITE + "You: " + RESET).strip()
|
|
342
|
+
if not user_msg:
|
|
343
|
+
continue
|
|
344
|
+
|
|
345
|
+
if user_msg.lower() in ["exit", "quit", "close"]:
|
|
346
|
+
print(BOLD + BLUE + f"\n[!] Terminating connection with {partner['name']}. Offline gateway closed. Goodbye!\n" + RESET)
|
|
347
|
+
break
|
|
348
|
+
|
|
349
|
+
# A. Execute Neural Classification
|
|
350
|
+
predicted_class, probs = predict_neural_class(user_msg, weights, biases)
|
|
351
|
+
|
|
352
|
+
# Print visually outstanding probability bars
|
|
353
|
+
print(BOLD + BLUE + "\n[ NEURAL RESPONSE CLASSIFICATION ]" + RESET)
|
|
354
|
+
print(render_probability_bars(probs))
|
|
355
|
+
print(BOLD + BLUE + f"[ ROUTING COGNITIVE FLOW -> {predicted_class.upper()} CLASS ]\n" + RESET)
|
|
356
|
+
time.sleep(0.2)
|
|
357
|
+
|
|
358
|
+
# B. Morph Speech Brain dynamically (Cognitive Resonance!)
|
|
359
|
+
transitions, words_list, c_len = brains[predicted_class]
|
|
360
|
+
|
|
361
|
+
# C. Extract matching vocabulary seeds to trigger speech
|
|
362
|
+
user_words = [w.lower().replace(".", "").replace("!", "").replace("?", "") for w in user_msg.split()]
|
|
363
|
+
matched_words = [w for w in user_words if w in transitions]
|
|
364
|
+
|
|
365
|
+
if matched_words:
|
|
366
|
+
start_word = random.choice(matched_words)
|
|
367
|
+
else:
|
|
368
|
+
start_word = random.choice(words_list)
|
|
369
|
+
|
|
370
|
+
# D. Synthesize loop-free, penalized sentence reply
|
|
371
|
+
reply_sentence = walk_complete_sentence_penalized(transitions, words_list, c_len, start_word)
|
|
372
|
+
|
|
373
|
+
# E. Prepend Neural Empathy Bridge Prefix
|
|
374
|
+
empathetic_prefix = get_empathetic_prefix(partner_native, predicted_class)
|
|
375
|
+
full_reply = empathetic_prefix + reply_sentence
|
|
376
|
+
|
|
377
|
+
# Print stylized character dialogue
|
|
378
|
+
print(BOLD + partner_color + f"{partner['name']}: " + RESET + full_reply + "\n")
|
|
379
|
+
|
|
380
|
+
except KeyboardInterrupt:
|
|
381
|
+
print(BOLD + BLUE + f"\n[!] Terminating connection with {partner['name']}. Offline gateway closed. Goodbye!\n" + RESET)
|
|
382
|
+
break
|
|
383
|
+
|
|
384
|
+
if __name__ == "__main__":
|
|
385
|
+
main()
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
print "=== Image Input Tests ==="
|
|
2
|
+
print ""
|
|
3
|
+
print "Test 1: Single image (literal path)..."
|
|
4
|
+
try
|
|
5
|
+
{let result = model("gemini-3-flash-preview") {images: "docs/logo.png"} {"In one sentence, describe the dominant shape and color in this image."}
|
|
6
|
+
print "PASS — model() single image:"
|
|
7
|
+
print result
|
|
8
|
+
} catch (e) {print "FAIL — Test 1 error:"
|
|
9
|
+
print e}
|
|
10
|
+
print ""
|
|
11
|
+
print "Test 2: Single image (variable path)..."
|
|
12
|
+
try
|
|
13
|
+
{let imgPath = "docs/logo.png"
|
|
14
|
+
let reading = model("gemini-3-flash-preview") {images: imgPath} {"What text, if any, is visible in this image? Reply in one line."}
|
|
15
|
+
print "PASS — model() variable path:"
|
|
16
|
+
print reading
|
|
17
|
+
} catch (e) {print "FAIL — Test 2 error:"
|
|
18
|
+
print e}
|
|
19
|
+
print ""
|
|
20
|
+
print "Test 3: Multiple images (array)..."
|
|
21
|
+
try
|
|
22
|
+
{let shots = ["docs/logo.png", "docs/logo.png"]
|
|
23
|
+
let comparison = model("gemini-3-flash-preview") {images: shots} {"Are these two images identical? Answer yes or no and give one reason."}
|
|
24
|
+
print "PASS — model() array of images:"
|
|
25
|
+
print comparison
|
|
26
|
+
} catch (e)
|
|
27
|
+
{print "FAIL — Test 3 error:"
|
|
28
|
+
print e}
|
|
29
|
+
print ""
|
|
30
|
+
print "Test 4: images combined with temperature and max_tokens..."
|
|
31
|
+
try
|
|
32
|
+
{let ref = "docs/logo.png"
|
|
33
|
+
let analysis = model("gemini-3.1-flash-lite") {images: ref, temperature: 0, max_tokens: 128} {"What programming language or brand does this logo represent? One word answer."}
|
|
34
|
+
print "PASS — model() with mixed config:"
|
|
35
|
+
print analysis
|
|
36
|
+
} catch (e)
|
|
37
|
+
{print "FAIL — Test 4 error:"
|
|
38
|
+
print e}
|
|
39
|
+
print ""
|
|
40
|
+
print "=== All image input tests complete ==="
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Sesi Native V2.0 Upgrades Test Script
|
|
2
|
+
|
|
3
|
+
print "=== 1. Testing Standard Math Module (std/math) ==="
|
|
4
|
+
import { PI, sqrt, pow } from "std/math"
|
|
5
|
+
print "PI:" + str(PI)
|
|
6
|
+
print "sqrt(100):" + str(sqrt(100))
|
|
7
|
+
print "pow(3, 3):" + str(pow(3, 3))
|
|
8
|
+
|
|
9
|
+
print "\n=== 2. Testing Standard JSON Module (std/json) ==="
|
|
10
|
+
import { stringify, parse } from "std/json"
|
|
11
|
+
let data = { "message": "hello from native Sesi", "code": 200 }
|
|
12
|
+
let serialized = stringify(data)
|
|
13
|
+
print "Serialized JSON:" + serialized
|
|
14
|
+
let parsed = parse(serialized)
|
|
15
|
+
print "Parsed Message:" + parsed["message"]
|
|
16
|
+
|
|
17
|
+
print "\n=== 3. Testing HTTP Client web_get ==="
|
|
18
|
+
let response = web_get("https://jsonplaceholder.typicode.com/posts/1")
|
|
19
|
+
print "Fetched Title:" + parse(response)["title"]
|
|
20
|
+
|
|
21
|
+
print "\n=== 4. Testing Concurrency with multi_req ==="
|
|
22
|
+
import { sleep, now } from "std/time"
|
|
23
|
+
|
|
24
|
+
fn job1() {
|
|
25
|
+
sleep(100)
|
|
26
|
+
return "job1_done"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
fn job2() {
|
|
30
|
+
sleep(100)
|
|
31
|
+
return "job2_done"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let start_t = now()
|
|
35
|
+
let parallel_results = multi_req([job1, job2])
|
|
36
|
+
let elapsed = now() - start_t
|
|
37
|
+
|
|
38
|
+
print "Parallel Results:" + str(parallel_results)
|
|
39
|
+
print "Elapsed time for parallel jobs:" + str(elapsed) + "ms"
|
|
40
|
+
|
|
41
|
+
print "\n=== 5. Testing Executable Sesi Module Import/Export ==="
|
|
42
|
+
// Note: Since importing relative path loads and interprets that module,
|
|
43
|
+
// we will import our helper module "tests/temp_math_mod".
|
|
44
|
+
// First, the host test runner will write the temp module file, or we can write a let binding check.
|
|
45
|
+
import { magic_number } from "tests/temp_math_mod"
|
|
46
|
+
print "Imported magic number from local module:" + str(magic_number)
|
|
47
|
+
|
|
48
|
+
print "\n=== All Native Sesi Tests Completed Successfully! ==="
|