@aivue/tabular-intelligence 1.3.4 → 1.3.6
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 +125 -123
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -2
package/dist/index.mjs
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
function
|
|
3
|
-
if (
|
|
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
|
+
if (c.length === 0)
|
|
4
4
|
return { columns: [], rowCount: 0, name: e };
|
|
5
|
-
const t =
|
|
5
|
+
const t = c[0];
|
|
6
6
|
return {
|
|
7
7
|
columns: Object.keys(t).map((s) => {
|
|
8
|
-
const a = O(
|
|
8
|
+
const a = O(c, s);
|
|
9
9
|
return {
|
|
10
10
|
name: s,
|
|
11
11
|
type: a,
|
|
12
|
-
nullable:
|
|
12
|
+
nullable: c.some((o) => o[s] == null)
|
|
13
13
|
};
|
|
14
14
|
}),
|
|
15
|
-
rowCount:
|
|
15
|
+
rowCount: c.length,
|
|
16
16
|
name: e
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
function O(
|
|
20
|
-
const t =
|
|
19
|
+
function O(c, e) {
|
|
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))))
|
|
23
23
|
return "number";
|
|
@@ -28,50 +28,50 @@ function O(i, 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 J(
|
|
32
|
-
const n =
|
|
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 r = n.map(Number).filter((
|
|
38
|
+
const r = n.map(Number).filter((i) => !isNaN(i));
|
|
39
39
|
if (r.length > 0) {
|
|
40
|
-
const
|
|
41
|
-
o.mean = l / r.length, o.median =
|
|
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
42
|
const w = r.reduce((f, d) => f + Math.pow(d - o.mean, 2), 0) / r.length;
|
|
43
43
|
o.std = Math.sqrt(w), o.percentiles = {
|
|
44
|
-
25:
|
|
44
|
+
25: i[Math.floor(i.length * 0.25)],
|
|
45
45
|
50: o.median,
|
|
46
|
-
75:
|
|
47
|
-
90:
|
|
46
|
+
75: i[Math.floor(i.length * 0.75)],
|
|
47
|
+
90: i[Math.floor(i.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
|
|
53
|
+
const i = {};
|
|
54
54
|
n.forEach((w) => {
|
|
55
55
|
const f = String(w);
|
|
56
|
-
|
|
56
|
+
i[f] = (i[f] || 0) + 1;
|
|
57
57
|
});
|
|
58
|
-
const l = Math.max(...Object.values(
|
|
59
|
-
o.mode = Object.keys(
|
|
58
|
+
const l = Math.max(...Object.values(i));
|
|
59
|
+
o.mode = Object.keys(i).find((w) => i[w] === l);
|
|
60
60
|
}
|
|
61
61
|
return o;
|
|
62
62
|
}
|
|
63
|
-
function re(
|
|
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 o =
|
|
66
|
+
const o = c.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, A) => y.value - A.value),
|
|
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
69
|
o.forEach(({ value: y, idx: A }) => {
|
|
70
70
|
if (y < f || y > d) {
|
|
71
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
72
|
_ ? (_.reasons.push(x), _.affectedColumns.push(a), _.score = Math.min(1, _.score + 0.2)) : n.push({
|
|
73
73
|
rowIndex: A,
|
|
74
|
-
row:
|
|
74
|
+
row: c[A],
|
|
75
75
|
score: 0.7,
|
|
76
76
|
reasons: [x],
|
|
77
77
|
affectedColumns: [a]
|
|
@@ -94,7 +94,7 @@ class B {
|
|
|
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, 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
99
|
answer: this.parseResponse(f, n, a.length > o),
|
|
100
100
|
processingTime: Date.now() - t
|
|
@@ -173,8 +173,8 @@ class B {
|
|
|
173
173
|
`, r += `Table: ${t.name}
|
|
174
174
|
`, r += `Columns:
|
|
175
175
|
`;
|
|
176
|
-
for (const
|
|
177
|
-
r += `- ${
|
|
176
|
+
for (const i of t.columns)
|
|
177
|
+
r += `- ${i.name} (${i.type})
|
|
178
178
|
`;
|
|
179
179
|
return r += `
|
|
180
180
|
`, s && Object.keys(s).length > 0 && (r += `**Summary Statistics:**
|
|
@@ -218,7 +218,7 @@ class B {
|
|
|
218
218
|
* Call OpenAI API
|
|
219
219
|
*/
|
|
220
220
|
async callOpenAI(e, t, n, s, a) {
|
|
221
|
-
var
|
|
221
|
+
var i, 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 B {
|
|
|
235
235
|
});
|
|
236
236
|
if (!o.ok)
|
|
237
237
|
throw new Error(`OpenAI API error: ${o.statusText}`);
|
|
238
|
-
return ((l = (
|
|
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
|
-
var
|
|
244
|
+
var i;
|
|
245
245
|
const o = await fetch("https://api.anthropic.com/v1/messages", {
|
|
246
246
|
method: "POST",
|
|
247
247
|
headers: {
|
|
@@ -258,7 +258,7 @@ class B {
|
|
|
258
258
|
});
|
|
259
259
|
if (!o.ok)
|
|
260
260
|
throw new Error(`Anthropic API error: ${o.statusText}`);
|
|
261
|
-
return ((
|
|
261
|
+
return ((i = (await o.json()).content[0]) == null ? void 0 : i.text) || "";
|
|
262
262
|
}
|
|
263
263
|
/**
|
|
264
264
|
* Call custom API
|
|
@@ -311,52 +311,52 @@ class B {
|
|
|
311
311
|
return `qa_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
|
-
function oe(
|
|
314
|
+
function oe(c = {}) {
|
|
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
|
+
} = c, 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 i = Array.from(o.rows);
|
|
325
|
+
if (i.length === 0)
|
|
326
326
|
return null;
|
|
327
327
|
let l = [], w = 0;
|
|
328
|
-
if (t &&
|
|
329
|
-
const A =
|
|
328
|
+
if (t && i[0]) {
|
|
329
|
+
const A = i[0];
|
|
330
330
|
l = Array.from(A.cells).map((_, x) => {
|
|
331
|
-
var
|
|
332
|
-
return ((
|
|
331
|
+
var E;
|
|
332
|
+
return ((E = _.textContent) == null ? void 0 : E.trim()) || "" || `Column${x + 1}`;
|
|
333
333
|
}), w = 1;
|
|
334
334
|
} else {
|
|
335
|
-
const A =
|
|
335
|
+
const A = i[0];
|
|
336
336
|
l = Array.from(A.cells).map((_, x) => `Column${x + 1}`);
|
|
337
337
|
}
|
|
338
|
-
const f = [], d = n ?
|
|
338
|
+
const f = [], d = n ? i.slice(w, w + n) : i.slice(w);
|
|
339
339
|
for (const A of d) {
|
|
340
340
|
const _ = Array.from(A.cells);
|
|
341
341
|
if (a && _.every((T) => {
|
|
342
|
-
var
|
|
343
|
-
return !((
|
|
342
|
+
var E;
|
|
343
|
+
return !((E = T.textContent) != null && E.trim());
|
|
344
344
|
}))
|
|
345
345
|
continue;
|
|
346
346
|
const x = {};
|
|
347
|
-
_.forEach((T,
|
|
347
|
+
_.forEach((T, E) => {
|
|
348
348
|
var z;
|
|
349
|
-
const F = l[
|
|
349
|
+
const F = l[E] || `Column${E + 1}`;
|
|
350
350
|
let I = ((z = T.textContent) == null ? void 0 : z.trim()) || "";
|
|
351
351
|
if (s && I) {
|
|
352
|
-
const
|
|
353
|
-
!isNaN(
|
|
352
|
+
const M = parseFloat(I);
|
|
353
|
+
!isNaN(M) && I === M.toString() && (I = M);
|
|
354
354
|
}
|
|
355
355
|
x[F] = I;
|
|
356
356
|
}), f.push(x);
|
|
357
357
|
}
|
|
358
358
|
return {
|
|
359
|
-
schema: s && f.length > 0 ?
|
|
359
|
+
schema: s && f.length > 0 ? N(f, "Extracted Table") : ce(l, f.length),
|
|
360
360
|
data: f,
|
|
361
361
|
source: "dom",
|
|
362
362
|
metadata: {
|
|
@@ -367,8 +367,8 @@ function oe(i = {}) {
|
|
|
367
367
|
}
|
|
368
368
|
};
|
|
369
369
|
}
|
|
370
|
-
function ie(
|
|
371
|
-
const { maxRows: n, inferTypes: s = !0 } = t, a = n ?
|
|
370
|
+
function ie(c, e, t = {}) {
|
|
371
|
+
const { maxRows: n, inferTypes: s = !0 } = t, a = n ? c.slice(0, n) : c;
|
|
372
372
|
let o;
|
|
373
373
|
return e && e.length > 0 ? o = {
|
|
374
374
|
name: "Vue Data Grid",
|
|
@@ -378,7 +378,7 @@ function ie(i, e, t = {}) {
|
|
|
378
378
|
nullable: !0
|
|
379
379
|
})),
|
|
380
380
|
rowCount: a.length
|
|
381
|
-
} : a.length > 0 ? o =
|
|
381
|
+
} : a.length > 0 ? o = N(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 ie(i, e, t = {}) {
|
|
|
389
389
|
}
|
|
390
390
|
};
|
|
391
391
|
}
|
|
392
|
-
function ce(
|
|
392
|
+
function ce(c, e = 0) {
|
|
393
393
|
return {
|
|
394
394
|
name: "Extracted Table",
|
|
395
|
-
columns:
|
|
395
|
+
columns: c.map((t) => ({
|
|
396
396
|
name: t,
|
|
397
397
|
type: "string",
|
|
398
398
|
nullable: !0
|
|
@@ -400,27 +400,27 @@ function ce(i, e = 0) {
|
|
|
400
400
|
rowCount: e
|
|
401
401
|
};
|
|
402
402
|
}
|
|
403
|
-
function le(
|
|
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 =
|
|
408
|
+
const t = c.auth ? K(c.auth) : void 0, n = [];
|
|
409
409
|
function s(a, o = "") {
|
|
410
410
|
a.forEach((r) => {
|
|
411
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(c.item), {
|
|
415
|
+
name: c.info.name,
|
|
416
|
+
description: c.info.description,
|
|
417
417
|
endpoints: n,
|
|
418
418
|
variables: e,
|
|
419
419
|
auth: t
|
|
420
420
|
};
|
|
421
421
|
}
|
|
422
|
-
function ue(
|
|
423
|
-
const t =
|
|
422
|
+
function ue(c, e) {
|
|
423
|
+
const t = c.request, n = {};
|
|
424
424
|
t.header && t.header.forEach((o) => {
|
|
425
425
|
n[o.key] = o.value;
|
|
426
426
|
});
|
|
@@ -430,7 +430,7 @@ function ue(i, e) {
|
|
|
430
430
|
});
|
|
431
431
|
const a = t.auth ? K(t.auth) : e;
|
|
432
432
|
return {
|
|
433
|
-
name:
|
|
433
|
+
name: c.name,
|
|
434
434
|
method: t.method,
|
|
435
435
|
url: t.url.raw,
|
|
436
436
|
description: t.description,
|
|
@@ -439,54 +439,54 @@ function ue(i, e) {
|
|
|
439
439
|
auth: a
|
|
440
440
|
};
|
|
441
441
|
}
|
|
442
|
-
function K(
|
|
442
|
+
function K(c) {
|
|
443
443
|
const e = {};
|
|
444
|
-
return
|
|
444
|
+
return c.apikey ? c.apikey.forEach((t) => {
|
|
445
445
|
e[t.key] = t.value;
|
|
446
|
-
}) :
|
|
446
|
+
}) : c.bearer ? c.bearer.forEach((t) => {
|
|
447
447
|
e[t.key] = t.value;
|
|
448
|
-
}) :
|
|
448
|
+
}) : c.basic && c.basic.forEach((t) => {
|
|
449
449
|
e[t.key] = t.value;
|
|
450
450
|
}), {
|
|
451
|
-
type:
|
|
451
|
+
type: c.type,
|
|
452
452
|
credentials: e
|
|
453
453
|
};
|
|
454
454
|
}
|
|
455
|
-
function P(
|
|
456
|
-
let t =
|
|
455
|
+
function P(c, e) {
|
|
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 G(
|
|
463
|
-
const { endpoint: e, variables: t = {}, additionalHeaders: n = {}, additionalParams: s = {} } =
|
|
462
|
+
async function G(c) {
|
|
463
|
+
const { endpoint: e, variables: t = {}, additionalHeaders: n = {}, additionalParams: s = {} } = c;
|
|
464
464
|
try {
|
|
465
465
|
let a = P(e.url, t);
|
|
466
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 i = {
|
|
469
469
|
"Content-Type": "application/json",
|
|
470
470
|
...e.headers,
|
|
471
471
|
...n
|
|
472
472
|
};
|
|
473
|
-
if (Object.keys(
|
|
474
|
-
|
|
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
477
|
const d = e.auth.credentials.key || "access_key", y = P(e.auth.credentials.value || "", t);
|
|
478
|
-
e.auth.credentials.in === "header" && (
|
|
478
|
+
e.auth.credentials.in === "header" && (i[d] = y);
|
|
479
479
|
} else if (e.auth.type === "bearer") {
|
|
480
480
|
const d = P(e.auth.credentials.token || "", t);
|
|
481
|
-
|
|
481
|
+
i.Authorization = `Bearer ${d}`;
|
|
482
482
|
} else if (e.auth.type === "basic") {
|
|
483
483
|
const d = P(e.auth.credentials.username || "", t), y = P(e.auth.credentials.password || "", t), A = btoa(`${d}:${y}`);
|
|
484
|
-
|
|
484
|
+
i.Authorization = `Basic ${A}`;
|
|
485
485
|
}
|
|
486
486
|
}
|
|
487
487
|
const l = await fetch(a, {
|
|
488
488
|
method: e.method,
|
|
489
|
-
headers:
|
|
489
|
+
headers: i
|
|
490
490
|
}), w = {};
|
|
491
491
|
return l.headers.forEach((d, y) => {
|
|
492
492
|
w[y] = d;
|
|
@@ -508,18 +508,18 @@ async function G(i) {
|
|
|
508
508
|
};
|
|
509
509
|
}
|
|
510
510
|
}
|
|
511
|
-
async function Ye(
|
|
511
|
+
async function Ye(c, e = {}) {
|
|
512
512
|
const t = [];
|
|
513
|
-
for (const n of
|
|
513
|
+
for (const n of c) {
|
|
514
514
|
const s = await G({ endpoint: n, variables: e });
|
|
515
515
|
t.push(s);
|
|
516
516
|
}
|
|
517
517
|
return t;
|
|
518
518
|
}
|
|
519
|
-
function de(
|
|
520
|
-
if (!
|
|
519
|
+
function de(c) {
|
|
520
|
+
if (!c.success || !c.data)
|
|
521
521
|
return [];
|
|
522
|
-
const e =
|
|
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
525
|
class me {
|
|
@@ -723,7 +723,7 @@ class me {
|
|
|
723
723
|
async fetchDataFromAPI(e, t) {
|
|
724
724
|
if (!this.parsedCollection)
|
|
725
725
|
throw new Error("No Postman collection loaded. Call loadPostmanCollection() first.");
|
|
726
|
-
const n = this.parsedCollection.endpoints.find((
|
|
726
|
+
const n = this.parsedCollection.endpoints.find((i) => i.name === e);
|
|
727
727
|
if (!n)
|
|
728
728
|
throw new Error(`Endpoint "${e}" not found in collection.`);
|
|
729
729
|
const s = {
|
|
@@ -732,7 +732,7 @@ class me {
|
|
|
732
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 o = de(a), r =
|
|
735
|
+
const o = de(a), r = N(o);
|
|
736
736
|
return { data: o, schema: r };
|
|
737
737
|
}
|
|
738
738
|
/**
|
|
@@ -767,12 +767,12 @@ class me {
|
|
|
767
767
|
})) : [];
|
|
768
768
|
}
|
|
769
769
|
}
|
|
770
|
-
function We(
|
|
771
|
-
const e = new me(
|
|
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
772
|
async function d(u, m) {
|
|
773
773
|
t.value = !0, n.value = null;
|
|
774
774
|
try {
|
|
775
|
-
if (
|
|
775
|
+
if (c.config.provider === "local" || f) {
|
|
776
776
|
console.log("🔧 Using local analysis (no API call)");
|
|
777
777
|
const b = y(u, m);
|
|
778
778
|
return s.value = b, b;
|
|
@@ -793,7 +793,7 @@ function We(i) {
|
|
|
793
793
|
}
|
|
794
794
|
}
|
|
795
795
|
function y(u, m) {
|
|
796
|
-
const $ = o.value ||
|
|
796
|
+
const $ = o.value || N(a.value);
|
|
797
797
|
switch (u) {
|
|
798
798
|
case "descriptive_stats": {
|
|
799
799
|
const C = $.columns.map(
|
|
@@ -872,19 +872,21 @@ function We(i) {
|
|
|
872
872
|
async function T(u, m) {
|
|
873
873
|
return d("prediction", { targetColumn: u, ...m });
|
|
874
874
|
}
|
|
875
|
-
function
|
|
875
|
+
function E(u) {
|
|
876
876
|
e.updateConfig(u);
|
|
877
877
|
}
|
|
878
878
|
function F(u, m = !0) {
|
|
879
|
-
a.value = u, m && (o.value =
|
|
879
|
+
a.value = u, m && (o.value = N(u));
|
|
880
880
|
}
|
|
881
881
|
function I() {
|
|
882
|
-
t.value = !1, n.value = null, s.value = null, r.value = [],
|
|
882
|
+
t.value = !1, n.value = null, s.value = null, r.value = [], i.value = [], l.value = null;
|
|
883
883
|
}
|
|
884
884
|
async function z(u, m) {
|
|
885
885
|
t.value = !0, n.value = null;
|
|
886
886
|
try {
|
|
887
|
-
|
|
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 = {
|
|
888
890
|
question: u,
|
|
889
891
|
schema: $,
|
|
890
892
|
data: a.value,
|
|
@@ -900,17 +902,17 @@ function We(i) {
|
|
|
900
902
|
rowCount: a.value.length
|
|
901
903
|
}
|
|
902
904
|
};
|
|
903
|
-
return r.value.push(S),
|
|
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;
|
|
904
906
|
} catch ($) {
|
|
905
907
|
throw n.value = $ instanceof Error ? $ : new Error("Q&A failed"), n.value;
|
|
906
908
|
} finally {
|
|
907
909
|
t.value = !1;
|
|
908
910
|
}
|
|
909
911
|
}
|
|
910
|
-
async function
|
|
912
|
+
async function M() {
|
|
911
913
|
t.value = !0, n.value = null;
|
|
912
914
|
try {
|
|
913
|
-
const u = o.value ||
|
|
915
|
+
const u = o.value || N(a.value);
|
|
914
916
|
return await e.generateSummary(a.value, u);
|
|
915
917
|
} catch (u) {
|
|
916
918
|
throw n.value = u instanceof Error ? u : new Error("Summary generation failed"), n.value;
|
|
@@ -919,7 +921,7 @@ function We(i) {
|
|
|
919
921
|
}
|
|
920
922
|
}
|
|
921
923
|
function Y() {
|
|
922
|
-
r.value = [],
|
|
924
|
+
r.value = [], i.value = [], l.value = null;
|
|
923
925
|
}
|
|
924
926
|
function W(u) {
|
|
925
927
|
const m = e.extractFromDOM(u);
|
|
@@ -940,7 +942,7 @@ function We(i) {
|
|
|
940
942
|
data: a,
|
|
941
943
|
schema: o,
|
|
942
944
|
questionHistory: r,
|
|
943
|
-
answerHistory:
|
|
945
|
+
answerHistory: i,
|
|
944
946
|
lastAnswer: l,
|
|
945
947
|
analyze: d,
|
|
946
948
|
getDescriptiveStats: A,
|
|
@@ -948,11 +950,11 @@ function We(i) {
|
|
|
948
950
|
performClustering: x,
|
|
949
951
|
predict: T,
|
|
950
952
|
askQuestion: z,
|
|
951
|
-
generateSummary:
|
|
953
|
+
generateSummary: M,
|
|
952
954
|
clearHistory: Y,
|
|
953
955
|
extractFromDOM: W,
|
|
954
956
|
loadFromVueGrid: X,
|
|
955
|
-
updateConfig:
|
|
957
|
+
updateConfig: E,
|
|
956
958
|
initializeQA: Z,
|
|
957
959
|
setData: F,
|
|
958
960
|
reset: I
|
|
@@ -976,17 +978,17 @@ const he = { class: "ti-question-input" }, fe = { class: "ti-input-wrapper" }, p
|
|
|
976
978
|
loading: { type: Boolean, default: !1 }
|
|
977
979
|
},
|
|
978
980
|
emits: ["submit"],
|
|
979
|
-
setup(
|
|
980
|
-
const t =
|
|
981
|
+
setup(c, { emit: e }) {
|
|
982
|
+
const t = c, n = e, s = D("");
|
|
981
983
|
function a() {
|
|
982
984
|
s.value.trim() && !t.disabled && !t.loading && (n("submit", s.value.trim()), s.value = "");
|
|
983
985
|
}
|
|
984
986
|
function o(r) {
|
|
985
987
|
}
|
|
986
|
-
return (r,
|
|
988
|
+
return (r, i) => (g(), p("div", he, [
|
|
987
989
|
h("div", fe, [
|
|
988
990
|
ee(h("textarea", {
|
|
989
|
-
"onUpdate:modelValue":
|
|
991
|
+
"onUpdate:modelValue": i[0] || (i[0] = (l) => s.value = l),
|
|
990
992
|
placeholder: r.placeholder,
|
|
991
993
|
disabled: r.disabled,
|
|
992
994
|
class: "ti-textarea",
|
|
@@ -1009,12 +1011,12 @@ const he = { class: "ti-question-input" }, fe = { class: "ti-input-wrapper" }, p
|
|
|
1009
1011
|
r.showHint ? (g(), p("div", ve, k(r.hint), 1)) : q("", !0)
|
|
1010
1012
|
]));
|
|
1011
1013
|
}
|
|
1012
|
-
}), V = (
|
|
1013
|
-
const t =
|
|
1014
|
+
}), V = (c, e) => {
|
|
1015
|
+
const t = c.__vccOpts || c;
|
|
1014
1016
|
for (const [n, s] of e)
|
|
1015
1017
|
t[n] = s;
|
|
1016
1018
|
return t;
|
|
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" },
|
|
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 = {
|
|
1018
1020
|
key: 0,
|
|
1019
1021
|
class: "ti-approximate-notice"
|
|
1020
1022
|
}, qe = {
|
|
@@ -1029,16 +1031,16 @@ const he = { class: "ti-question-input" }, fe = { class: "ti-input-wrapper" }, p
|
|
|
1029
1031
|
}, Pe = {
|
|
1030
1032
|
key: 0,
|
|
1031
1033
|
class: "ti-aggregates"
|
|
1032
|
-
},
|
|
1034
|
+
}, Ne = {
|
|
1033
1035
|
key: 1,
|
|
1034
1036
|
class: "ti-rows"
|
|
1035
|
-
},
|
|
1037
|
+
}, Me = { class: "ti-table-wrapper" }, ze = { class: "ti-table" }, Qe = /* @__PURE__ */ U({
|
|
1036
1038
|
__name: "AnswerDisplay",
|
|
1037
1039
|
props: {
|
|
1038
1040
|
answer: {}
|
|
1039
1041
|
},
|
|
1040
|
-
setup(
|
|
1041
|
-
const e =
|
|
1042
|
+
setup(c) {
|
|
1043
|
+
const e = D(!1);
|
|
1042
1044
|
function t(n) {
|
|
1043
1045
|
return new Date(n).toLocaleTimeString();
|
|
1044
1046
|
}
|
|
@@ -1051,10 +1053,10 @@ const he = { class: "ti-question-input" }, fe = { class: "ti-input-wrapper" }, p
|
|
|
1051
1053
|
]),
|
|
1052
1054
|
h("div", _e, [
|
|
1053
1055
|
h("div", xe, " Confidence: " + k(Math.round(n.answer.confidence * 100)) + "% ", 1),
|
|
1054
|
-
h("div",
|
|
1056
|
+
h("div", Ee, k(t(n.answer.timestamp)), 1)
|
|
1055
1057
|
])
|
|
1056
1058
|
]),
|
|
1057
|
-
h("div",
|
|
1059
|
+
h("div", De, k(n.answer.text), 1),
|
|
1058
1060
|
n.answer.isApproximate ? (g(), p("div", Se, " ℹ️ This answer is based on sampled data and may be approximate. ")) : q("", !0),
|
|
1059
1061
|
n.answer.reason && n.answer.cannotAnswer ? (g(), p("div", qe, [
|
|
1060
1062
|
s[1] || (s[1] = h("strong", null, "Reason:", -1)),
|
|
@@ -1070,9 +1072,9 @@ const he = { class: "ti-question-input" }, fe = { class: "ti-input-wrapper" }, p
|
|
|
1070
1072
|
s[2] || (s[2] = h("h4", null, "Aggregates:", -1)),
|
|
1071
1073
|
h("pre", null, k(JSON.stringify(n.answer.supportingData.aggregates, null, 2)), 1)
|
|
1072
1074
|
])) : q("", !0),
|
|
1073
|
-
n.answer.supportingData.rows && n.answer.supportingData.rows.length > 0 ? (g(), p("div",
|
|
1075
|
+
n.answer.supportingData.rows && n.answer.supportingData.rows.length > 0 ? (g(), p("div", Ne, [
|
|
1074
1076
|
h("h4", null, "Sample Rows (" + k(n.answer.supportingData.rows.length) + "):", 1),
|
|
1075
|
-
h("div",
|
|
1077
|
+
h("div", Me, [
|
|
1076
1078
|
h("table", ze, [
|
|
1077
1079
|
h("thead", null, [
|
|
1078
1080
|
h("tr", null, [
|
|
@@ -1081,7 +1083,7 @@ const he = { class: "ti-question-input" }, fe = { class: "ti-input-wrapper" }, p
|
|
|
1081
1083
|
]),
|
|
1082
1084
|
h("tbody", null, [
|
|
1083
1085
|
(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,
|
|
1086
|
+
(g(!0), p(Q, null, j(Object.keys(a), (r, i) => (g(), p("td", { key: i }, k(a[r]), 1))), 128))
|
|
1085
1087
|
]))), 128))
|
|
1086
1088
|
])
|
|
1087
1089
|
])
|
|
@@ -1106,10 +1108,10 @@ const he = { class: "ti-question-input" }, fe = { class: "ti-input-wrapper" }, p
|
|
|
1106
1108
|
questions: {}
|
|
1107
1109
|
},
|
|
1108
1110
|
emits: ["clear", "select"],
|
|
1109
|
-
setup(
|
|
1110
|
-
const t =
|
|
1111
|
+
setup(c, { emit: e }) {
|
|
1112
|
+
const t = c, n = ae(() => [...t.questions].reverse());
|
|
1111
1113
|
function s(a) {
|
|
1112
|
-
const o = new Date(a),
|
|
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);
|
|
1113
1115
|
return l < 1 ? "Just now" : l < 60 ? `${l}m ago` : w < 24 ? `${w}h ago` : `${f}d ago`;
|
|
1114
1116
|
}
|
|
1115
1117
|
return (a, o) => (g(), p("div", je, [
|
|
@@ -1126,13 +1128,13 @@ const he = { class: "ti-question-input" }, fe = { class: "ti-input-wrapper" }, p
|
|
|
1126
1128
|
h("p", null, "No questions asked yet", -1),
|
|
1127
1129
|
h("p", { class: "ti-empty-hint" }, "Ask a question about your data to get started", -1)
|
|
1128
1130
|
]))) : (g(), p("div", Ue, [
|
|
1129
|
-
(g(!0), p(Q, null, j(n.value, (r,
|
|
1131
|
+
(g(!0), p(Q, null, j(n.value, (r, i) => (g(), p("div", {
|
|
1130
1132
|
key: r.id,
|
|
1131
1133
|
class: "ti-history-item",
|
|
1132
1134
|
onClick: (l) => a.$emit("select", r)
|
|
1133
1135
|
}, [
|
|
1134
1136
|
h("div", Le, [
|
|
1135
|
-
h("span", He, "#" + k(a.questions.length -
|
|
1137
|
+
h("span", He, "#" + k(a.questions.length - i), 1),
|
|
1136
1138
|
h("span", Be, k(s(r.timestamp)), 1)
|
|
1137
1139
|
]),
|
|
1138
1140
|
h("div", Oe, k(r.text), 1),
|
|
@@ -1155,7 +1157,7 @@ export {
|
|
|
1155
1157
|
Ye as executeMultipleRequests,
|
|
1156
1158
|
oe as extractFromDOM,
|
|
1157
1159
|
O as inferColumnType,
|
|
1158
|
-
|
|
1160
|
+
N as inferSchema,
|
|
1159
1161
|
ie as normalizeVueData,
|
|
1160
1162
|
le as parsePostmanCollection,
|
|
1161
1163
|
P as replaceVariables,
|