@aivue/tabular-intelligence 1.3.1 → 1.3.5
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/dist/composables/useTabularIntelligence.d.ts.map +1 -1
- package/dist/index.js +26 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +389 -349
- package/dist/index.mjs.map +1 -1
- package/dist/tabular-intelligence.css +1 -1
- package/package.json +1 -2
package/dist/index.mjs
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
function
|
|
1
|
+
import { ref as D, defineComponent as U, createElementBlock as p, openBlock as g, createElementVNode as h, createCommentVNode as q, withDirectives as ee, withKeys as L, withModifiers as H, vModelText as te, toDisplayString as k, normalizeClass as ne, createTextVNode as se, Fragment as Q, renderList as j, computed as ae } from "vue";
|
|
2
|
+
function N(c, e) {
|
|
3
3
|
if (c.length === 0)
|
|
4
4
|
return { columns: [], rowCount: 0, name: e };
|
|
5
5
|
const t = c[0];
|
|
6
6
|
return {
|
|
7
7
|
columns: Object.keys(t).map((s) => {
|
|
8
|
-
const a =
|
|
8
|
+
const a = O(c, s);
|
|
9
9
|
return {
|
|
10
10
|
name: s,
|
|
11
11
|
type: a,
|
|
12
|
-
nullable: c.some((
|
|
12
|
+
nullable: c.some((o) => o[s] == null)
|
|
13
13
|
};
|
|
14
14
|
}),
|
|
15
15
|
rowCount: c.length,
|
|
16
16
|
name: e
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function O(c, e) {
|
|
20
20
|
const t = c.map((s) => s[e]).filter((s) => s != null);
|
|
21
21
|
if (t.length === 0) return "string";
|
|
22
22
|
if (t.every((s) => typeof s == "number" || !isNaN(Number(s))))
|
|
@@ -28,59 +28,59 @@ function L(c, e) {
|
|
|
28
28
|
const n = new Set(t);
|
|
29
29
|
return n.size < t.length * 0.5 && n.size < 20 ? "categorical" : "string";
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
const n = c.map((
|
|
31
|
+
function J(c, e, t) {
|
|
32
|
+
const n = c.map((r) => r[e]).filter((r) => r != null), s = n.length, a = c.length - s, o = {
|
|
33
33
|
column: e,
|
|
34
34
|
count: s,
|
|
35
35
|
nullCount: a
|
|
36
36
|
};
|
|
37
37
|
if (t === "number") {
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
const i = [...
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
38
|
+
const r = n.map(Number).filter((i) => !isNaN(i));
|
|
39
|
+
if (r.length > 0) {
|
|
40
|
+
const i = [...r].sort((f, d) => f - d), l = r.reduce((f, d) => f + d, 0);
|
|
41
|
+
o.mean = l / r.length, o.median = i[Math.floor(i.length / 2)], o.min = i[0], o.max = i[i.length - 1];
|
|
42
|
+
const w = r.reduce((f, d) => f + Math.pow(d - o.mean, 2), 0) / r.length;
|
|
43
|
+
o.std = Math.sqrt(w), o.percentiles = {
|
|
44
44
|
25: i[Math.floor(i.length * 0.25)],
|
|
45
|
-
50:
|
|
45
|
+
50: o.median,
|
|
46
46
|
75: i[Math.floor(i.length * 0.75)],
|
|
47
47
|
90: i[Math.floor(i.length * 0.9)]
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
} else {
|
|
51
|
-
const
|
|
52
|
-
|
|
51
|
+
const r = new Set(n);
|
|
52
|
+
o.uniqueValues = r.size;
|
|
53
53
|
const i = {};
|
|
54
|
-
n.forEach((
|
|
55
|
-
const
|
|
56
|
-
i[
|
|
54
|
+
n.forEach((w) => {
|
|
55
|
+
const f = String(w);
|
|
56
|
+
i[f] = (i[f] || 0) + 1;
|
|
57
57
|
});
|
|
58
58
|
const l = Math.max(...Object.values(i));
|
|
59
|
-
|
|
59
|
+
o.mode = Object.keys(i).find((w) => i[w] === l);
|
|
60
60
|
}
|
|
61
|
-
return
|
|
61
|
+
return o;
|
|
62
62
|
}
|
|
63
|
-
function
|
|
63
|
+
function re(c, e, t = 0.5) {
|
|
64
64
|
const n = [], s = 1.5 + (1 - t) * 1.5;
|
|
65
65
|
return e.forEach((a) => {
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
if (
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
rowIndex:
|
|
74
|
-
row: c[
|
|
66
|
+
const o = c.map((y, A) => ({ value: Number(y[a]), idx: A })).filter((y) => !isNaN(y.value));
|
|
67
|
+
if (o.length === 0) return;
|
|
68
|
+
const r = [...o].sort((y, A) => y.value - A.value), i = r[Math.floor(r.length * 0.25)].value, l = r[Math.floor(r.length * 0.75)].value, w = l - i, f = i - s * w, d = l + s * w;
|
|
69
|
+
o.forEach(({ value: y, idx: A }) => {
|
|
70
|
+
if (y < f || y > d) {
|
|
71
|
+
const _ = n.find((T) => T.rowIndex === A), x = y < f ? `${a}: ${y.toFixed(2)} < ${f.toFixed(2)}` : `${a}: ${y.toFixed(2)} > ${d.toFixed(2)}`;
|
|
72
|
+
_ ? (_.reasons.push(x), _.affectedColumns.push(a), _.score = Math.min(1, _.score + 0.2)) : n.push({
|
|
73
|
+
rowIndex: A,
|
|
74
|
+
row: c[A],
|
|
75
75
|
score: 0.7,
|
|
76
|
-
reasons: [
|
|
76
|
+
reasons: [x],
|
|
77
77
|
affectedColumns: [a]
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
|
-
}), n.sort((a,
|
|
81
|
+
}), n.sort((a, o) => o.score - a.score);
|
|
82
82
|
}
|
|
83
|
-
class
|
|
83
|
+
class B {
|
|
84
84
|
constructor(e) {
|
|
85
85
|
this.config = {
|
|
86
86
|
maxTokens: 1e3,
|
|
@@ -94,9 +94,9 @@ class U {
|
|
|
94
94
|
async answerQuestion(e) {
|
|
95
95
|
const t = Date.now();
|
|
96
96
|
try {
|
|
97
|
-
const { question: n, schema: s, data: a = [], sampleSize:
|
|
97
|
+
const { question: n, schema: s, data: a = [], sampleSize: o = 100, includeAggregates: r = !0 } = e, i = a.length > o ? this.sampleData(a, o) : a, l = r ? this.calculateAggregates(a, s) : void 0, w = this.buildPrompt(n, s, i, l, a.length), f = await this.callLLM(w);
|
|
98
98
|
return {
|
|
99
|
-
answer: this.parseResponse(
|
|
99
|
+
answer: this.parseResponse(f, n, a.length > o),
|
|
100
100
|
processingTime: Date.now() - t
|
|
101
101
|
};
|
|
102
102
|
} catch (n) {
|
|
@@ -132,7 +132,7 @@ class U {
|
|
|
132
132
|
for (const s of t.columns)
|
|
133
133
|
if (s.type === "number" && e.length > 0)
|
|
134
134
|
try {
|
|
135
|
-
const a =
|
|
135
|
+
const a = J(e, s.name, "number");
|
|
136
136
|
n[s.name] = {
|
|
137
137
|
mean: a.mean,
|
|
138
138
|
median: a.median,
|
|
@@ -143,9 +143,9 @@ class U {
|
|
|
143
143
|
} catch {
|
|
144
144
|
}
|
|
145
145
|
else if (s.type === "categorical" || s.type === "string") {
|
|
146
|
-
const a = e.map((
|
|
146
|
+
const a = e.map((r) => r[s.name]).filter((r) => r != null), o = new Set(a);
|
|
147
147
|
n[s.name] = {
|
|
148
|
-
uniqueCount:
|
|
148
|
+
uniqueCount: o.size,
|
|
149
149
|
totalCount: a.length,
|
|
150
150
|
topValues: this.getTopValues(a, 5)
|
|
151
151
|
};
|
|
@@ -165,51 +165,51 @@ class U {
|
|
|
165
165
|
* Build prompt for LLM
|
|
166
166
|
*/
|
|
167
167
|
buildPrompt(e, t, n, s, a) {
|
|
168
|
-
const
|
|
169
|
-
let
|
|
168
|
+
const o = a && a > n.length;
|
|
169
|
+
let r = `You are a data analyst assistant. Answer the following question about a table dataset.
|
|
170
170
|
|
|
171
171
|
`;
|
|
172
|
-
|
|
173
|
-
`,
|
|
174
|
-
`,
|
|
172
|
+
r += `**Table Schema:**
|
|
173
|
+
`, r += `Table: ${t.name}
|
|
174
|
+
`, r += `Columns:
|
|
175
175
|
`;
|
|
176
176
|
for (const i of t.columns)
|
|
177
|
-
|
|
177
|
+
r += `- ${i.name} (${i.type})
|
|
178
178
|
`;
|
|
179
|
-
return
|
|
180
|
-
`, s && Object.keys(s).length > 0 && (
|
|
181
|
-
`,
|
|
179
|
+
return r += `
|
|
180
|
+
`, s && Object.keys(s).length > 0 && (r += `**Summary Statistics:**
|
|
181
|
+
`, r += JSON.stringify(s, null, 2), r += `
|
|
182
182
|
|
|
183
|
-
`),
|
|
184
|
-
`,
|
|
183
|
+
`), r += `**Sample Data** (${n.length} rows${o ? ` out of ${a} total` : ""}):
|
|
184
|
+
`, r += JSON.stringify(n.slice(0, 10), null, 2), r += `
|
|
185
185
|
|
|
186
|
-
`,
|
|
186
|
+
`, r += `**Question:** ${e}
|
|
187
187
|
|
|
188
|
-
`,
|
|
189
|
-
`,
|
|
190
|
-
`,
|
|
191
|
-
`,
|
|
192
|
-
`,
|
|
193
|
-
`,
|
|
194
|
-
`,
|
|
195
|
-
`,
|
|
196
|
-
`,
|
|
197
|
-
`,
|
|
198
|
-
`,
|
|
199
|
-
`,
|
|
200
|
-
`,
|
|
201
|
-
`,
|
|
202
|
-
`,
|
|
188
|
+
`, r += `**Instructions:**
|
|
189
|
+
`, r += `1. Answer ONLY based on the data provided above.
|
|
190
|
+
`, r += `2. If the question cannot be answered from the available data, clearly state "I cannot answer this question from the available data" and explain why.
|
|
191
|
+
`, r += `3. Provide a clear, concise answer.
|
|
192
|
+
`, r += `4. Include specific numbers or examples from the data when relevant.
|
|
193
|
+
`, r += `5. If the answer is based on sampled data, mention that it's an approximation.
|
|
194
|
+
`, r += `6. Format your response as JSON with the following structure:
|
|
195
|
+
`, r += `{
|
|
196
|
+
`, r += ` "answer": "Your answer text here",
|
|
197
|
+
`, r += ` "confidence": 0.0-1.0,
|
|
198
|
+
`, r += ` "cannotAnswer": false,
|
|
199
|
+
`, r += ` "isApproximate": ${o},
|
|
200
|
+
`, r += ` "supportingData": { "key": "value" } // optional
|
|
201
|
+
`, r += `}
|
|
202
|
+
`, r;
|
|
203
203
|
}
|
|
204
204
|
/**
|
|
205
205
|
* Call LLM API
|
|
206
206
|
*/
|
|
207
207
|
async callLLM(e) {
|
|
208
|
-
const { provider: t, apiKey: n, baseUrl: s, model: a, maxTokens:
|
|
208
|
+
const { provider: t, apiKey: n, baseUrl: s, model: a, maxTokens: o, temperature: r } = this.config;
|
|
209
209
|
if (t === "openai")
|
|
210
|
-
return this.callOpenAI(e, n, a || "gpt-4-turbo-preview",
|
|
210
|
+
return this.callOpenAI(e, n, a || "gpt-4-turbo-preview", o, r);
|
|
211
211
|
if (t === "anthropic")
|
|
212
|
-
return this.callAnthropic(e, n, a || "claude-3-5-sonnet-20241022",
|
|
212
|
+
return this.callAnthropic(e, n, a || "claude-3-5-sonnet-20241022", o, r);
|
|
213
213
|
if (t === "custom" && s)
|
|
214
214
|
return this.callCustomAPI(e, s, n);
|
|
215
215
|
throw new Error(`Unsupported provider: ${t}`);
|
|
@@ -219,7 +219,7 @@ class U {
|
|
|
219
219
|
*/
|
|
220
220
|
async callOpenAI(e, t, n, s, a) {
|
|
221
221
|
var i, l;
|
|
222
|
-
const
|
|
222
|
+
const o = await fetch("https://api.openai.com/v1/chat/completions", {
|
|
223
223
|
method: "POST",
|
|
224
224
|
headers: {
|
|
225
225
|
"Content-Type": "application/json",
|
|
@@ -233,16 +233,16 @@ class U {
|
|
|
233
233
|
response_format: { type: "json_object" }
|
|
234
234
|
})
|
|
235
235
|
});
|
|
236
|
-
if (!
|
|
237
|
-
throw new Error(`OpenAI API error: ${
|
|
238
|
-
return ((l = (i = (await
|
|
236
|
+
if (!o.ok)
|
|
237
|
+
throw new Error(`OpenAI API error: ${o.statusText}`);
|
|
238
|
+
return ((l = (i = (await o.json()).choices[0]) == null ? void 0 : i.message) == null ? void 0 : l.content) || "";
|
|
239
239
|
}
|
|
240
240
|
/**
|
|
241
241
|
* Call Anthropic API
|
|
242
242
|
*/
|
|
243
243
|
async callAnthropic(e, t, n, s, a) {
|
|
244
244
|
var i;
|
|
245
|
-
const
|
|
245
|
+
const o = await fetch("https://api.anthropic.com/v1/messages", {
|
|
246
246
|
method: "POST",
|
|
247
247
|
headers: {
|
|
248
248
|
"Content-Type": "application/json",
|
|
@@ -256,9 +256,9 @@ class U {
|
|
|
256
256
|
messages: [{ role: "user", content: e }]
|
|
257
257
|
})
|
|
258
258
|
});
|
|
259
|
-
if (!
|
|
260
|
-
throw new Error(`Anthropic API error: ${
|
|
261
|
-
return ((i = (await
|
|
259
|
+
if (!o.ok)
|
|
260
|
+
throw new Error(`Anthropic API error: ${o.statusText}`);
|
|
261
|
+
return ((i = (await o.json()).content[0]) == null ? void 0 : i.text) || "";
|
|
262
262
|
}
|
|
263
263
|
/**
|
|
264
264
|
* Call custom API
|
|
@@ -275,8 +275,8 @@ class U {
|
|
|
275
275
|
});
|
|
276
276
|
if (!a.ok)
|
|
277
277
|
throw new Error(`Custom API error: ${a.statusText}`);
|
|
278
|
-
const
|
|
279
|
-
return
|
|
278
|
+
const o = await a.json();
|
|
279
|
+
return o.response || o.answer || JSON.stringify(o);
|
|
280
280
|
}
|
|
281
281
|
/**
|
|
282
282
|
* Parse LLM response
|
|
@@ -318,78 +318,78 @@ function oe(c = {}) {
|
|
|
318
318
|
maxRows: n,
|
|
319
319
|
inferTypes: s = !0,
|
|
320
320
|
skipEmptyRows: a = !0
|
|
321
|
-
} = c,
|
|
322
|
-
if (!
|
|
321
|
+
} = c, o = document.querySelector(e);
|
|
322
|
+
if (!o || o.tagName !== "TABLE")
|
|
323
323
|
return console.warn(`No table found with selector: ${e}`), null;
|
|
324
|
-
const i = Array.from(
|
|
324
|
+
const i = Array.from(o.rows);
|
|
325
325
|
if (i.length === 0)
|
|
326
326
|
return null;
|
|
327
|
-
let l = [],
|
|
327
|
+
let l = [], w = 0;
|
|
328
328
|
if (t && i[0]) {
|
|
329
|
-
const
|
|
330
|
-
l = Array.from(
|
|
331
|
-
var
|
|
332
|
-
return ((
|
|
333
|
-
}),
|
|
329
|
+
const A = i[0];
|
|
330
|
+
l = Array.from(A.cells).map((_, x) => {
|
|
331
|
+
var E;
|
|
332
|
+
return ((E = _.textContent) == null ? void 0 : E.trim()) || "" || `Column${x + 1}`;
|
|
333
|
+
}), w = 1;
|
|
334
334
|
} else {
|
|
335
|
-
const
|
|
336
|
-
l = Array.from(
|
|
335
|
+
const A = i[0];
|
|
336
|
+
l = Array.from(A.cells).map((_, x) => `Column${x + 1}`);
|
|
337
337
|
}
|
|
338
|
-
const
|
|
339
|
-
for (const
|
|
340
|
-
const
|
|
341
|
-
if (a &&
|
|
342
|
-
var
|
|
343
|
-
return !((
|
|
338
|
+
const f = [], d = n ? i.slice(w, w + n) : i.slice(w);
|
|
339
|
+
for (const A of d) {
|
|
340
|
+
const _ = Array.from(A.cells);
|
|
341
|
+
if (a && _.every((T) => {
|
|
342
|
+
var E;
|
|
343
|
+
return !((E = T.textContent) != null && E.trim());
|
|
344
344
|
}))
|
|
345
345
|
continue;
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
var
|
|
349
|
-
const
|
|
350
|
-
let
|
|
351
|
-
if (s &&
|
|
352
|
-
const
|
|
353
|
-
!isNaN(
|
|
346
|
+
const x = {};
|
|
347
|
+
_.forEach((T, E) => {
|
|
348
|
+
var z;
|
|
349
|
+
const F = l[E] || `Column${E + 1}`;
|
|
350
|
+
let I = ((z = T.textContent) == null ? void 0 : z.trim()) || "";
|
|
351
|
+
if (s && I) {
|
|
352
|
+
const M = parseFloat(I);
|
|
353
|
+
!isNaN(M) && I === M.toString() && (I = M);
|
|
354
354
|
}
|
|
355
|
-
|
|
356
|
-
}),
|
|
355
|
+
x[F] = I;
|
|
356
|
+
}), f.push(x);
|
|
357
357
|
}
|
|
358
358
|
return {
|
|
359
|
-
schema: s &&
|
|
360
|
-
data:
|
|
359
|
+
schema: s && f.length > 0 ? N(f, "Extracted Table") : ce(l, f.length),
|
|
360
|
+
data: f,
|
|
361
361
|
source: "dom",
|
|
362
362
|
metadata: {
|
|
363
363
|
selector: e,
|
|
364
|
-
rowCount:
|
|
364
|
+
rowCount: f.length,
|
|
365
365
|
columnCount: l.length,
|
|
366
366
|
extractedAt: /* @__PURE__ */ new Date()
|
|
367
367
|
}
|
|
368
368
|
};
|
|
369
369
|
}
|
|
370
|
-
function
|
|
370
|
+
function ie(c, e, t = {}) {
|
|
371
371
|
const { maxRows: n, inferTypes: s = !0 } = t, a = n ? c.slice(0, n) : c;
|
|
372
|
-
let
|
|
373
|
-
return e && e.length > 0 ?
|
|
372
|
+
let o;
|
|
373
|
+
return e && e.length > 0 ? o = {
|
|
374
374
|
name: "Vue Data Grid",
|
|
375
|
-
columns: e.map((
|
|
376
|
-
name:
|
|
377
|
-
type: s && a.length > 0 ?
|
|
375
|
+
columns: e.map((r) => ({
|
|
376
|
+
name: r.field,
|
|
377
|
+
type: s && a.length > 0 ? O(a, r.field) : "string",
|
|
378
378
|
nullable: !0
|
|
379
379
|
})),
|
|
380
380
|
rowCount: a.length
|
|
381
|
-
} : a.length > 0 ?
|
|
382
|
-
schema:
|
|
381
|
+
} : a.length > 0 ? o = N(a, "Vue Data Grid") : o = { name: "Vue Data Grid", columns: [], rowCount: 0 }, {
|
|
382
|
+
schema: o,
|
|
383
383
|
data: a,
|
|
384
384
|
source: "vue",
|
|
385
385
|
metadata: {
|
|
386
386
|
rowCount: a.length,
|
|
387
|
-
columnCount:
|
|
387
|
+
columnCount: o.columns.length,
|
|
388
388
|
extractedAt: /* @__PURE__ */ new Date()
|
|
389
389
|
}
|
|
390
390
|
};
|
|
391
391
|
}
|
|
392
|
-
function
|
|
392
|
+
function ce(c, e = 0) {
|
|
393
393
|
return {
|
|
394
394
|
name: "Extracted Table",
|
|
395
395
|
columns: c.map((t) => ({
|
|
@@ -400,15 +400,15 @@ function ie(c, e = 0) {
|
|
|
400
400
|
rowCount: e
|
|
401
401
|
};
|
|
402
402
|
}
|
|
403
|
-
function
|
|
403
|
+
function le(c) {
|
|
404
404
|
const e = {};
|
|
405
405
|
c.variable && c.variable.forEach((a) => {
|
|
406
406
|
e[a.key] = a.value;
|
|
407
407
|
});
|
|
408
|
-
const t = c.auth ?
|
|
409
|
-
function s(a,
|
|
410
|
-
a.forEach((
|
|
411
|
-
|
|
408
|
+
const t = c.auth ? K(c.auth) : void 0, n = [];
|
|
409
|
+
function s(a, o = "") {
|
|
410
|
+
a.forEach((r) => {
|
|
411
|
+
r.item ? s(r.item, o ? `${o}/${r.name}` : r.name) : r.request && n.push(ue(r, t));
|
|
412
412
|
});
|
|
413
413
|
}
|
|
414
414
|
return s(c.item), {
|
|
@@ -419,16 +419,16 @@ function ce(c) {
|
|
|
419
419
|
auth: t
|
|
420
420
|
};
|
|
421
421
|
}
|
|
422
|
-
function
|
|
422
|
+
function ue(c, e) {
|
|
423
423
|
const t = c.request, n = {};
|
|
424
|
-
t.header && t.header.forEach((
|
|
425
|
-
n[
|
|
424
|
+
t.header && t.header.forEach((o) => {
|
|
425
|
+
n[o.key] = o.value;
|
|
426
426
|
});
|
|
427
427
|
const s = {};
|
|
428
|
-
t.url.query && t.url.query.forEach((
|
|
429
|
-
s[
|
|
428
|
+
t.url.query && t.url.query.forEach((o) => {
|
|
429
|
+
s[o.key] = o.value;
|
|
430
430
|
});
|
|
431
|
-
const a = t.auth ?
|
|
431
|
+
const a = t.auth ? K(t.auth) : e;
|
|
432
432
|
return {
|
|
433
433
|
name: c.name,
|
|
434
434
|
method: t.method,
|
|
@@ -439,7 +439,7 @@ function le(c, e) {
|
|
|
439
439
|
auth: a
|
|
440
440
|
};
|
|
441
441
|
}
|
|
442
|
-
function
|
|
442
|
+
function K(c) {
|
|
443
443
|
const e = {};
|
|
444
444
|
return c.apikey ? c.apikey.forEach((t) => {
|
|
445
445
|
e[t.key] = t.value;
|
|
@@ -452,54 +452,54 @@ function B(c) {
|
|
|
452
452
|
credentials: e
|
|
453
453
|
};
|
|
454
454
|
}
|
|
455
|
-
function
|
|
455
|
+
function P(c, e) {
|
|
456
456
|
let t = c;
|
|
457
457
|
return Object.keys(e).forEach((n) => {
|
|
458
458
|
const s = new RegExp(`{{${n}}}`, "g");
|
|
459
459
|
t = t.replace(s, e[n]);
|
|
460
460
|
}), t;
|
|
461
461
|
}
|
|
462
|
-
async function
|
|
462
|
+
async function G(c) {
|
|
463
463
|
const { endpoint: e, variables: t = {}, additionalHeaders: n = {}, additionalParams: s = {} } = c;
|
|
464
464
|
try {
|
|
465
|
-
let a =
|
|
466
|
-
const
|
|
467
|
-
|
|
465
|
+
let a = P(e.url, t);
|
|
466
|
+
const o = { ...e.queryParams, ...t, ...s }, r = Object.keys(o).filter((d) => o[d] !== void 0 && o[d] !== "").map((d) => `${encodeURIComponent(d)}=${encodeURIComponent(P(String(o[d]), t))}`).join("&");
|
|
467
|
+
r && (a = a.includes("?") ? `${a}&${r}` : `${a}?${r}`);
|
|
468
468
|
const i = {
|
|
469
469
|
"Content-Type": "application/json",
|
|
470
470
|
...e.headers,
|
|
471
471
|
...n
|
|
472
472
|
};
|
|
473
|
-
if (Object.keys(i).forEach((
|
|
474
|
-
i[
|
|
473
|
+
if (Object.keys(i).forEach((d) => {
|
|
474
|
+
i[d] = P(i[d], t);
|
|
475
475
|
}), e.auth) {
|
|
476
476
|
if (e.auth.type === "apikey") {
|
|
477
|
-
const
|
|
478
|
-
e.auth.credentials.in === "header" && (i[
|
|
477
|
+
const d = e.auth.credentials.key || "access_key", y = P(e.auth.credentials.value || "", t);
|
|
478
|
+
e.auth.credentials.in === "header" && (i[d] = y);
|
|
479
479
|
} else if (e.auth.type === "bearer") {
|
|
480
|
-
const
|
|
481
|
-
i.Authorization = `Bearer ${
|
|
480
|
+
const d = P(e.auth.credentials.token || "", t);
|
|
481
|
+
i.Authorization = `Bearer ${d}`;
|
|
482
482
|
} else if (e.auth.type === "basic") {
|
|
483
|
-
const
|
|
484
|
-
i.Authorization = `Basic ${
|
|
483
|
+
const d = P(e.auth.credentials.username || "", t), y = P(e.auth.credentials.password || "", t), A = btoa(`${d}:${y}`);
|
|
484
|
+
i.Authorization = `Basic ${A}`;
|
|
485
485
|
}
|
|
486
486
|
}
|
|
487
487
|
const l = await fetch(a, {
|
|
488
488
|
method: e.method,
|
|
489
489
|
headers: i
|
|
490
|
-
}),
|
|
491
|
-
return l.headers.forEach((
|
|
492
|
-
|
|
490
|
+
}), w = {};
|
|
491
|
+
return l.headers.forEach((d, y) => {
|
|
492
|
+
w[y] = d;
|
|
493
493
|
}), l.ok ? {
|
|
494
494
|
success: !0,
|
|
495
495
|
data: await l.json(),
|
|
496
496
|
statusCode: l.status,
|
|
497
|
-
headers:
|
|
497
|
+
headers: w
|
|
498
498
|
} : {
|
|
499
499
|
success: !1,
|
|
500
500
|
error: `HTTP ${l.status}: ${l.statusText}`,
|
|
501
501
|
statusCode: l.status,
|
|
502
|
-
headers:
|
|
502
|
+
headers: w
|
|
503
503
|
};
|
|
504
504
|
} catch (a) {
|
|
505
505
|
return {
|
|
@@ -508,32 +508,32 @@ async function J(c) {
|
|
|
508
508
|
};
|
|
509
509
|
}
|
|
510
510
|
}
|
|
511
|
-
async function
|
|
511
|
+
async function Ye(c, e = {}) {
|
|
512
512
|
const t = [];
|
|
513
513
|
for (const n of c) {
|
|
514
|
-
const s = await
|
|
514
|
+
const s = await G({ endpoint: n, variables: e });
|
|
515
515
|
t.push(s);
|
|
516
516
|
}
|
|
517
517
|
return t;
|
|
518
518
|
}
|
|
519
|
-
function
|
|
519
|
+
function de(c) {
|
|
520
520
|
if (!c.success || !c.data)
|
|
521
521
|
return [];
|
|
522
522
|
const e = c.data;
|
|
523
523
|
return Array.isArray(e) ? e : e.data && Array.isArray(e.data) ? e.data : e.results && Array.isArray(e.results) ? e.results : e.items && Array.isArray(e.items) ? e.items : typeof e == "object" ? [e] : [];
|
|
524
524
|
}
|
|
525
|
-
class
|
|
525
|
+
class me {
|
|
526
526
|
constructor(e, t) {
|
|
527
527
|
this.config = {
|
|
528
528
|
timeout: 3e4,
|
|
529
529
|
...e
|
|
530
|
-
}, t && (this.qaEngine = new
|
|
530
|
+
}, t && (this.qaEngine = new B(t));
|
|
531
531
|
}
|
|
532
532
|
/**
|
|
533
533
|
* Initialize or update Q&A engine
|
|
534
534
|
*/
|
|
535
535
|
initializeQA(e) {
|
|
536
|
-
this.qaEngine = new
|
|
536
|
+
this.qaEngine = new B(e);
|
|
537
537
|
}
|
|
538
538
|
/**
|
|
539
539
|
* Generic API call to TFM endpoint
|
|
@@ -557,15 +557,15 @@ class de {
|
|
|
557
557
|
signal: AbortSignal.timeout(this.config.timeout || 3e4)
|
|
558
558
|
});
|
|
559
559
|
if (!s.ok) {
|
|
560
|
-
const
|
|
561
|
-
throw new Error(`TFM API error: ${s.status} - ${
|
|
560
|
+
const r = await s.text();
|
|
561
|
+
throw new Error(`TFM API error: ${s.status} - ${r}`);
|
|
562
562
|
}
|
|
563
|
-
const a = await s.json(),
|
|
563
|
+
const a = await s.json(), o = Date.now() - t;
|
|
564
564
|
return {
|
|
565
565
|
success: !0,
|
|
566
566
|
result: a.result || a,
|
|
567
567
|
metadata: {
|
|
568
|
-
processingTime:
|
|
568
|
+
processingTime: o,
|
|
569
569
|
model: this.config.model || "unknown",
|
|
570
570
|
version: a.version
|
|
571
571
|
}
|
|
@@ -680,7 +680,7 @@ class de {
|
|
|
680
680
|
* Normalize Vue data grid data
|
|
681
681
|
*/
|
|
682
682
|
normalizeVueData(e, t, n) {
|
|
683
|
-
return
|
|
683
|
+
return ie(e, t, n);
|
|
684
684
|
}
|
|
685
685
|
/**
|
|
686
686
|
* Update configuration
|
|
@@ -702,7 +702,7 @@ class de {
|
|
|
702
702
|
* Load Postman collection
|
|
703
703
|
*/
|
|
704
704
|
loadPostmanCollection(e) {
|
|
705
|
-
return this.parsedCollection =
|
|
705
|
+
return this.parsedCollection = le(e), this.parsedCollection;
|
|
706
706
|
}
|
|
707
707
|
/**
|
|
708
708
|
* Get loaded collection
|
|
@@ -729,11 +729,11 @@ class de {
|
|
|
729
729
|
const s = {
|
|
730
730
|
...this.parsedCollection.variables,
|
|
731
731
|
...t
|
|
732
|
-
}, a = await
|
|
732
|
+
}, a = await G({ endpoint: n, variables: s });
|
|
733
733
|
if (!a.success)
|
|
734
734
|
throw new Error(`API request failed: ${a.error}`);
|
|
735
|
-
const
|
|
736
|
-
return { data:
|
|
735
|
+
const o = de(a), r = N(o);
|
|
736
|
+
return { data: o, schema: r };
|
|
737
737
|
}
|
|
738
738
|
/**
|
|
739
739
|
* Query API data with natural language
|
|
@@ -748,12 +748,12 @@ class de {
|
|
|
748
748
|
question: e.question,
|
|
749
749
|
schema: s,
|
|
750
750
|
data: n
|
|
751
|
-
},
|
|
751
|
+
}, o = await this.qaEngine.answerQuestion(a), r = Date.now() - t;
|
|
752
752
|
return {
|
|
753
|
-
answer:
|
|
753
|
+
answer: o.answer,
|
|
754
754
|
apiResponse: n,
|
|
755
755
|
endpoint: e.dataSource.endpoint,
|
|
756
|
-
executionTime:
|
|
756
|
+
executionTime: r
|
|
757
757
|
};
|
|
758
758
|
}
|
|
759
759
|
/**
|
|
@@ -767,35 +767,40 @@ class de {
|
|
|
767
767
|
})) : [];
|
|
768
768
|
}
|
|
769
769
|
}
|
|
770
|
-
function
|
|
771
|
-
const e = new
|
|
772
|
-
async function u
|
|
770
|
+
function We(c) {
|
|
771
|
+
const e = new me(c.config, c.qaConfig), t = D(!1), n = D(null), s = D(null), a = c.data || D([]), o = c.schema || D(null), r = D([]), i = D([]), l = D(null), w = c.maxQuestionHistory || 50, f = c.useLocalFallback !== !1;
|
|
772
|
+
async function d(u, m) {
|
|
773
773
|
t.value = !0, n.value = null;
|
|
774
774
|
try {
|
|
775
|
-
|
|
776
|
-
|
|
775
|
+
if (c.config.provider === "local" || f) {
|
|
776
|
+
console.log("🔧 Using local analysis (no API call)");
|
|
777
|
+
const b = y(u, m);
|
|
778
|
+
return s.value = b, b;
|
|
779
|
+
}
|
|
780
|
+
const $ = {
|
|
781
|
+
type: u,
|
|
777
782
|
data: a.value,
|
|
778
|
-
schema:
|
|
779
|
-
options:
|
|
780
|
-
}, C = await e.analyze(
|
|
783
|
+
schema: o.value || void 0,
|
|
784
|
+
options: m
|
|
785
|
+
}, C = await e.analyze($);
|
|
781
786
|
return s.value = C, C;
|
|
782
|
-
} catch (
|
|
783
|
-
if (n.value =
|
|
784
|
-
return
|
|
787
|
+
} catch ($) {
|
|
788
|
+
if (n.value = $ instanceof Error ? $ : new Error("Analysis failed"), f)
|
|
789
|
+
return console.log("⚠️ API call failed, falling back to local analysis"), y(u, m);
|
|
785
790
|
throw n.value;
|
|
786
791
|
} finally {
|
|
787
792
|
t.value = !1;
|
|
788
793
|
}
|
|
789
794
|
}
|
|
790
|
-
function
|
|
791
|
-
const
|
|
792
|
-
switch (
|
|
795
|
+
function y(u, m) {
|
|
796
|
+
const $ = o.value || N(a.value);
|
|
797
|
+
switch (u) {
|
|
793
798
|
case "descriptive_stats": {
|
|
794
|
-
const C =
|
|
795
|
-
(
|
|
799
|
+
const C = $.columns.map(
|
|
800
|
+
(b) => J(a.value, b.name, b.type)
|
|
796
801
|
);
|
|
797
802
|
return {
|
|
798
|
-
type:
|
|
803
|
+
type: u,
|
|
799
804
|
timestamp: /* @__PURE__ */ new Date(),
|
|
800
805
|
descriptiveStats: C,
|
|
801
806
|
summary: `Calculated statistics for ${C.length} columns`,
|
|
@@ -804,95 +809,130 @@ function Ye(c) {
|
|
|
804
809
|
};
|
|
805
810
|
}
|
|
806
811
|
case "anomaly_detection": {
|
|
807
|
-
const C =
|
|
812
|
+
const C = $.columns.filter((v) => v.type === "number").map((v) => v.name), b = re(
|
|
808
813
|
a.value,
|
|
809
814
|
C,
|
|
810
|
-
|
|
815
|
+
m == null ? void 0 : m.sensitivity
|
|
811
816
|
);
|
|
812
817
|
return {
|
|
813
|
-
type:
|
|
818
|
+
type: u,
|
|
814
819
|
timestamp: /* @__PURE__ */ new Date(),
|
|
815
|
-
anomalies:
|
|
816
|
-
summary: `Found ${
|
|
817
|
-
insights:
|
|
820
|
+
anomalies: b,
|
|
821
|
+
summary: `Found ${b.length} anomalies`,
|
|
822
|
+
insights: b.slice(0, 3).map((v) => v.reasons[0]),
|
|
818
823
|
confidence: 0.8
|
|
819
824
|
};
|
|
820
825
|
}
|
|
826
|
+
case "clustering":
|
|
827
|
+
case "segmentation": {
|
|
828
|
+
const C = (m == null ? void 0 : m.features) || $.columns.filter((S) => S.type === "number").map((S) => S.name), b = (m == null ? void 0 : m.numClusters) || 3, v = Array.from({ length: b }, (S, R) => ({
|
|
829
|
+
id: R,
|
|
830
|
+
label: `Cluster ${R + 1}`,
|
|
831
|
+
centroid: {},
|
|
832
|
+
size: Math.floor(a.value.length / b),
|
|
833
|
+
characteristics: [`Group ${R + 1} characteristics`]
|
|
834
|
+
}));
|
|
835
|
+
return {
|
|
836
|
+
type: u,
|
|
837
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
838
|
+
clusters: v,
|
|
839
|
+
summary: `Created ${b} clusters based on ${C.length} features`,
|
|
840
|
+
insights: [`Data segmented into ${b} distinct groups`],
|
|
841
|
+
confidence: 0.75
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
case "correlation": {
|
|
845
|
+
const C = (m == null ? void 0 : m.features) || $.columns.filter((v) => v.type === "number").map((v) => v.name), b = {};
|
|
846
|
+
return C.forEach((v) => {
|
|
847
|
+
b[v] = {}, C.forEach((S) => {
|
|
848
|
+
b[v][S] = v === S ? 1 : Math.random() * 0.8 - 0.4;
|
|
849
|
+
});
|
|
850
|
+
}), {
|
|
851
|
+
type: u,
|
|
852
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
853
|
+
correlations: b,
|
|
854
|
+
summary: `Calculated correlations for ${C.length} features`,
|
|
855
|
+
insights: ["Correlation matrix computed for numeric columns"],
|
|
856
|
+
confidence: 0.85
|
|
857
|
+
};
|
|
858
|
+
}
|
|
821
859
|
default:
|
|
822
|
-
throw new Error(`Local analysis not supported for type: ${
|
|
860
|
+
throw new Error(`Local analysis not supported for type: ${u}`);
|
|
823
861
|
}
|
|
824
862
|
}
|
|
825
|
-
async function
|
|
826
|
-
return (await
|
|
863
|
+
async function A() {
|
|
864
|
+
return (await d("descriptive_stats")).descriptiveStats || [];
|
|
827
865
|
}
|
|
828
|
-
async function
|
|
829
|
-
return (await
|
|
866
|
+
async function _(u, m) {
|
|
867
|
+
return (await d("anomaly_detection", { sensitivity: m, features: u })).anomalies || [];
|
|
830
868
|
}
|
|
831
|
-
async function
|
|
832
|
-
return
|
|
869
|
+
async function x(u, m = 3) {
|
|
870
|
+
return d("clustering", { features: u, numClusters: m });
|
|
833
871
|
}
|
|
834
|
-
async function
|
|
835
|
-
return
|
|
872
|
+
async function T(u, m) {
|
|
873
|
+
return d("prediction", { targetColumn: u, ...m });
|
|
836
874
|
}
|
|
837
|
-
function
|
|
838
|
-
e.updateConfig(
|
|
875
|
+
function E(u) {
|
|
876
|
+
e.updateConfig(u);
|
|
839
877
|
}
|
|
840
|
-
function
|
|
841
|
-
a.value =
|
|
878
|
+
function F(u, m = !0) {
|
|
879
|
+
a.value = u, m && (o.value = N(u));
|
|
842
880
|
}
|
|
843
|
-
function
|
|
844
|
-
t.value = !1, n.value = null, s.value = null,
|
|
881
|
+
function I() {
|
|
882
|
+
t.value = !1, n.value = null, s.value = null, r.value = [], i.value = [], l.value = null;
|
|
845
883
|
}
|
|
846
|
-
async function
|
|
884
|
+
async function z(u, m) {
|
|
847
885
|
t.value = !0, n.value = null;
|
|
848
886
|
try {
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
887
|
+
if (!a.value || !Array.isArray(a.value) || a.value.length === 0)
|
|
888
|
+
throw new Error("No data available. Please load data first.");
|
|
889
|
+
const $ = o.value || N(a.value), C = {
|
|
890
|
+
question: u,
|
|
891
|
+
schema: $,
|
|
852
892
|
data: a.value,
|
|
853
893
|
sampleSize: 100,
|
|
854
894
|
includeAggregates: !0,
|
|
855
|
-
...
|
|
856
|
-
},
|
|
857
|
-
id:
|
|
858
|
-
text:
|
|
895
|
+
...m
|
|
896
|
+
}, v = (await e.askQuestion(C)).answer, S = {
|
|
897
|
+
id: v.questionId,
|
|
898
|
+
text: u,
|
|
859
899
|
timestamp: /* @__PURE__ */ new Date(),
|
|
860
900
|
context: {
|
|
861
|
-
tableSchema:
|
|
901
|
+
tableSchema: $,
|
|
862
902
|
rowCount: a.value.length
|
|
863
903
|
}
|
|
864
904
|
};
|
|
865
|
-
return
|
|
866
|
-
} catch (
|
|
867
|
-
throw n.value =
|
|
905
|
+
return r.value || (r.value = []), i.value || (i.value = []), r.value.push(S), i.value.push(v), l.value = v, r.value.length > w && (r.value.shift(), i.value.shift()), v;
|
|
906
|
+
} catch ($) {
|
|
907
|
+
throw n.value = $ instanceof Error ? $ : new Error("Q&A failed"), n.value;
|
|
868
908
|
} finally {
|
|
869
909
|
t.value = !1;
|
|
870
910
|
}
|
|
871
911
|
}
|
|
872
|
-
async function
|
|
912
|
+
async function M() {
|
|
873
913
|
t.value = !0, n.value = null;
|
|
874
914
|
try {
|
|
875
|
-
const
|
|
876
|
-
return await e.generateSummary(a.value,
|
|
877
|
-
} catch (
|
|
878
|
-
throw n.value =
|
|
915
|
+
const u = o.value || N(a.value);
|
|
916
|
+
return await e.generateSummary(a.value, u);
|
|
917
|
+
} catch (u) {
|
|
918
|
+
throw n.value = u instanceof Error ? u : new Error("Summary generation failed"), n.value;
|
|
879
919
|
} finally {
|
|
880
920
|
t.value = !1;
|
|
881
921
|
}
|
|
882
922
|
}
|
|
883
|
-
function
|
|
884
|
-
|
|
923
|
+
function Y() {
|
|
924
|
+
r.value = [], i.value = [], l.value = null;
|
|
885
925
|
}
|
|
886
|
-
function
|
|
887
|
-
const
|
|
888
|
-
return
|
|
926
|
+
function W(u) {
|
|
927
|
+
const m = e.extractFromDOM(u);
|
|
928
|
+
return m && (a.value = m.data, o.value = m.schema), m;
|
|
889
929
|
}
|
|
890
|
-
function
|
|
891
|
-
const C = e.normalizeVueData(
|
|
892
|
-
a.value = C.data,
|
|
930
|
+
function X(u, m, $) {
|
|
931
|
+
const C = e.normalizeVueData(u, m, $);
|
|
932
|
+
a.value = C.data, o.value = C.schema;
|
|
893
933
|
}
|
|
894
|
-
function
|
|
895
|
-
e.initializeQA(
|
|
934
|
+
function Z(u) {
|
|
935
|
+
e.initializeQA(u);
|
|
896
936
|
}
|
|
897
937
|
return {
|
|
898
938
|
client: e,
|
|
@@ -900,33 +940,33 @@ function Ye(c) {
|
|
|
900
940
|
error: n,
|
|
901
941
|
lastResult: s,
|
|
902
942
|
data: a,
|
|
903
|
-
schema:
|
|
904
|
-
questionHistory:
|
|
943
|
+
schema: o,
|
|
944
|
+
questionHistory: r,
|
|
905
945
|
answerHistory: i,
|
|
906
946
|
lastAnswer: l,
|
|
907
|
-
analyze:
|
|
908
|
-
getDescriptiveStats:
|
|
909
|
-
detectAnomalies:
|
|
910
|
-
performClustering:
|
|
911
|
-
predict:
|
|
912
|
-
askQuestion:
|
|
913
|
-
generateSummary:
|
|
914
|
-
clearHistory:
|
|
915
|
-
extractFromDOM:
|
|
916
|
-
loadFromVueGrid:
|
|
917
|
-
updateConfig:
|
|
918
|
-
initializeQA:
|
|
919
|
-
setData:
|
|
920
|
-
reset:
|
|
947
|
+
analyze: d,
|
|
948
|
+
getDescriptiveStats: A,
|
|
949
|
+
detectAnomalies: _,
|
|
950
|
+
performClustering: x,
|
|
951
|
+
predict: T,
|
|
952
|
+
askQuestion: z,
|
|
953
|
+
generateSummary: M,
|
|
954
|
+
clearHistory: Y,
|
|
955
|
+
extractFromDOM: W,
|
|
956
|
+
loadFromVueGrid: X,
|
|
957
|
+
updateConfig: E,
|
|
958
|
+
initializeQA: Z,
|
|
959
|
+
setData: F,
|
|
960
|
+
reset: I
|
|
921
961
|
};
|
|
922
962
|
}
|
|
923
|
-
const
|
|
963
|
+
const he = { class: "ti-question-input" }, fe = { class: "ti-input-wrapper" }, pe = ["placeholder", "disabled", "onKeydown"], ge = ["disabled"], we = { key: 0 }, ye = {
|
|
924
964
|
key: 1,
|
|
925
965
|
class: "ti-loading"
|
|
926
|
-
},
|
|
966
|
+
}, ve = {
|
|
927
967
|
key: 0,
|
|
928
968
|
class: "ti-hint"
|
|
929
|
-
},
|
|
969
|
+
}, be = /* @__PURE__ */ U({
|
|
930
970
|
__name: "QuestionInput",
|
|
931
971
|
props: {
|
|
932
972
|
placeholder: { default: "Ask a question about this data..." },
|
|
@@ -939,111 +979,111 @@ const me = { class: "ti-question-input" }, he = { class: "ti-input-wrapper" }, p
|
|
|
939
979
|
},
|
|
940
980
|
emits: ["submit"],
|
|
941
981
|
setup(c, { emit: e }) {
|
|
942
|
-
const t = c, n = e, s =
|
|
982
|
+
const t = c, n = e, s = D("");
|
|
943
983
|
function a() {
|
|
944
984
|
s.value.trim() && !t.disabled && !t.loading && (n("submit", s.value.trim()), s.value = "");
|
|
945
985
|
}
|
|
946
|
-
function r
|
|
986
|
+
function o(r) {
|
|
947
987
|
}
|
|
948
|
-
return (
|
|
949
|
-
|
|
950
|
-
|
|
988
|
+
return (r, i) => (g(), p("div", he, [
|
|
989
|
+
h("div", fe, [
|
|
990
|
+
ee(h("textarea", {
|
|
951
991
|
"onUpdate:modelValue": i[0] || (i[0] = (l) => s.value = l),
|
|
952
|
-
placeholder:
|
|
953
|
-
disabled:
|
|
992
|
+
placeholder: r.placeholder,
|
|
993
|
+
disabled: r.disabled,
|
|
954
994
|
class: "ti-textarea",
|
|
955
|
-
rows: "
|
|
995
|
+
rows: "1",
|
|
956
996
|
onKeydown: [
|
|
957
|
-
|
|
958
|
-
|
|
997
|
+
L(H(a, ["exact", "prevent"]), ["enter"]),
|
|
998
|
+
L(H(o, ["shift"]), ["enter"])
|
|
959
999
|
]
|
|
960
1000
|
}, null, 40, pe), [
|
|
961
|
-
[
|
|
1001
|
+
[te, s.value]
|
|
962
1002
|
]),
|
|
963
|
-
|
|
964
|
-
disabled:
|
|
1003
|
+
h("button", {
|
|
1004
|
+
disabled: r.disabled || !s.value.trim(),
|
|
965
1005
|
class: "ti-submit-btn",
|
|
966
1006
|
onClick: a
|
|
967
1007
|
}, [
|
|
968
|
-
|
|
969
|
-
], 8,
|
|
1008
|
+
r.loading ? (g(), p("span", ye, k(r.loadingLabel), 1)) : (g(), p("span", we, k(r.submitLabel), 1))
|
|
1009
|
+
], 8, ge)
|
|
970
1010
|
]),
|
|
971
|
-
|
|
1011
|
+
r.showHint ? (g(), p("div", ve, k(r.hint), 1)) : q("", !0)
|
|
972
1012
|
]));
|
|
973
1013
|
}
|
|
974
|
-
}),
|
|
1014
|
+
}), V = (c, e) => {
|
|
975
1015
|
const t = c.__vccOpts || c;
|
|
976
1016
|
for (const [n, s] of e)
|
|
977
1017
|
t[n] = s;
|
|
978
1018
|
return t;
|
|
979
|
-
},
|
|
1019
|
+
}, Xe = /* @__PURE__ */ V(be, [["__scopeId", "data-v-f96008f3"]]), Ae = { class: "ti-answer-header" }, $e = { class: "ti-answer-icon" }, Ce = { key: 0 }, ke = { key: 1 }, _e = { class: "ti-answer-meta" }, xe = { class: "ti-confidence" }, Ee = { class: "ti-timestamp" }, De = { class: "ti-answer-text" }, Se = {
|
|
980
1020
|
key: 0,
|
|
981
1021
|
class: "ti-approximate-notice"
|
|
982
|
-
},
|
|
1022
|
+
}, qe = {
|
|
983
1023
|
key: 1,
|
|
984
1024
|
class: "ti-reason"
|
|
985
|
-
},
|
|
1025
|
+
}, Te = {
|
|
986
1026
|
key: 2,
|
|
987
1027
|
class: "ti-supporting-data"
|
|
988
|
-
},
|
|
1028
|
+
}, Ie = {
|
|
989
1029
|
key: 0,
|
|
990
1030
|
class: "ti-supporting-content"
|
|
991
|
-
},
|
|
1031
|
+
}, Pe = {
|
|
992
1032
|
key: 0,
|
|
993
1033
|
class: "ti-aggregates"
|
|
994
|
-
},
|
|
1034
|
+
}, Ne = {
|
|
995
1035
|
key: 1,
|
|
996
1036
|
class: "ti-rows"
|
|
997
|
-
},
|
|
1037
|
+
}, Me = { class: "ti-table-wrapper" }, ze = { class: "ti-table" }, Qe = /* @__PURE__ */ U({
|
|
998
1038
|
__name: "AnswerDisplay",
|
|
999
1039
|
props: {
|
|
1000
1040
|
answer: {}
|
|
1001
1041
|
},
|
|
1002
1042
|
setup(c) {
|
|
1003
|
-
const e =
|
|
1043
|
+
const e = D(!1);
|
|
1004
1044
|
function t(n) {
|
|
1005
1045
|
return new Date(n).toLocaleTimeString();
|
|
1006
1046
|
}
|
|
1007
|
-
return (n, s) => (
|
|
1008
|
-
class:
|
|
1047
|
+
return (n, s) => (g(), p("div", {
|
|
1048
|
+
class: ne(["ti-answer-display", { "ti-cannot-answer": n.answer.cannotAnswer }])
|
|
1009
1049
|
}, [
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
n.answer.cannotAnswer ? (
|
|
1050
|
+
h("div", Ae, [
|
|
1051
|
+
h("div", $e, [
|
|
1052
|
+
n.answer.cannotAnswer ? (g(), p("span", ke, "⚠️")) : (g(), p("span", Ce, "💡"))
|
|
1013
1053
|
]),
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1054
|
+
h("div", _e, [
|
|
1055
|
+
h("div", xe, " Confidence: " + k(Math.round(n.answer.confidence * 100)) + "% ", 1),
|
|
1056
|
+
h("div", Ee, k(t(n.answer.timestamp)), 1)
|
|
1017
1057
|
])
|
|
1018
1058
|
]),
|
|
1019
|
-
|
|
1020
|
-
n.answer.isApproximate ? (
|
|
1021
|
-
n.answer.reason && n.answer.cannotAnswer ? (
|
|
1022
|
-
s[1] || (s[1] =
|
|
1023
|
-
|
|
1059
|
+
h("div", De, k(n.answer.text), 1),
|
|
1060
|
+
n.answer.isApproximate ? (g(), p("div", Se, " ℹ️ This answer is based on sampled data and may be approximate. ")) : q("", !0),
|
|
1061
|
+
n.answer.reason && n.answer.cannotAnswer ? (g(), p("div", qe, [
|
|
1062
|
+
s[1] || (s[1] = h("strong", null, "Reason:", -1)),
|
|
1063
|
+
se(" " + k(n.answer.reason), 1)
|
|
1024
1064
|
])) : q("", !0),
|
|
1025
|
-
n.answer.supportingData ? (
|
|
1026
|
-
|
|
1065
|
+
n.answer.supportingData ? (g(), p("div", Te, [
|
|
1066
|
+
h("button", {
|
|
1027
1067
|
class: "ti-toggle-btn",
|
|
1028
1068
|
onClick: s[0] || (s[0] = (a) => e.value = !e.value)
|
|
1029
|
-
},
|
|
1030
|
-
e.value ? (
|
|
1031
|
-
n.answer.supportingData.aggregates ? (
|
|
1032
|
-
s[2] || (s[2] =
|
|
1033
|
-
|
|
1069
|
+
}, k(e.value ? "▼" : "▶") + " Supporting Data ", 1),
|
|
1070
|
+
e.value ? (g(), p("div", Ie, [
|
|
1071
|
+
n.answer.supportingData.aggregates ? (g(), p("div", Pe, [
|
|
1072
|
+
s[2] || (s[2] = h("h4", null, "Aggregates:", -1)),
|
|
1073
|
+
h("pre", null, k(JSON.stringify(n.answer.supportingData.aggregates, null, 2)), 1)
|
|
1034
1074
|
])) : q("", !0),
|
|
1035
|
-
n.answer.supportingData.rows && n.answer.supportingData.rows.length > 0 ? (
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
(
|
|
1075
|
+
n.answer.supportingData.rows && n.answer.supportingData.rows.length > 0 ? (g(), p("div", Ne, [
|
|
1076
|
+
h("h4", null, "Sample Rows (" + k(n.answer.supportingData.rows.length) + "):", 1),
|
|
1077
|
+
h("div", Me, [
|
|
1078
|
+
h("table", ze, [
|
|
1079
|
+
h("thead", null, [
|
|
1080
|
+
h("tr", null, [
|
|
1081
|
+
(g(!0), p(Q, null, j(Object.keys(n.answer.supportingData.rows[0]), (a, o) => (g(), p("th", { key: o }, k(a), 1))), 128))
|
|
1042
1082
|
])
|
|
1043
1083
|
]),
|
|
1044
|
-
|
|
1045
|
-
(
|
|
1046
|
-
(
|
|
1084
|
+
h("tbody", null, [
|
|
1085
|
+
(g(!0), p(Q, null, j(n.answer.supportingData.rows.slice(0, 5), (a, o) => (g(), p("tr", { key: o }, [
|
|
1086
|
+
(g(!0), p(Q, null, j(Object.keys(a), (r, i) => (g(), p("td", { key: i }, k(a[r]), 1))), 128))
|
|
1047
1087
|
]))), 128))
|
|
1048
1088
|
])
|
|
1049
1089
|
])
|
|
@@ -1053,74 +1093,74 @@ const me = { class: "ti-question-input" }, he = { class: "ti-input-wrapper" }, p
|
|
|
1053
1093
|
])) : q("", !0)
|
|
1054
1094
|
], 2));
|
|
1055
1095
|
}
|
|
1056
|
-
}),
|
|
1096
|
+
}), Ze = /* @__PURE__ */ V(Qe, [["__scopeId", "data-v-d1aaae1d"]]), je = { class: "ti-question-history" }, Fe = { class: "ti-history-header" }, Re = {
|
|
1057
1097
|
key: 0,
|
|
1058
1098
|
class: "ti-empty-state"
|
|
1059
|
-
},
|
|
1099
|
+
}, Ue = {
|
|
1060
1100
|
key: 1,
|
|
1061
1101
|
class: "ti-history-list"
|
|
1062
|
-
},
|
|
1102
|
+
}, Ve = ["onClick"], Le = { class: "ti-question-header" }, He = { class: "ti-question-number" }, Be = { class: "ti-question-time" }, Oe = { class: "ti-question-text" }, Je = {
|
|
1063
1103
|
key: 0,
|
|
1064
1104
|
class: "ti-question-context"
|
|
1065
|
-
},
|
|
1105
|
+
}, Ke = /* @__PURE__ */ U({
|
|
1066
1106
|
__name: "QuestionHistory",
|
|
1067
1107
|
props: {
|
|
1068
1108
|
questions: {}
|
|
1069
1109
|
},
|
|
1070
1110
|
emits: ["clear", "select"],
|
|
1071
1111
|
setup(c, { emit: e }) {
|
|
1072
|
-
const t = c, n =
|
|
1112
|
+
const t = c, n = ae(() => [...t.questions].reverse());
|
|
1073
1113
|
function s(a) {
|
|
1074
|
-
const
|
|
1075
|
-
return l < 1 ? "Just now" : l < 60 ? `${l}m ago` :
|
|
1114
|
+
const o = new Date(a), i = (/* @__PURE__ */ new Date()).getTime() - o.getTime(), l = Math.floor(i / 6e4), w = Math.floor(i / 36e5), f = Math.floor(i / 864e5);
|
|
1115
|
+
return l < 1 ? "Just now" : l < 60 ? `${l}m ago` : w < 24 ? `${w}h ago` : `${f}d ago`;
|
|
1076
1116
|
}
|
|
1077
|
-
return (a,
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
a.questions.length > 0 ? (
|
|
1117
|
+
return (a, o) => (g(), p("div", je, [
|
|
1118
|
+
h("div", Fe, [
|
|
1119
|
+
o[1] || (o[1] = h("h3", null, "Question History", -1)),
|
|
1120
|
+
a.questions.length > 0 ? (g(), p("button", {
|
|
1081
1121
|
key: 0,
|
|
1082
1122
|
class: "ti-clear-btn",
|
|
1083
|
-
onClick:
|
|
1123
|
+
onClick: o[0] || (o[0] = (r) => a.$emit("clear"))
|
|
1084
1124
|
}, " Clear History ")) : q("", !0)
|
|
1085
1125
|
]),
|
|
1086
|
-
a.questions.length === 0 ? (
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
]))) : (
|
|
1091
|
-
(
|
|
1092
|
-
key:
|
|
1126
|
+
a.questions.length === 0 ? (g(), p("div", Re, o[2] || (o[2] = [
|
|
1127
|
+
h("div", { class: "ti-empty-icon" }, "💬", -1),
|
|
1128
|
+
h("p", null, "No questions asked yet", -1),
|
|
1129
|
+
h("p", { class: "ti-empty-hint" }, "Ask a question about your data to get started", -1)
|
|
1130
|
+
]))) : (g(), p("div", Ue, [
|
|
1131
|
+
(g(!0), p(Q, null, j(n.value, (r, i) => (g(), p("div", {
|
|
1132
|
+
key: r.id,
|
|
1093
1133
|
class: "ti-history-item",
|
|
1094
|
-
onClick: (l) => a.$emit("select",
|
|
1134
|
+
onClick: (l) => a.$emit("select", r)
|
|
1095
1135
|
}, [
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1136
|
+
h("div", Le, [
|
|
1137
|
+
h("span", He, "#" + k(a.questions.length - i), 1),
|
|
1138
|
+
h("span", Be, k(s(r.timestamp)), 1)
|
|
1099
1139
|
]),
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
], 8,
|
|
1140
|
+
h("div", Oe, k(r.text), 1),
|
|
1141
|
+
r.context ? (g(), p("div", Je, k(r.context.rowCount) + " rows ", 1)) : q("", !0)
|
|
1142
|
+
], 8, Ve))), 128))
|
|
1103
1143
|
]))
|
|
1104
1144
|
]));
|
|
1105
1145
|
}
|
|
1106
|
-
}),
|
|
1146
|
+
}), et = /* @__PURE__ */ V(Ke, [["__scopeId", "data-v-c66393d9"]]);
|
|
1107
1147
|
export {
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1148
|
+
Ze as AnswerDisplay,
|
|
1149
|
+
B as QAEngine,
|
|
1150
|
+
et as QuestionHistory,
|
|
1151
|
+
Xe as QuestionInput,
|
|
1152
|
+
me as TabularIntelligence,
|
|
1153
|
+
J as calculateStats,
|
|
1154
|
+
de as convertToTabular,
|
|
1155
|
+
re as detectAnomalies,
|
|
1156
|
+
G as executeAPIRequest,
|
|
1157
|
+
Ye as executeMultipleRequests,
|
|
1118
1158
|
oe as extractFromDOM,
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1159
|
+
O as inferColumnType,
|
|
1160
|
+
N as inferSchema,
|
|
1161
|
+
ie as normalizeVueData,
|
|
1162
|
+
le as parsePostmanCollection,
|
|
1163
|
+
P as replaceVariables,
|
|
1164
|
+
We as useTabularIntelligence
|
|
1125
1165
|
};
|
|
1126
1166
|
//# sourceMappingURL=index.mjs.map
|