@misterscan/sesi 1.2.0 → 1.2.2
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/bin/sesi.js +3 -3
- package/dist/ai-runtime.d.ts.map +1 -1
- package/dist/ai-runtime.js +11 -3
- package/dist/ai-runtime.js.map +1 -1
- package/dist/builtins.d.ts.map +1 -1
- package/dist/builtins.js +6 -1
- package/dist/builtins.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/interpreter.d.ts +10 -1
- package/dist/interpreter.d.ts.map +1 -1
- package/dist/interpreter.js +62 -10
- package/dist/interpreter.js.map +1 -1
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +8 -0
- package/dist/parser.js.map +1 -1
- package/dist/sesi.bundled.js +498 -385
- package/docs/ARCHITECTURE.md +1 -1
- package/docs/BUILTINS.md +62 -1
- package/docs/IMAGE_GENERATION.md +3 -3
- package/docs/README.md +8 -8
- package/docs/SKILLS.md +133 -0
- package/docs/SPECIFICATION.md +75 -19
- package/docs/SYSTEMS_REASONING.md +22 -22
- package/docs/favicon.ico +0 -0
- package/examples/16_modules.sesi +1 -1
- package/main/sesi_db_chatbot.sesi +280 -261
- package/main/start.sesi +1 -1
- package/main/terminal.log +56 -0
- package/main/unified_sesi_ai.sesi +1 -1
- package/package.json +20 -14
|
@@ -1,261 +1,280 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
print "=================================================="
|
|
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
|
-
if word == "
|
|
58
|
-
if word == "
|
|
59
|
-
if word == "
|
|
60
|
-
if word == "
|
|
61
|
-
if word == "
|
|
62
|
-
if word == "
|
|
63
|
-
if word == "
|
|
64
|
-
if word == "
|
|
65
|
-
if word == "
|
|
66
|
-
if word == "
|
|
67
|
-
if word == "
|
|
68
|
-
if word == "
|
|
69
|
-
if word == "
|
|
70
|
-
if word == "
|
|
71
|
-
if word == "
|
|
72
|
-
if word == "
|
|
73
|
-
if word == "
|
|
74
|
-
if word == "
|
|
75
|
-
if word == "
|
|
76
|
-
if word == "
|
|
77
|
-
if word == "
|
|
78
|
-
if word == "
|
|
79
|
-
if word == "
|
|
80
|
-
if word == "
|
|
81
|
-
if word == "
|
|
82
|
-
if word == "
|
|
83
|
-
if word == "
|
|
84
|
-
if word == "
|
|
85
|
-
if word == "
|
|
86
|
-
if word == "
|
|
87
|
-
if word == "
|
|
88
|
-
if word == "
|
|
89
|
-
if word == "
|
|
90
|
-
if word == "
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
let
|
|
160
|
-
while
|
|
161
|
-
let
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
1
|
+
// Dynamically indexes the sesi-db knowledge base, trains on-the-fly, and answers queries!
|
|
2
|
+
|
|
3
|
+
// ==================================================
|
|
4
|
+
// 💬 1. CHOOSE YOUR ADVANCED TECHNICAL QUERY HERE!
|
|
5
|
+
// (Test it with custom phrases containing our keywords!)
|
|
6
|
+
let queryText = "how do I parse a json string?"
|
|
7
|
+
try {
|
|
8
|
+
queryText = read_file("query.txt")
|
|
9
|
+
} catch (e) {}
|
|
10
|
+
// ==================================================
|
|
11
|
+
|
|
12
|
+
print "=================================================="
|
|
13
|
+
print "🧠 WELCOME TO THE SESI CO-PILOT!"
|
|
14
|
+
print "=================================================="
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
// Maintains context across multiple queries so the co-pilot remembers what you previously asked.
|
|
18
|
+
memory chatHistory {"You are the Sesi Co-Pilot, an expert assistant for the Sesi programming language. You help users write correct, idiomatic Sesi code. Be concise and conversational."}
|
|
19
|
+
|
|
20
|
+
// Load persisted history from disk if it exists
|
|
21
|
+
try {
|
|
22
|
+
chatHistory = read_file("sesi-db/chat_history.txt")
|
|
23
|
+
print "📝 Loaded previous conversation context."
|
|
24
|
+
} catch (e) {}
|
|
25
|
+
|
|
26
|
+
// Auto-summarize when history gets too long (saves tokens)
|
|
27
|
+
fn summarizeHistory() {
|
|
28
|
+
let summary = model("gemini-3.1-flash-lite") {"temperature": 0, "max_tokens": 300} {"Summarize this conversation history into key facts and context. Be very concise: " chatHistory}
|
|
29
|
+
chatHistory = "Previous conversation summary: " + summary
|
|
30
|
+
print "🗜️ Memory auto-summarized to save tokens."
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Sigmoid math
|
|
34
|
+
fn activate(x) {
|
|
35
|
+
return 1.0 / (1.0 + exp(0.0 - x))
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
fn derivative(y) {
|
|
39
|
+
return y * (1.0 - y)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// 2. Advanced Bag-of-Words Vectorizer (49 keywords covering all Sesi primitives & built-ins)
|
|
43
|
+
fn vectorize(text) {
|
|
44
|
+
let words = split(text, " ")
|
|
45
|
+
|
|
46
|
+
// Dynamically initialize 49-dimensional vector
|
|
47
|
+
let vec = []
|
|
48
|
+
let k = 0
|
|
49
|
+
while k < 49 {
|
|
50
|
+
push(vec, 0.0)
|
|
51
|
+
k = k + 1
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let w = 0
|
|
55
|
+
while w < len(words) {
|
|
56
|
+
let word = words[w]
|
|
57
|
+
if word == "print" { vec[0] = 1.0 }
|
|
58
|
+
if word == "str" { vec[1] = 1.0 }
|
|
59
|
+
if word == "type" { vec[2] = 1.0 }
|
|
60
|
+
if word == "num" { vec[3] = 1.0 }
|
|
61
|
+
if word == "bool" { vec[4] = 1.0 }
|
|
62
|
+
if word == "json" { vec[5] = 1.0 }
|
|
63
|
+
if word == "from_json" { vec[6] = 1.0 }
|
|
64
|
+
if word == "to_json" { vec[7] = 1.0 }
|
|
65
|
+
if word == "len" { vec[8] = 1.0 }
|
|
66
|
+
if word == "file" { vec[9] = 1.0 }
|
|
67
|
+
if word == "read_file" { vec[10] = 1.0 }
|
|
68
|
+
if word == "write_file" { vec[11] = 1.0 }
|
|
69
|
+
if word == "dir" { vec[12] = 1.0 }
|
|
70
|
+
if word == "list_dir" { vec[13] = 1.0 }
|
|
71
|
+
if word == "make_dir" { vec[14] = 1.0 }
|
|
72
|
+
if word == "exp" { vec[15] = 1.0 }
|
|
73
|
+
if word == "random" { vec[16] = 1.0 }
|
|
74
|
+
if word == "let" { vec[17] = 1.0 }
|
|
75
|
+
if word == "const" { vec[18] = 1.0 }
|
|
76
|
+
if word == "fn" { vec[19] = 1.0 }
|
|
77
|
+
if word == "if" { vec[20] = 1.0 }
|
|
78
|
+
if word == "else" { vec[21] = 1.0 }
|
|
79
|
+
if word == "while" { vec[22] = 1.0 }
|
|
80
|
+
if word == "for" { vec[23] = 1.0 }
|
|
81
|
+
if word == "return" { vec[24] = 1.0 }
|
|
82
|
+
if word == "break" { vec[25] = 1.0 }
|
|
83
|
+
if word == "continue" { vec[26] = 1.0 }
|
|
84
|
+
if word == "try" { vec[27] = 1.0 }
|
|
85
|
+
if word == "catch" { vec[28] = 1.0 }
|
|
86
|
+
if word == "import" { vec[29] = 1.0 }
|
|
87
|
+
if word == "export" { vec[30] = 1.0 }
|
|
88
|
+
if word == "memory" { vec[31] = 1.0 }
|
|
89
|
+
if word == "sleep" { vec[32] = 1.0 }
|
|
90
|
+
if word == "now" { vec[33] = 1.0 }
|
|
91
|
+
if word == "model" { vec[34] = 1.0 }
|
|
92
|
+
if word == "image" { vec[35] = 1.0 }
|
|
93
|
+
if word == "structured_output" { vec[36] = 1.0 }
|
|
94
|
+
if word == "tool_call" { vec[37] = 1.0 }
|
|
95
|
+
if word == "spawn" { vec[38] = 1.0 }
|
|
96
|
+
if word == "exec" { vec[39] = 1.0 }
|
|
97
|
+
if word == "time" { vec[40] = 1.0 }
|
|
98
|
+
if word == "range" { vec[41] = 1.0 }
|
|
99
|
+
if word == "push" { vec[42] = 1.0 }
|
|
100
|
+
if word == "pop" { vec[43] = 1.0 }
|
|
101
|
+
if word == "join" { vec[44] = 1.0 }
|
|
102
|
+
if word == "split" { vec[45] = 1.0 }
|
|
103
|
+
if word == "keys" { vec[46] = 1.0 }
|
|
104
|
+
if word == "values" { vec[47] = 1.0 }
|
|
105
|
+
if word == "array" { vec[48] = 1.0 }
|
|
106
|
+
w = w + 1
|
|
107
|
+
}
|
|
108
|
+
return vec
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
let db_files = list_dir("sesi-db")
|
|
112
|
+
let num_classes = len(db_files)
|
|
113
|
+
|
|
114
|
+
if num_classes == 0 {
|
|
115
|
+
print "⚠️ Database is empty! Run 'sesi indexer.sesi' first!"
|
|
116
|
+
} else {
|
|
117
|
+
print "✅ Found " + str(num_classes) + " knowledge documents in sesi-db!"
|
|
118
|
+
|
|
119
|
+
let database = []
|
|
120
|
+
let inputs = []
|
|
121
|
+
let targets = []
|
|
122
|
+
|
|
123
|
+
let i = 0
|
|
124
|
+
while i < num_classes {
|
|
125
|
+
let f = db_files[i]
|
|
126
|
+
let raw = read_file("sesi-db/" + f)
|
|
127
|
+
let parsed = from_json(raw)
|
|
128
|
+
|
|
129
|
+
// Combine summary and rules for training text
|
|
130
|
+
let doc_text = parsed["summary"] + " " + parsed["key_rules"]
|
|
131
|
+
let vec = vectorize(doc_text)
|
|
132
|
+
push(inputs, vec)
|
|
133
|
+
|
|
134
|
+
// Create one-hot targets dynamically
|
|
135
|
+
let t = []
|
|
136
|
+
let t_idx = 0
|
|
137
|
+
while t_idx < num_classes {
|
|
138
|
+
if t_idx == i {
|
|
139
|
+
push(t, 1.0)
|
|
140
|
+
} else {
|
|
141
|
+
push(t, 0.0)
|
|
142
|
+
}
|
|
143
|
+
t_idx = t_idx + 1
|
|
144
|
+
}
|
|
145
|
+
push(targets, t)
|
|
146
|
+
push(database, parsed)
|
|
147
|
+
|
|
148
|
+
i = i + 1
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// 4. Dynamic Multi-Class Weights Matrix Initialization
|
|
152
|
+
let weights = []
|
|
153
|
+
let biases = []
|
|
154
|
+
|
|
155
|
+
let c = 0
|
|
156
|
+
while c < num_classes {
|
|
157
|
+
// Initialize random-seeded weights between -0.2 and 0.2
|
|
158
|
+
let w_row = []
|
|
159
|
+
let k = 0
|
|
160
|
+
while k < 49 {
|
|
161
|
+
let r_val = (random() * 0.4) - 0.2
|
|
162
|
+
push(w_row, r_val)
|
|
163
|
+
k = k + 1
|
|
164
|
+
}
|
|
165
|
+
push(weights, w_row)
|
|
166
|
+
push(biases, 0.0)
|
|
167
|
+
c = c + 1
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// 5. Run dynamic multi-class gradient descent training loop (2,000 epochs)
|
|
171
|
+
let lr = 0.5
|
|
172
|
+
let epoch = 1
|
|
173
|
+
while epoch <= 2000 {
|
|
174
|
+
let c = 0
|
|
175
|
+
while c < num_classes {
|
|
176
|
+
let x = inputs[c]
|
|
177
|
+
let t = targets[c]
|
|
178
|
+
|
|
179
|
+
// Forward propagation (dynamic dot product)
|
|
180
|
+
let sum = 0.0
|
|
181
|
+
let w_row = weights[c]
|
|
182
|
+
let k = 0
|
|
183
|
+
while k < 49 {
|
|
184
|
+
sum = sum + (x[k] * w_row[k])
|
|
185
|
+
k = k + 1
|
|
186
|
+
}
|
|
187
|
+
let o = activate(sum + biases[c])
|
|
188
|
+
|
|
189
|
+
// Backpropagation delta
|
|
190
|
+
let delta = (t[c] - o) * derivative(o)
|
|
191
|
+
|
|
192
|
+
// Synaptic updates
|
|
193
|
+
k = 0
|
|
194
|
+
while k < 49 {
|
|
195
|
+
w_row[k] = w_row[k] + (lr * delta * x[k])
|
|
196
|
+
k = k + 1
|
|
197
|
+
}
|
|
198
|
+
biases[c] = biases[c] + (lr * delta)
|
|
199
|
+
|
|
200
|
+
c = c + 1
|
|
201
|
+
}
|
|
202
|
+
epoch = epoch + 1
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
let query_vec = vectorize(queryText)
|
|
206
|
+
|
|
207
|
+
// Forward propagation on user query across all dynamic classes
|
|
208
|
+
let outputs = []
|
|
209
|
+
let j = 0
|
|
210
|
+
while j < num_classes {
|
|
211
|
+
let sum = 0.0
|
|
212
|
+
let w_row = weights[j]
|
|
213
|
+
let k = 0
|
|
214
|
+
while k < 49 {
|
|
215
|
+
sum = sum + (query_vec[k] * w_row[k])
|
|
216
|
+
k = k + 1
|
|
217
|
+
}
|
|
218
|
+
let o = activate(sum + biases[j])
|
|
219
|
+
push(outputs, o)
|
|
220
|
+
j = j + 1
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Determine class index with highest score
|
|
224
|
+
let best_class = 0
|
|
225
|
+
let max_score = -1.0
|
|
226
|
+
let j = 0
|
|
227
|
+
while j < num_classes {
|
|
228
|
+
if outputs[j] > max_score {
|
|
229
|
+
max_score = outputs[j]
|
|
230
|
+
best_class = j
|
|
231
|
+
}
|
|
232
|
+
j = j + 1
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// 7. Output Dynamic Recommendation with Confidence Thresholding
|
|
236
|
+
print "--------------------------------------------------"
|
|
237
|
+
print "🤖 SESI CO-PILOT RESPONDING:"
|
|
238
|
+
print "--------------------------------------------------"
|
|
239
|
+
if max_score < 0.40 {
|
|
240
|
+
print "🤔 Sesi's native synapses evaluated this query with low confidence: " + str(max_score)
|
|
241
|
+
print " It seems your question does not contain any Sesi keywords in our vocabulary!"
|
|
242
|
+
print " Please try asking about: 'print', 'str', 'files', 'json', 'model', 'image', or 'random'!"
|
|
243
|
+
} else {
|
|
244
|
+
let rec = database[best_class]
|
|
245
|
+
let docs_list = list_dir("docs")
|
|
246
|
+
let sesiDocs = ""
|
|
247
|
+
let d = 0
|
|
248
|
+
while d < len(docs_list) {
|
|
249
|
+
let f_name = docs_list[d]
|
|
250
|
+
let parts = split(f_name, ".")
|
|
251
|
+
let ext = parts[len(parts) - 1]
|
|
252
|
+
|
|
253
|
+
if ext == "md" {
|
|
254
|
+
let doc_content = read_file("docs/" + f_name)
|
|
255
|
+
sesiDocs = sesiDocs + "\n\n=== DOCUMENT: " + f_name + " ===\n" + doc_content
|
|
256
|
+
}
|
|
257
|
+
d = d + 1
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Auto-summarize if history exceeds ~3000 characters
|
|
261
|
+
if len(chatHistory) > 3000 {
|
|
262
|
+
summarizeHistory()
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
let ragPrompt = "Conversation History:\n" + chatHistory + "\n\nSesi Official Reference Documentation:\n" + sesiDocs + "\n\nUser Query: " + queryText + "\n\nMatched Context from Sesi DB:\nSummary: " + rec["summary"] + "\nKey Rules: " + rec["key_rules"] + "\n\nInstructions: Write a direct, beautiful, highly conversational response to the user's question using strictly the matched rules. Walk them through Sesi's syntax with direct examples. Be helpful and concise. Do not mention that you got this from a database—act as a supportive code copilot. Reference any relevant prior conversation context when applicable."
|
|
266
|
+
|
|
267
|
+
let generated_response = model("gemini-3.1-flash-lite") {"temperature": 0.3, "max_tokens": 200} {ragPrompt}
|
|
268
|
+
|
|
269
|
+
// Append this turn to conversational memory
|
|
270
|
+
chatHistory = chatHistory + "\nUser: " + queryText + "\nAssistant: " + generated_response
|
|
271
|
+
|
|
272
|
+
// Persist memory to disk for next session
|
|
273
|
+
try {
|
|
274
|
+
write_file("sesi-db/chat_history.txt", chatHistory)
|
|
275
|
+
} catch (e) {}
|
|
276
|
+
|
|
277
|
+
print "--------------------------------------------------"
|
|
278
|
+
print generated_response
|
|
279
|
+
print "--------------------------------------------------"
|
|
280
|
+
}}
|
package/main/start.sesi
CHANGED
|
@@ -9,5 +9,5 @@ print "Math check:" a + b
|
|
|
9
9
|
|
|
10
10
|
// Or jump straight into reasoning tasks
|
|
11
11
|
let topic = "building a new programming language"
|
|
12
|
-
let response = model("gemini-3.
|
|
12
|
+
let response = model("gemini-3.5-flash") {thinkingLevel: "minimal"} {"Write a motivational 2-sentence intro about" topic}
|
|
13
13
|
print "Sesi:" response
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
PS C:\Users\owner\Documents\Sesi> sesi -h i need an image and metadata for my album release
|
|
2
|
+
⟐ injected env (1) from .env · dotenvx@1.66.0
|
|
3
|
+
==================================================
|
|
4
|
+
🧠 WELCOME TO THE SESI CO-PILOT!
|
|
5
|
+
==================================================
|
|
6
|
+
--------------------------------------------------
|
|
7
|
+
🤖 SESI CO-PILOT RESPONDING:
|
|
8
|
+
--------------------------------------------------
|
|
9
|
+
Generating an image and extracting metadata for your album release is incredibly straightforward in Sesi. Because Sesi treats AI as a native language primitive, you don't need to worry about SDKs, manual JSON parsing, or complex schema boilerplate.
|
|
10
|
+
|
|
11
|
+
Here is how you can handle your album release pipeline in just a few lines of code:
|
|
12
|
+
|
|
13
|
+
### 1. Generate Your Album Art
|
|
14
|
+
You can use the native `image` primitive to generate your cover art. Sesi handles the base64 encoding and file persistence automatically.
|
|
15
|
+
|
|
16
|
+
```sesi
|
|
17
|
+
// Generate the image with specific configuration
|
|
18
|
+
let coverArt = image("gemini-3.1-flash-image-preview") {
|
|
19
|
+
"ratio": "1:1",
|
|
20
|
+
"size": "1K",
|
|
21
|
+
"temperature": 0.5
|
|
22
|
+
} {"A minimalist, atmospheric album cover for a synth-pop release"}
|
|
23
|
+
|
|
24
|
+
// Save it directly to disk
|
|
25
|
+
write_image("album_cover.png", coverArt)
|
|
26
|
+
print "Album art saved successfully!"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### 2. Extract Album Metadata
|
|
30
|
+
Instead of manually defining complex schemas or parsing JSON, you can use `structured_output` to get typed metadata directly from the model. Sesi dynamically builds the schema from your object literal and handles the hydration for you.
|
|
31
|
+
|
|
32
|
+
```sesi
|
|
33
|
+
// Define your metadata needs and extract them in one go
|
|
34
|
+
let albumInfo = structured_output({
|
|
35
|
+
title: string,
|
|
36
|
+
artist: string,
|
|
37
|
+
genre: string,
|
|
38
|
+
releaseYear: number
|
|
39
|
+
})(model("gemini-3.1-flash-lite") {
|
|
40
|
+
"Extract album metadata from this description: 'The new 2026 synth-pop album Neon Nights by Luna Ray'"
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
// Access the data as native Sesi objects
|
|
44
|
+
print "Title:" albumInfo["title"]
|
|
45
|
+
print "Artist:" albumInfo["artist"]
|
|
46
|
+
print "Genre:" albumInfo["genre"]
|
|
47
|
+
print "Year:" albumInfo["releaseYear"]
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Why this is better:
|
|
51
|
+
* **No Boilerplate:** You didn't have to import a single SDK or manually define a JSON schema.
|
|
52
|
+
* **Native Types:** The `albumInfo` variable is immediately ready to use as a native Sesi object.
|
|
53
|
+
* **Resilient:** If the model's output is slightly malformed, Sesi's runtime handles the recovery and coercion for you automatically.
|
|
54
|
+
|
|
55
|
+
You’re all set to build out the rest of your release pipeline! Let me know if you need help adding logic to automatically upload these files or notify your team.
|
|
56
|
+
--------------------------------------------------
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// ==================================================
|
|
7
7
|
// 💬 1. CHOOSE YOUR ADVANCED TECHNICAL QUERY HERE!
|
|
8
8
|
// (Trained keywords: print, str, type, num, bool, json, convert, array, len, file, write, dir, exp, random)
|
|
9
|
-
let queryText = "how do i convert
|
|
9
|
+
let queryText = "how do i convert integer to string?"
|
|
10
10
|
// ==================================================
|
|
11
11
|
|
|
12
12
|
print "=================================================="
|