@aivue/tabular-intelligence 1.3.0 → 1.3.4
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/core/TabularIntelligence.d.ts.map +1 -1
- package/dist/index.js +26 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +371 -331
- package/dist/index.mjs.map +1 -1
- package/dist/tabular-intelligence.css +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
function
|
|
3
|
-
if (
|
|
1
|
+
import { ref as E, 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 M(i, e) {
|
|
3
|
+
if (i.length === 0)
|
|
4
4
|
return { columns: [], rowCount: 0, name: e };
|
|
5
|
-
const t =
|
|
5
|
+
const t = i[0];
|
|
6
6
|
return {
|
|
7
7
|
columns: Object.keys(t).map((s) => {
|
|
8
|
-
const a =
|
|
8
|
+
const a = O(i, s);
|
|
9
9
|
return {
|
|
10
10
|
name: s,
|
|
11
11
|
type: a,
|
|
12
|
-
nullable:
|
|
12
|
+
nullable: i.some((o) => o[s] == null)
|
|
13
13
|
};
|
|
14
14
|
}),
|
|
15
|
-
rowCount:
|
|
15
|
+
rowCount: i.length,
|
|
16
16
|
name: e
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
const t =
|
|
19
|
+
function O(i, e) {
|
|
20
|
+
const t = i.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))))
|
|
23
23
|
return "number";
|
|
@@ -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 =
|
|
31
|
+
function J(i, e, t) {
|
|
32
|
+
const n = i.map((r) => r[e]).filter((r) => r != null), s = n.length, a = i.length - s, o = {
|
|
33
33
|
column: e,
|
|
34
34
|
count: s,
|
|
35
35
|
nullCount: a
|
|
36
36
|
};
|
|
37
37
|
if (t === "number") {
|
|
38
|
-
const r = n.map(Number).filter((
|
|
38
|
+
const r = n.map(Number).filter((c) => !isNaN(c));
|
|
39
39
|
if (r.length > 0) {
|
|
40
|
-
const
|
|
41
|
-
o.mean = l / r.length, o.median =
|
|
42
|
-
const
|
|
43
|
-
o.std = Math.sqrt(
|
|
44
|
-
25:
|
|
40
|
+
const c = [...r].sort((f, d) => f - d), l = r.reduce((f, d) => f + d, 0);
|
|
41
|
+
o.mean = l / r.length, o.median = c[Math.floor(c.length / 2)], o.min = c[0], o.max = c[c.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
|
+
25: c[Math.floor(c.length * 0.25)],
|
|
45
45
|
50: o.median,
|
|
46
|
-
75:
|
|
47
|
-
90:
|
|
46
|
+
75: c[Math.floor(c.length * 0.75)],
|
|
47
|
+
90: c[Math.floor(c.length * 0.9)]
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
} else {
|
|
51
51
|
const r = new Set(n);
|
|
52
52
|
o.uniqueValues = r.size;
|
|
53
|
-
const
|
|
54
|
-
n.forEach((
|
|
55
|
-
const
|
|
56
|
-
|
|
53
|
+
const c = {};
|
|
54
|
+
n.forEach((w) => {
|
|
55
|
+
const f = String(w);
|
|
56
|
+
c[f] = (c[f] || 0) + 1;
|
|
57
57
|
});
|
|
58
|
-
const l = Math.max(...Object.values(
|
|
59
|
-
o.mode = Object.keys(
|
|
58
|
+
const l = Math.max(...Object.values(c));
|
|
59
|
+
o.mode = Object.keys(c).find((w) => c[w] === l);
|
|
60
60
|
}
|
|
61
61
|
return o;
|
|
62
62
|
}
|
|
63
|
-
function
|
|
63
|
+
function re(i, e, t = 0.5) {
|
|
64
64
|
const n = [], s = 1.5 + (1 - t) * 1.5;
|
|
65
65
|
return e.forEach((a) => {
|
|
66
|
-
const o =
|
|
66
|
+
const o = i.map((y, A) => ({ value: Number(y[a]), idx: A })).filter((y) => !isNaN(y.value));
|
|
67
67
|
if (o.length === 0) return;
|
|
68
|
-
const r = [...o].sort((y,
|
|
69
|
-
o.forEach(({ value: y, idx:
|
|
70
|
-
if (y <
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
rowIndex:
|
|
74
|
-
row:
|
|
68
|
+
const r = [...o].sort((y, A) => y.value - A.value), c = r[Math.floor(r.length * 0.25)].value, l = r[Math.floor(r.length * 0.75)].value, w = l - c, f = c - 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: i[A],
|
|
75
75
|
score: 0.7,
|
|
76
|
-
reasons: [
|
|
76
|
+
reasons: [x],
|
|
77
77
|
affectedColumns: [a]
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
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 H {
|
|
|
94
94
|
async answerQuestion(e) {
|
|
95
95
|
const t = Date.now();
|
|
96
96
|
try {
|
|
97
|
-
const { question: n, schema: s, data: a = [], sampleSize: o = 100, includeAggregates: r = !0 } = e,
|
|
97
|
+
const { question: n, schema: s, data: a = [], sampleSize: o = 100, includeAggregates: r = !0 } = e, c = a.length > o ? this.sampleData(a, o) : a, l = r ? this.calculateAggregates(a, s) : void 0, w = this.buildPrompt(n, s, c, 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 H {
|
|
|
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,
|
|
@@ -173,8 +173,8 @@ class H {
|
|
|
173
173
|
`, r += `Table: ${t.name}
|
|
174
174
|
`, r += `Columns:
|
|
175
175
|
`;
|
|
176
|
-
for (const
|
|
177
|
-
r += `- ${
|
|
176
|
+
for (const c of t.columns)
|
|
177
|
+
r += `- ${c.name} (${c.type})
|
|
178
178
|
`;
|
|
179
179
|
return r += `
|
|
180
180
|
`, s && Object.keys(s).length > 0 && (r += `**Summary Statistics:**
|
|
@@ -218,7 +218,7 @@ class H {
|
|
|
218
218
|
* Call OpenAI API
|
|
219
219
|
*/
|
|
220
220
|
async callOpenAI(e, t, n, s, a) {
|
|
221
|
-
var
|
|
221
|
+
var c, l;
|
|
222
222
|
const o = await fetch("https://api.openai.com/v1/chat/completions", {
|
|
223
223
|
method: "POST",
|
|
224
224
|
headers: {
|
|
@@ -235,13 +235,13 @@ class H {
|
|
|
235
235
|
});
|
|
236
236
|
if (!o.ok)
|
|
237
237
|
throw new Error(`OpenAI API error: ${o.statusText}`);
|
|
238
|
-
return ((l = (
|
|
238
|
+
return ((l = (c = (await o.json()).choices[0]) == null ? void 0 : c.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
|
-
var
|
|
244
|
+
var c;
|
|
245
245
|
const o = await fetch("https://api.anthropic.com/v1/messages", {
|
|
246
246
|
method: "POST",
|
|
247
247
|
headers: {
|
|
@@ -258,7 +258,7 @@ class H {
|
|
|
258
258
|
});
|
|
259
259
|
if (!o.ok)
|
|
260
260
|
throw new Error(`Anthropic API error: ${o.statusText}`);
|
|
261
|
-
return ((
|
|
261
|
+
return ((c = (await o.json()).content[0]) == null ? void 0 : c.text) || "";
|
|
262
262
|
}
|
|
263
263
|
/**
|
|
264
264
|
* Call custom API
|
|
@@ -311,74 +311,74 @@ class H {
|
|
|
311
311
|
return `qa_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
|
-
function
|
|
314
|
+
function oe(i = {}) {
|
|
315
315
|
const {
|
|
316
316
|
selector: e = "table",
|
|
317
317
|
includeHeaders: t = !0,
|
|
318
318
|
maxRows: n,
|
|
319
319
|
inferTypes: s = !0,
|
|
320
320
|
skipEmptyRows: a = !0
|
|
321
|
-
} =
|
|
321
|
+
} = i, o = document.querySelector(e);
|
|
322
322
|
if (!o || o.tagName !== "TABLE")
|
|
323
323
|
return console.warn(`No table found with selector: ${e}`), null;
|
|
324
|
-
const
|
|
325
|
-
if (
|
|
324
|
+
const c = Array.from(o.rows);
|
|
325
|
+
if (c.length === 0)
|
|
326
326
|
return null;
|
|
327
|
-
let l = [],
|
|
328
|
-
if (t &&
|
|
329
|
-
const
|
|
330
|
-
l = Array.from(
|
|
331
|
-
var
|
|
332
|
-
return ((
|
|
333
|
-
}),
|
|
327
|
+
let l = [], w = 0;
|
|
328
|
+
if (t && c[0]) {
|
|
329
|
+
const A = c[0];
|
|
330
|
+
l = Array.from(A.cells).map((_, x) => {
|
|
331
|
+
var D;
|
|
332
|
+
return ((D = _.textContent) == null ? void 0 : D.trim()) || "" || `Column${x + 1}`;
|
|
333
|
+
}), w = 1;
|
|
334
334
|
} else {
|
|
335
|
-
const
|
|
336
|
-
l = Array.from(
|
|
335
|
+
const A = c[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 ? c.slice(w, w + n) : c.slice(w);
|
|
339
|
+
for (const A of d) {
|
|
340
|
+
const _ = Array.from(A.cells);
|
|
341
|
+
if (a && _.every((T) => {
|
|
342
|
+
var D;
|
|
343
|
+
return !((D = T.textContent) != null && D.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, D) => {
|
|
348
|
+
var z;
|
|
349
|
+
const F = l[D] || `Column${D + 1}`;
|
|
350
|
+
let I = ((z = T.textContent) == null ? void 0 : z.trim()) || "";
|
|
351
|
+
if (s && I) {
|
|
352
|
+
const N = parseFloat(I);
|
|
353
|
+
!isNaN(N) && I === N.toString() && (I = N);
|
|
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 ? M(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
|
|
371
|
-
const { maxRows: n, inferTypes: s = !0 } = t, a = n ?
|
|
370
|
+
function ie(i, e, t = {}) {
|
|
371
|
+
const { maxRows: n, inferTypes: s = !0 } = t, a = n ? i.slice(0, n) : i;
|
|
372
372
|
let o;
|
|
373
373
|
return e && e.length > 0 ? o = {
|
|
374
374
|
name: "Vue Data Grid",
|
|
375
375
|
columns: e.map((r) => ({
|
|
376
376
|
name: r.field,
|
|
377
|
-
type: s && a.length > 0 ?
|
|
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 ? o =
|
|
381
|
+
} : a.length > 0 ? o = M(a, "Vue Data Grid") : o = { name: "Vue Data Grid", columns: [], rowCount: 0 }, {
|
|
382
382
|
schema: o,
|
|
383
383
|
data: a,
|
|
384
384
|
source: "vue",
|
|
@@ -389,10 +389,10 @@ function oe(c, e, t = {}) {
|
|
|
389
389
|
}
|
|
390
390
|
};
|
|
391
391
|
}
|
|
392
|
-
function
|
|
392
|
+
function ce(i, e = 0) {
|
|
393
393
|
return {
|
|
394
394
|
name: "Extracted Table",
|
|
395
|
-
columns:
|
|
395
|
+
columns: i.map((t) => ({
|
|
396
396
|
name: t,
|
|
397
397
|
type: "string",
|
|
398
398
|
nullable: !0
|
|
@@ -400,27 +400,27 @@ function ie(c, e = 0) {
|
|
|
400
400
|
rowCount: e
|
|
401
401
|
};
|
|
402
402
|
}
|
|
403
|
-
function
|
|
403
|
+
function le(i) {
|
|
404
404
|
const e = {};
|
|
405
|
-
|
|
405
|
+
i.variable && i.variable.forEach((a) => {
|
|
406
406
|
e[a.key] = a.value;
|
|
407
407
|
});
|
|
408
|
-
const t =
|
|
408
|
+
const t = i.auth ? K(i.auth) : void 0, n = [];
|
|
409
409
|
function s(a, o = "") {
|
|
410
410
|
a.forEach((r) => {
|
|
411
|
-
r.item ? s(r.item, o ? `${o}/${r.name}` : r.name) : r.request && n.push(
|
|
411
|
+
r.item ? s(r.item, o ? `${o}/${r.name}` : r.name) : r.request && n.push(ue(r, t));
|
|
412
412
|
});
|
|
413
413
|
}
|
|
414
|
-
return s(
|
|
415
|
-
name:
|
|
416
|
-
description:
|
|
414
|
+
return s(i.item), {
|
|
415
|
+
name: i.info.name,
|
|
416
|
+
description: i.info.description,
|
|
417
417
|
endpoints: n,
|
|
418
418
|
variables: e,
|
|
419
419
|
auth: t
|
|
420
420
|
};
|
|
421
421
|
}
|
|
422
|
-
function
|
|
423
|
-
const t =
|
|
422
|
+
function ue(i, e) {
|
|
423
|
+
const t = i.request, n = {};
|
|
424
424
|
t.header && t.header.forEach((o) => {
|
|
425
425
|
n[o.key] = o.value;
|
|
426
426
|
});
|
|
@@ -428,9 +428,9 @@ function le(c, e) {
|
|
|
428
428
|
t.url.query && t.url.query.forEach((o) => {
|
|
429
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
|
-
name:
|
|
433
|
+
name: i.name,
|
|
434
434
|
method: t.method,
|
|
435
435
|
url: t.url.raw,
|
|
436
436
|
description: t.description,
|
|
@@ -439,67 +439,67 @@ function le(c, e) {
|
|
|
439
439
|
auth: a
|
|
440
440
|
};
|
|
441
441
|
}
|
|
442
|
-
function
|
|
442
|
+
function K(i) {
|
|
443
443
|
const e = {};
|
|
444
|
-
return
|
|
444
|
+
return i.apikey ? i.apikey.forEach((t) => {
|
|
445
445
|
e[t.key] = t.value;
|
|
446
|
-
}) :
|
|
446
|
+
}) : i.bearer ? i.bearer.forEach((t) => {
|
|
447
447
|
e[t.key] = t.value;
|
|
448
|
-
}) :
|
|
448
|
+
}) : i.basic && i.basic.forEach((t) => {
|
|
449
449
|
e[t.key] = t.value;
|
|
450
450
|
}), {
|
|
451
|
-
type:
|
|
451
|
+
type: i.type,
|
|
452
452
|
credentials: e
|
|
453
453
|
};
|
|
454
454
|
}
|
|
455
|
-
function
|
|
456
|
-
let t =
|
|
455
|
+
function P(i, e) {
|
|
456
|
+
let t = i;
|
|
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
|
|
463
|
-
const { endpoint: e, variables: t = {}, additionalHeaders: n = {}, additionalParams: s = {} } =
|
|
462
|
+
async function G(i) {
|
|
463
|
+
const { endpoint: e, variables: t = {}, additionalHeaders: n = {}, additionalParams: s = {} } = i;
|
|
464
464
|
try {
|
|
465
|
-
let a =
|
|
466
|
-
const o = { ...e.queryParams, ...t, ...s }, r = Object.keys(o).filter((
|
|
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
467
|
r && (a = a.includes("?") ? `${a}&${r}` : `${a}?${r}`);
|
|
468
|
-
const
|
|
468
|
+
const c = {
|
|
469
469
|
"Content-Type": "application/json",
|
|
470
470
|
...e.headers,
|
|
471
471
|
...n
|
|
472
472
|
};
|
|
473
|
-
if (Object.keys(
|
|
474
|
-
|
|
473
|
+
if (Object.keys(c).forEach((d) => {
|
|
474
|
+
c[d] = P(c[d], t);
|
|
475
475
|
}), e.auth) {
|
|
476
476
|
if (e.auth.type === "apikey") {
|
|
477
|
-
const
|
|
478
|
-
e.auth.credentials.in === "header" && (
|
|
477
|
+
const d = e.auth.credentials.key || "access_key", y = P(e.auth.credentials.value || "", t);
|
|
478
|
+
e.auth.credentials.in === "header" && (c[d] = y);
|
|
479
479
|
} else if (e.auth.type === "bearer") {
|
|
480
|
-
const
|
|
481
|
-
|
|
480
|
+
const d = P(e.auth.credentials.token || "", t);
|
|
481
|
+
c.Authorization = `Bearer ${d}`;
|
|
482
482
|
} else if (e.auth.type === "basic") {
|
|
483
|
-
const
|
|
484
|
-
|
|
483
|
+
const d = P(e.auth.credentials.username || "", t), y = P(e.auth.credentials.password || "", t), A = btoa(`${d}:${y}`);
|
|
484
|
+
c.Authorization = `Basic ${A}`;
|
|
485
485
|
}
|
|
486
486
|
}
|
|
487
487
|
const l = await fetch(a, {
|
|
488
488
|
method: e.method,
|
|
489
|
-
headers:
|
|
490
|
-
}),
|
|
491
|
-
return l.headers.forEach((
|
|
492
|
-
|
|
489
|
+
headers: c
|
|
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 U(c) {
|
|
|
508
508
|
};
|
|
509
509
|
}
|
|
510
510
|
}
|
|
511
|
-
async function
|
|
511
|
+
async function Ye(i, e = {}) {
|
|
512
512
|
const t = [];
|
|
513
|
-
for (const n of
|
|
514
|
-
const s = await
|
|
513
|
+
for (const n of i) {
|
|
514
|
+
const s = await G({ endpoint: n, variables: e });
|
|
515
515
|
t.push(s);
|
|
516
516
|
}
|
|
517
517
|
return t;
|
|
518
518
|
}
|
|
519
|
-
function
|
|
520
|
-
if (!
|
|
519
|
+
function de(i) {
|
|
520
|
+
if (!i.success || !i.data)
|
|
521
521
|
return [];
|
|
522
|
-
const e =
|
|
522
|
+
const e = i.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
|
|
@@ -541,7 +541,9 @@ class de {
|
|
|
541
541
|
async callTFM(e) {
|
|
542
542
|
const t = Date.now();
|
|
543
543
|
try {
|
|
544
|
-
|
|
544
|
+
let n = this.config.baseUrl;
|
|
545
|
+
this.config.useCorsProxy && this.config.corsProxyUrl && (this.config.corsProxyUrl.includes("?") ? n = this.config.corsProxyUrl + encodeURIComponent(n) : n = (this.config.corsProxyUrl.endsWith("/") ? this.config.corsProxyUrl : this.config.corsProxyUrl + "/") + n, console.log("Using CORS proxy for TFM API call:", this.config.corsProxyUrl), console.log("Proxied URL:", n));
|
|
546
|
+
const s = await fetch(n, {
|
|
545
547
|
method: "POST",
|
|
546
548
|
headers: {
|
|
547
549
|
"Content-Type": "application/json",
|
|
@@ -554,18 +556,18 @@ class de {
|
|
|
554
556
|
}),
|
|
555
557
|
signal: AbortSignal.timeout(this.config.timeout || 3e4)
|
|
556
558
|
});
|
|
557
|
-
if (!
|
|
558
|
-
const
|
|
559
|
-
throw new Error(`TFM API error: ${
|
|
559
|
+
if (!s.ok) {
|
|
560
|
+
const r = await s.text();
|
|
561
|
+
throw new Error(`TFM API error: ${s.status} - ${r}`);
|
|
560
562
|
}
|
|
561
|
-
const
|
|
563
|
+
const a = await s.json(), o = Date.now() - t;
|
|
562
564
|
return {
|
|
563
565
|
success: !0,
|
|
564
|
-
result:
|
|
566
|
+
result: a.result || a,
|
|
565
567
|
metadata: {
|
|
566
|
-
processingTime:
|
|
568
|
+
processingTime: o,
|
|
567
569
|
model: this.config.model || "unknown",
|
|
568
|
-
version:
|
|
570
|
+
version: a.version
|
|
569
571
|
}
|
|
570
572
|
};
|
|
571
573
|
} catch (n) {
|
|
@@ -672,13 +674,13 @@ class de {
|
|
|
672
674
|
* Extract table from DOM
|
|
673
675
|
*/
|
|
674
676
|
extractFromDOM(e) {
|
|
675
|
-
return
|
|
677
|
+
return oe(e);
|
|
676
678
|
}
|
|
677
679
|
/**
|
|
678
680
|
* Normalize Vue data grid data
|
|
679
681
|
*/
|
|
680
682
|
normalizeVueData(e, t, n) {
|
|
681
|
-
return
|
|
683
|
+
return ie(e, t, n);
|
|
682
684
|
}
|
|
683
685
|
/**
|
|
684
686
|
* Update configuration
|
|
@@ -700,7 +702,7 @@ class de {
|
|
|
700
702
|
* Load Postman collection
|
|
701
703
|
*/
|
|
702
704
|
loadPostmanCollection(e) {
|
|
703
|
-
return this.parsedCollection =
|
|
705
|
+
return this.parsedCollection = le(e), this.parsedCollection;
|
|
704
706
|
}
|
|
705
707
|
/**
|
|
706
708
|
* Get loaded collection
|
|
@@ -721,16 +723,16 @@ class de {
|
|
|
721
723
|
async fetchDataFromAPI(e, t) {
|
|
722
724
|
if (!this.parsedCollection)
|
|
723
725
|
throw new Error("No Postman collection loaded. Call loadPostmanCollection() first.");
|
|
724
|
-
const n = this.parsedCollection.endpoints.find((
|
|
726
|
+
const n = this.parsedCollection.endpoints.find((c) => c.name === e);
|
|
725
727
|
if (!n)
|
|
726
728
|
throw new Error(`Endpoint "${e}" not found in collection.`);
|
|
727
729
|
const s = {
|
|
728
730
|
...this.parsedCollection.variables,
|
|
729
731
|
...t
|
|
730
|
-
}, a = await
|
|
732
|
+
}, a = await G({ endpoint: n, variables: s });
|
|
731
733
|
if (!a.success)
|
|
732
734
|
throw new Error(`API request failed: ${a.error}`);
|
|
733
|
-
const o =
|
|
735
|
+
const o = de(a), r = M(o);
|
|
734
736
|
return { data: o, schema: r };
|
|
735
737
|
}
|
|
736
738
|
/**
|
|
@@ -765,132 +767,170 @@ class de {
|
|
|
765
767
|
})) : [];
|
|
766
768
|
}
|
|
767
769
|
}
|
|
768
|
-
function
|
|
769
|
-
const e = new
|
|
770
|
-
async function u
|
|
770
|
+
function We(i) {
|
|
771
|
+
const e = new me(i.config, i.qaConfig), t = E(!1), n = E(null), s = E(null), a = i.data || E([]), o = i.schema || E(null), r = E([]), c = E([]), l = E(null), w = i.maxQuestionHistory || 50, f = i.useLocalFallback !== !1;
|
|
772
|
+
async function d(u, m) {
|
|
771
773
|
t.value = !0, n.value = null;
|
|
772
774
|
try {
|
|
773
|
-
|
|
774
|
-
|
|
775
|
+
if (i.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,
|
|
775
782
|
data: a.value,
|
|
776
783
|
schema: o.value || void 0,
|
|
777
|
-
options:
|
|
778
|
-
},
|
|
779
|
-
return s.value =
|
|
780
|
-
} catch (
|
|
781
|
-
if (n.value =
|
|
782
|
-
return y(
|
|
784
|
+
options: m
|
|
785
|
+
}, C = await e.analyze($);
|
|
786
|
+
return s.value = C, C;
|
|
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);
|
|
783
790
|
throw n.value;
|
|
784
791
|
} finally {
|
|
785
792
|
t.value = !1;
|
|
786
793
|
}
|
|
787
794
|
}
|
|
788
|
-
function y(
|
|
789
|
-
const
|
|
790
|
-
switch (
|
|
795
|
+
function y(u, m) {
|
|
796
|
+
const $ = o.value || M(a.value);
|
|
797
|
+
switch (u) {
|
|
791
798
|
case "descriptive_stats": {
|
|
792
|
-
const
|
|
793
|
-
(
|
|
799
|
+
const C = $.columns.map(
|
|
800
|
+
(b) => J(a.value, b.name, b.type)
|
|
794
801
|
);
|
|
795
802
|
return {
|
|
796
|
-
type:
|
|
803
|
+
type: u,
|
|
797
804
|
timestamp: /* @__PURE__ */ new Date(),
|
|
798
|
-
descriptiveStats:
|
|
799
|
-
summary: `Calculated statistics for ${
|
|
805
|
+
descriptiveStats: C,
|
|
806
|
+
summary: `Calculated statistics for ${C.length} columns`,
|
|
800
807
|
insights: [],
|
|
801
808
|
confidence: 0.9
|
|
802
809
|
};
|
|
803
810
|
}
|
|
804
811
|
case "anomaly_detection": {
|
|
805
|
-
const
|
|
812
|
+
const C = $.columns.filter((v) => v.type === "number").map((v) => v.name), b = re(
|
|
806
813
|
a.value,
|
|
807
|
-
|
|
808
|
-
|
|
814
|
+
C,
|
|
815
|
+
m == null ? void 0 : m.sensitivity
|
|
809
816
|
);
|
|
810
817
|
return {
|
|
811
|
-
type:
|
|
818
|
+
type: u,
|
|
812
819
|
timestamp: /* @__PURE__ */ new Date(),
|
|
813
|
-
anomalies:
|
|
814
|
-
summary: `Found ${
|
|
815
|
-
insights:
|
|
820
|
+
anomalies: b,
|
|
821
|
+
summary: `Found ${b.length} anomalies`,
|
|
822
|
+
insights: b.slice(0, 3).map((v) => v.reasons[0]),
|
|
816
823
|
confidence: 0.8
|
|
817
824
|
};
|
|
818
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
|
+
}
|
|
819
859
|
default:
|
|
820
|
-
throw new Error(`Local analysis not supported for type: ${
|
|
860
|
+
throw new Error(`Local analysis not supported for type: ${u}`);
|
|
821
861
|
}
|
|
822
862
|
}
|
|
823
|
-
async function
|
|
824
|
-
return (await
|
|
863
|
+
async function A() {
|
|
864
|
+
return (await d("descriptive_stats")).descriptiveStats || [];
|
|
825
865
|
}
|
|
826
|
-
async function
|
|
827
|
-
return (await
|
|
866
|
+
async function _(u, m) {
|
|
867
|
+
return (await d("anomaly_detection", { sensitivity: m, features: u })).anomalies || [];
|
|
828
868
|
}
|
|
829
|
-
async function
|
|
830
|
-
return
|
|
869
|
+
async function x(u, m = 3) {
|
|
870
|
+
return d("clustering", { features: u, numClusters: m });
|
|
831
871
|
}
|
|
832
|
-
async function
|
|
833
|
-
return
|
|
872
|
+
async function T(u, m) {
|
|
873
|
+
return d("prediction", { targetColumn: u, ...m });
|
|
834
874
|
}
|
|
835
|
-
function
|
|
836
|
-
e.updateConfig(
|
|
875
|
+
function D(u) {
|
|
876
|
+
e.updateConfig(u);
|
|
837
877
|
}
|
|
838
|
-
function
|
|
839
|
-
a.value =
|
|
878
|
+
function F(u, m = !0) {
|
|
879
|
+
a.value = u, m && (o.value = M(u));
|
|
840
880
|
}
|
|
841
|
-
function
|
|
842
|
-
t.value = !1, n.value = null, s.value = null, r.value = [],
|
|
881
|
+
function I() {
|
|
882
|
+
t.value = !1, n.value = null, s.value = null, r.value = [], c.value = [], l.value = null;
|
|
843
883
|
}
|
|
844
|
-
async function
|
|
884
|
+
async function z(u, m) {
|
|
845
885
|
t.value = !0, n.value = null;
|
|
846
886
|
try {
|
|
847
|
-
const
|
|
848
|
-
question:
|
|
849
|
-
schema:
|
|
887
|
+
const $ = o.value || M(a.value), C = {
|
|
888
|
+
question: u,
|
|
889
|
+
schema: $,
|
|
850
890
|
data: a.value,
|
|
851
891
|
sampleSize: 100,
|
|
852
892
|
includeAggregates: !0,
|
|
853
|
-
...
|
|
854
|
-
},
|
|
855
|
-
id:
|
|
856
|
-
text:
|
|
893
|
+
...m
|
|
894
|
+
}, v = (await e.askQuestion(C)).answer, S = {
|
|
895
|
+
id: v.questionId,
|
|
896
|
+
text: u,
|
|
857
897
|
timestamp: /* @__PURE__ */ new Date(),
|
|
858
898
|
context: {
|
|
859
|
-
tableSchema:
|
|
899
|
+
tableSchema: $,
|
|
860
900
|
rowCount: a.value.length
|
|
861
901
|
}
|
|
862
902
|
};
|
|
863
|
-
return r.value.push(
|
|
864
|
-
} catch (
|
|
865
|
-
throw n.value =
|
|
903
|
+
return r.value.push(S), c.value.push(v), l.value = v, r.value.length > w && (r.value.shift(), c.value.shift()), v;
|
|
904
|
+
} catch ($) {
|
|
905
|
+
throw n.value = $ instanceof Error ? $ : new Error("Q&A failed"), n.value;
|
|
866
906
|
} finally {
|
|
867
907
|
t.value = !1;
|
|
868
908
|
}
|
|
869
909
|
}
|
|
870
|
-
async function
|
|
910
|
+
async function N() {
|
|
871
911
|
t.value = !0, n.value = null;
|
|
872
912
|
try {
|
|
873
|
-
const
|
|
874
|
-
return await e.generateSummary(a.value,
|
|
875
|
-
} catch (
|
|
876
|
-
throw n.value =
|
|
913
|
+
const u = o.value || M(a.value);
|
|
914
|
+
return await e.generateSummary(a.value, u);
|
|
915
|
+
} catch (u) {
|
|
916
|
+
throw n.value = u instanceof Error ? u : new Error("Summary generation failed"), n.value;
|
|
877
917
|
} finally {
|
|
878
918
|
t.value = !1;
|
|
879
919
|
}
|
|
880
920
|
}
|
|
881
|
-
function
|
|
882
|
-
r.value = [],
|
|
921
|
+
function Y() {
|
|
922
|
+
r.value = [], c.value = [], l.value = null;
|
|
883
923
|
}
|
|
884
|
-
function
|
|
885
|
-
const
|
|
886
|
-
return
|
|
924
|
+
function W(u) {
|
|
925
|
+
const m = e.extractFromDOM(u);
|
|
926
|
+
return m && (a.value = m.data, o.value = m.schema), m;
|
|
887
927
|
}
|
|
888
|
-
function
|
|
889
|
-
const
|
|
890
|
-
a.value =
|
|
928
|
+
function X(u, m, $) {
|
|
929
|
+
const C = e.normalizeVueData(u, m, $);
|
|
930
|
+
a.value = C.data, o.value = C.schema;
|
|
891
931
|
}
|
|
892
|
-
function
|
|
893
|
-
e.initializeQA(
|
|
932
|
+
function Z(u) {
|
|
933
|
+
e.initializeQA(u);
|
|
894
934
|
}
|
|
895
935
|
return {
|
|
896
936
|
client: e,
|
|
@@ -900,31 +940,31 @@ function Ye(c) {
|
|
|
900
940
|
data: a,
|
|
901
941
|
schema: o,
|
|
902
942
|
questionHistory: r,
|
|
903
|
-
answerHistory:
|
|
943
|
+
answerHistory: c,
|
|
904
944
|
lastAnswer: l,
|
|
905
|
-
analyze:
|
|
906
|
-
getDescriptiveStats:
|
|
907
|
-
detectAnomalies:
|
|
908
|
-
performClustering:
|
|
909
|
-
predict:
|
|
910
|
-
askQuestion:
|
|
911
|
-
generateSummary:
|
|
912
|
-
clearHistory:
|
|
913
|
-
extractFromDOM:
|
|
914
|
-
loadFromVueGrid:
|
|
915
|
-
updateConfig:
|
|
916
|
-
initializeQA:
|
|
917
|
-
setData:
|
|
918
|
-
reset:
|
|
945
|
+
analyze: d,
|
|
946
|
+
getDescriptiveStats: A,
|
|
947
|
+
detectAnomalies: _,
|
|
948
|
+
performClustering: x,
|
|
949
|
+
predict: T,
|
|
950
|
+
askQuestion: z,
|
|
951
|
+
generateSummary: N,
|
|
952
|
+
clearHistory: Y,
|
|
953
|
+
extractFromDOM: W,
|
|
954
|
+
loadFromVueGrid: X,
|
|
955
|
+
updateConfig: D,
|
|
956
|
+
initializeQA: Z,
|
|
957
|
+
setData: F,
|
|
958
|
+
reset: I
|
|
919
959
|
};
|
|
920
960
|
}
|
|
921
|
-
const
|
|
961
|
+
const he = { class: "ti-question-input" }, fe = { class: "ti-input-wrapper" }, pe = ["placeholder", "disabled", "onKeydown"], ge = ["disabled"], we = { key: 0 }, ye = {
|
|
922
962
|
key: 1,
|
|
923
963
|
class: "ti-loading"
|
|
924
|
-
},
|
|
964
|
+
}, ve = {
|
|
925
965
|
key: 0,
|
|
926
966
|
class: "ti-hint"
|
|
927
|
-
},
|
|
967
|
+
}, be = /* @__PURE__ */ U({
|
|
928
968
|
__name: "QuestionInput",
|
|
929
969
|
props: {
|
|
930
970
|
placeholder: { default: "Ask a question about this data..." },
|
|
@@ -936,189 +976,189 @@ const me = { class: "ti-question-input" }, pe = { class: "ti-input-wrapper" }, h
|
|
|
936
976
|
loading: { type: Boolean, default: !1 }
|
|
937
977
|
},
|
|
938
978
|
emits: ["submit"],
|
|
939
|
-
setup(
|
|
940
|
-
const t =
|
|
979
|
+
setup(i, { emit: e }) {
|
|
980
|
+
const t = i, n = e, s = E("");
|
|
941
981
|
function a() {
|
|
942
982
|
s.value.trim() && !t.disabled && !t.loading && (n("submit", s.value.trim()), s.value = "");
|
|
943
983
|
}
|
|
944
984
|
function o(r) {
|
|
945
985
|
}
|
|
946
|
-
return (r,
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
"onUpdate:modelValue":
|
|
986
|
+
return (r, c) => (g(), p("div", he, [
|
|
987
|
+
h("div", fe, [
|
|
988
|
+
ee(h("textarea", {
|
|
989
|
+
"onUpdate:modelValue": c[0] || (c[0] = (l) => s.value = l),
|
|
950
990
|
placeholder: r.placeholder,
|
|
951
991
|
disabled: r.disabled,
|
|
952
992
|
class: "ti-textarea",
|
|
953
|
-
rows: "
|
|
993
|
+
rows: "1",
|
|
954
994
|
onKeydown: [
|
|
955
|
-
|
|
956
|
-
|
|
995
|
+
L(H(a, ["exact", "prevent"]), ["enter"]),
|
|
996
|
+
L(H(o, ["shift"]), ["enter"])
|
|
957
997
|
]
|
|
958
|
-
}, null, 40,
|
|
959
|
-
[
|
|
998
|
+
}, null, 40, pe), [
|
|
999
|
+
[te, s.value]
|
|
960
1000
|
]),
|
|
961
|
-
|
|
1001
|
+
h("button", {
|
|
962
1002
|
disabled: r.disabled || !s.value.trim(),
|
|
963
1003
|
class: "ti-submit-btn",
|
|
964
1004
|
onClick: a
|
|
965
1005
|
}, [
|
|
966
|
-
r.loading ? (
|
|
967
|
-
], 8,
|
|
1006
|
+
r.loading ? (g(), p("span", ye, k(r.loadingLabel), 1)) : (g(), p("span", we, k(r.submitLabel), 1))
|
|
1007
|
+
], 8, ge)
|
|
968
1008
|
]),
|
|
969
|
-
r.showHint ? (
|
|
1009
|
+
r.showHint ? (g(), p("div", ve, k(r.hint), 1)) : q("", !0)
|
|
970
1010
|
]));
|
|
971
1011
|
}
|
|
972
|
-
}),
|
|
973
|
-
const t =
|
|
1012
|
+
}), V = (i, e) => {
|
|
1013
|
+
const t = i.__vccOpts || i;
|
|
974
1014
|
for (const [n, s] of e)
|
|
975
1015
|
t[n] = s;
|
|
976
1016
|
return t;
|
|
977
|
-
},
|
|
1017
|
+
}, 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" }, De = { class: "ti-timestamp" }, Ee = { class: "ti-answer-text" }, Se = {
|
|
978
1018
|
key: 0,
|
|
979
1019
|
class: "ti-approximate-notice"
|
|
980
|
-
},
|
|
1020
|
+
}, qe = {
|
|
981
1021
|
key: 1,
|
|
982
1022
|
class: "ti-reason"
|
|
983
1023
|
}, Te = {
|
|
984
1024
|
key: 2,
|
|
985
1025
|
class: "ti-supporting-data"
|
|
986
|
-
},
|
|
1026
|
+
}, Ie = {
|
|
987
1027
|
key: 0,
|
|
988
1028
|
class: "ti-supporting-content"
|
|
989
|
-
},
|
|
1029
|
+
}, Pe = {
|
|
990
1030
|
key: 0,
|
|
991
1031
|
class: "ti-aggregates"
|
|
992
|
-
},
|
|
1032
|
+
}, Me = {
|
|
993
1033
|
key: 1,
|
|
994
1034
|
class: "ti-rows"
|
|
995
|
-
},
|
|
1035
|
+
}, Ne = { class: "ti-table-wrapper" }, ze = { class: "ti-table" }, Qe = /* @__PURE__ */ U({
|
|
996
1036
|
__name: "AnswerDisplay",
|
|
997
1037
|
props: {
|
|
998
1038
|
answer: {}
|
|
999
1039
|
},
|
|
1000
|
-
setup(
|
|
1001
|
-
const e =
|
|
1040
|
+
setup(i) {
|
|
1041
|
+
const e = E(!1);
|
|
1002
1042
|
function t(n) {
|
|
1003
1043
|
return new Date(n).toLocaleTimeString();
|
|
1004
1044
|
}
|
|
1005
|
-
return (n, s) => (
|
|
1006
|
-
class:
|
|
1045
|
+
return (n, s) => (g(), p("div", {
|
|
1046
|
+
class: ne(["ti-answer-display", { "ti-cannot-answer": n.answer.cannotAnswer }])
|
|
1007
1047
|
}, [
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
n.answer.cannotAnswer ? (
|
|
1048
|
+
h("div", Ae, [
|
|
1049
|
+
h("div", $e, [
|
|
1050
|
+
n.answer.cannotAnswer ? (g(), p("span", ke, "⚠️")) : (g(), p("span", Ce, "💡"))
|
|
1011
1051
|
]),
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1052
|
+
h("div", _e, [
|
|
1053
|
+
h("div", xe, " Confidence: " + k(Math.round(n.answer.confidence * 100)) + "% ", 1),
|
|
1054
|
+
h("div", De, k(t(n.answer.timestamp)), 1)
|
|
1015
1055
|
])
|
|
1016
1056
|
]),
|
|
1017
|
-
|
|
1018
|
-
n.answer.isApproximate ? (
|
|
1019
|
-
n.answer.reason && n.answer.cannotAnswer ? (
|
|
1020
|
-
s[1] || (s[1] =
|
|
1021
|
-
|
|
1022
|
-
])) :
|
|
1023
|
-
n.answer.supportingData ? (
|
|
1024
|
-
|
|
1057
|
+
h("div", Ee, k(n.answer.text), 1),
|
|
1058
|
+
n.answer.isApproximate ? (g(), p("div", Se, " ℹ️ This answer is based on sampled data and may be approximate. ")) : q("", !0),
|
|
1059
|
+
n.answer.reason && n.answer.cannotAnswer ? (g(), p("div", qe, [
|
|
1060
|
+
s[1] || (s[1] = h("strong", null, "Reason:", -1)),
|
|
1061
|
+
se(" " + k(n.answer.reason), 1)
|
|
1062
|
+
])) : q("", !0),
|
|
1063
|
+
n.answer.supportingData ? (g(), p("div", Te, [
|
|
1064
|
+
h("button", {
|
|
1025
1065
|
class: "ti-toggle-btn",
|
|
1026
1066
|
onClick: s[0] || (s[0] = (a) => e.value = !e.value)
|
|
1027
|
-
},
|
|
1028
|
-
e.value ? (
|
|
1029
|
-
n.answer.supportingData.aggregates ? (
|
|
1030
|
-
s[2] || (s[2] =
|
|
1031
|
-
|
|
1032
|
-
])) :
|
|
1033
|
-
n.answer.supportingData.rows && n.answer.supportingData.rows.length > 0 ? (
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
(
|
|
1067
|
+
}, k(e.value ? "▼" : "▶") + " Supporting Data ", 1),
|
|
1068
|
+
e.value ? (g(), p("div", Ie, [
|
|
1069
|
+
n.answer.supportingData.aggregates ? (g(), p("div", Pe, [
|
|
1070
|
+
s[2] || (s[2] = h("h4", null, "Aggregates:", -1)),
|
|
1071
|
+
h("pre", null, k(JSON.stringify(n.answer.supportingData.aggregates, null, 2)), 1)
|
|
1072
|
+
])) : q("", !0),
|
|
1073
|
+
n.answer.supportingData.rows && n.answer.supportingData.rows.length > 0 ? (g(), p("div", Me, [
|
|
1074
|
+
h("h4", null, "Sample Rows (" + k(n.answer.supportingData.rows.length) + "):", 1),
|
|
1075
|
+
h("div", Ne, [
|
|
1076
|
+
h("table", ze, [
|
|
1077
|
+
h("thead", null, [
|
|
1078
|
+
h("tr", null, [
|
|
1079
|
+
(g(!0), p(Q, null, j(Object.keys(n.answer.supportingData.rows[0]), (a, o) => (g(), p("th", { key: o }, k(a), 1))), 128))
|
|
1040
1080
|
])
|
|
1041
1081
|
]),
|
|
1042
|
-
|
|
1043
|
-
(
|
|
1044
|
-
(
|
|
1082
|
+
h("tbody", null, [
|
|
1083
|
+
(g(!0), p(Q, null, j(n.answer.supportingData.rows.slice(0, 5), (a, o) => (g(), p("tr", { key: o }, [
|
|
1084
|
+
(g(!0), p(Q, null, j(Object.keys(a), (r, c) => (g(), p("td", { key: c }, k(a[r]), 1))), 128))
|
|
1045
1085
|
]))), 128))
|
|
1046
1086
|
])
|
|
1047
1087
|
])
|
|
1048
1088
|
])
|
|
1049
|
-
])) :
|
|
1050
|
-
])) :
|
|
1051
|
-
])) :
|
|
1089
|
+
])) : q("", !0)
|
|
1090
|
+
])) : q("", !0)
|
|
1091
|
+
])) : q("", !0)
|
|
1052
1092
|
], 2));
|
|
1053
1093
|
}
|
|
1054
|
-
}),
|
|
1094
|
+
}), Ze = /* @__PURE__ */ V(Qe, [["__scopeId", "data-v-d1aaae1d"]]), je = { class: "ti-question-history" }, Fe = { class: "ti-history-header" }, Re = {
|
|
1055
1095
|
key: 0,
|
|
1056
1096
|
class: "ti-empty-state"
|
|
1057
|
-
},
|
|
1097
|
+
}, Ue = {
|
|
1058
1098
|
key: 1,
|
|
1059
1099
|
class: "ti-history-list"
|
|
1060
|
-
}, Ve = ["onClick"],
|
|
1100
|
+
}, Ve = ["onClick"], Le = { class: "ti-question-header" }, He = { class: "ti-question-number" }, Be = { class: "ti-question-time" }, Oe = { class: "ti-question-text" }, Je = {
|
|
1061
1101
|
key: 0,
|
|
1062
1102
|
class: "ti-question-context"
|
|
1063
|
-
},
|
|
1103
|
+
}, Ke = /* @__PURE__ */ U({
|
|
1064
1104
|
__name: "QuestionHistory",
|
|
1065
1105
|
props: {
|
|
1066
1106
|
questions: {}
|
|
1067
1107
|
},
|
|
1068
1108
|
emits: ["clear", "select"],
|
|
1069
|
-
setup(
|
|
1070
|
-
const t =
|
|
1109
|
+
setup(i, { emit: e }) {
|
|
1110
|
+
const t = i, n = ae(() => [...t.questions].reverse());
|
|
1071
1111
|
function s(a) {
|
|
1072
|
-
const o = new Date(a),
|
|
1073
|
-
return l < 1 ? "Just now" : l < 60 ? `${l}m ago` :
|
|
1112
|
+
const o = new Date(a), c = (/* @__PURE__ */ new Date()).getTime() - o.getTime(), l = Math.floor(c / 6e4), w = Math.floor(c / 36e5), f = Math.floor(c / 864e5);
|
|
1113
|
+
return l < 1 ? "Just now" : l < 60 ? `${l}m ago` : w < 24 ? `${w}h ago` : `${f}d ago`;
|
|
1074
1114
|
}
|
|
1075
|
-
return (a, o) => (
|
|
1076
|
-
|
|
1077
|
-
o[1] || (o[1] =
|
|
1078
|
-
a.questions.length > 0 ? (
|
|
1115
|
+
return (a, o) => (g(), p("div", je, [
|
|
1116
|
+
h("div", Fe, [
|
|
1117
|
+
o[1] || (o[1] = h("h3", null, "Question History", -1)),
|
|
1118
|
+
a.questions.length > 0 ? (g(), p("button", {
|
|
1079
1119
|
key: 0,
|
|
1080
1120
|
class: "ti-clear-btn",
|
|
1081
1121
|
onClick: o[0] || (o[0] = (r) => a.$emit("clear"))
|
|
1082
|
-
}, " Clear History ")) :
|
|
1122
|
+
}, " Clear History ")) : q("", !0)
|
|
1083
1123
|
]),
|
|
1084
|
-
a.questions.length === 0 ? (
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
]))) : (
|
|
1089
|
-
(
|
|
1124
|
+
a.questions.length === 0 ? (g(), p("div", Re, o[2] || (o[2] = [
|
|
1125
|
+
h("div", { class: "ti-empty-icon" }, "💬", -1),
|
|
1126
|
+
h("p", null, "No questions asked yet", -1),
|
|
1127
|
+
h("p", { class: "ti-empty-hint" }, "Ask a question about your data to get started", -1)
|
|
1128
|
+
]))) : (g(), p("div", Ue, [
|
|
1129
|
+
(g(!0), p(Q, null, j(n.value, (r, c) => (g(), p("div", {
|
|
1090
1130
|
key: r.id,
|
|
1091
1131
|
class: "ti-history-item",
|
|
1092
1132
|
onClick: (l) => a.$emit("select", r)
|
|
1093
1133
|
}, [
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1134
|
+
h("div", Le, [
|
|
1135
|
+
h("span", He, "#" + k(a.questions.length - c), 1),
|
|
1136
|
+
h("span", Be, k(s(r.timestamp)), 1)
|
|
1097
1137
|
]),
|
|
1098
|
-
|
|
1099
|
-
r.context ? (
|
|
1138
|
+
h("div", Oe, k(r.text), 1),
|
|
1139
|
+
r.context ? (g(), p("div", Je, k(r.context.rowCount) + " rows ", 1)) : q("", !0)
|
|
1100
1140
|
], 8, Ve))), 128))
|
|
1101
1141
|
]))
|
|
1102
1142
|
]));
|
|
1103
1143
|
}
|
|
1104
|
-
}),
|
|
1144
|
+
}), et = /* @__PURE__ */ V(Ke, [["__scopeId", "data-v-c66393d9"]]);
|
|
1105
1145
|
export {
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1146
|
+
Ze as AnswerDisplay,
|
|
1147
|
+
B as QAEngine,
|
|
1148
|
+
et as QuestionHistory,
|
|
1149
|
+
Xe as QuestionInput,
|
|
1150
|
+
me as TabularIntelligence,
|
|
1151
|
+
J as calculateStats,
|
|
1152
|
+
de as convertToTabular,
|
|
1153
|
+
re as detectAnomalies,
|
|
1154
|
+
G as executeAPIRequest,
|
|
1155
|
+
Ye as executeMultipleRequests,
|
|
1156
|
+
oe as extractFromDOM,
|
|
1157
|
+
O as inferColumnType,
|
|
1158
|
+
M as inferSchema,
|
|
1159
|
+
ie as normalizeVueData,
|
|
1160
|
+
le as parsePostmanCollection,
|
|
1161
|
+
P as replaceVariables,
|
|
1162
|
+
We as useTabularIntelligence
|
|
1123
1163
|
};
|
|
1124
1164
|
//# sourceMappingURL=index.mjs.map
|