@aivue/tabular-intelligence 1.2.0 → 1.3.1
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/core/TabularIntelligence.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +282 -280
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/apiClient.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
function
|
|
1
|
+
import { ref as S, defineComponent as z, createElementBlock as p, openBlock as f, createElementVNode as m, createCommentVNode as q, withDirectives as Z, withKeys as R, withModifiers as V, vModelText as ee, toDisplayString as A, normalizeClass as te, createTextVNode as ne, Fragment as O, renderList as Q, computed as se } from "vue";
|
|
2
|
+
function P(c, e) {
|
|
3
3
|
if (c.length === 0)
|
|
4
4
|
return { columns: [], rowCount: 0, name: e };
|
|
5
5
|
const t = c[0];
|
|
@@ -9,7 +9,7 @@ function N(c, e) {
|
|
|
9
9
|
return {
|
|
10
10
|
name: s,
|
|
11
11
|
type: a,
|
|
12
|
-
nullable: c.some((
|
|
12
|
+
nullable: c.some((r) => r[s] == null)
|
|
13
13
|
};
|
|
14
14
|
}),
|
|
15
15
|
rowCount: c.length,
|
|
@@ -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 H(c, e, t) {
|
|
32
|
+
const n = c.map((o) => o[e]).filter((o) => o != null), s = n.length, a = c.length - s, r = {
|
|
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 g =
|
|
43
|
-
|
|
38
|
+
const o = n.map(Number).filter((i) => !isNaN(i));
|
|
39
|
+
if (o.length > 0) {
|
|
40
|
+
const i = [...o].sort((h, u) => h - u), l = o.reduce((h, u) => h + u, 0);
|
|
41
|
+
r.mean = l / o.length, r.median = i[Math.floor(i.length / 2)], r.min = i[0], r.max = i[i.length - 1];
|
|
42
|
+
const g = o.reduce((h, u) => h + Math.pow(u - r.mean, 2), 0) / o.length;
|
|
43
|
+
r.std = Math.sqrt(g), r.percentiles = {
|
|
44
44
|
25: i[Math.floor(i.length * 0.25)],
|
|
45
|
-
50:
|
|
45
|
+
50: r.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 o = new Set(n);
|
|
52
|
+
r.uniqueValues = o.size;
|
|
53
53
|
const i = {};
|
|
54
54
|
n.forEach((g) => {
|
|
55
|
-
const
|
|
56
|
-
i[
|
|
55
|
+
const h = String(g);
|
|
56
|
+
i[h] = (i[h] || 0) + 1;
|
|
57
57
|
});
|
|
58
58
|
const l = Math.max(...Object.values(i));
|
|
59
|
-
|
|
59
|
+
r.mode = Object.keys(i).find((g) => i[g] === l);
|
|
60
60
|
}
|
|
61
|
-
return
|
|
61
|
+
return r;
|
|
62
62
|
}
|
|
63
63
|
function ae(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 $ = n.find((
|
|
72
|
-
$ ? ($.reasons.push(
|
|
66
|
+
const r = c.map((w, v) => ({ value: Number(w[a]), idx: v })).filter((w) => !isNaN(w.value));
|
|
67
|
+
if (r.length === 0) return;
|
|
68
|
+
const o = [...r].sort((w, v) => w.value - v.value), i = o[Math.floor(o.length * 0.25)].value, l = o[Math.floor(o.length * 0.75)].value, g = l - i, h = i - s * g, u = l + s * g;
|
|
69
|
+
r.forEach(({ value: w, idx: v }) => {
|
|
70
|
+
if (w < h || w > u) {
|
|
71
|
+
const $ = n.find((E) => E.rowIndex === v), k = w < h ? `${a}: ${w.toFixed(2)} < ${h.toFixed(2)}` : `${a}: ${w.toFixed(2)} > ${u.toFixed(2)}`;
|
|
72
|
+
$ ? ($.reasons.push(k), $.affectedColumns.push(a), $.score = Math.min(1, $.score + 0.2)) : n.push({
|
|
73
73
|
rowIndex: v,
|
|
74
74
|
row: c[v],
|
|
75
75
|
score: 0.7,
|
|
76
|
-
reasons: [
|
|
76
|
+
reasons: [k],
|
|
77
77
|
affectedColumns: [a]
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
|
-
}), n.sort((a,
|
|
81
|
+
}), n.sort((a, r) => r.score - a.score);
|
|
82
82
|
}
|
|
83
|
-
class
|
|
83
|
+
class U {
|
|
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:
|
|
97
|
+
const { question: n, schema: s, data: a = [], sampleSize: r = 100, includeAggregates: o = !0 } = e, i = a.length > r ? this.sampleData(a, r) : a, l = o ? this.calculateAggregates(a, s) : void 0, g = this.buildPrompt(n, s, i, l, a.length), h = await this.callLLM(g);
|
|
98
98
|
return {
|
|
99
|
-
answer: this.parseResponse(
|
|
99
|
+
answer: this.parseResponse(h, n, a.length > r),
|
|
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 = H(e, s.name, "number");
|
|
136
136
|
n[s.name] = {
|
|
137
137
|
mean: a.mean,
|
|
138
138
|
median: a.median,
|
|
@@ -143,9 +143,9 @@ class H {
|
|
|
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((o) => o[s.name]).filter((o) => o != null), r = new Set(a);
|
|
147
147
|
n[s.name] = {
|
|
148
|
-
uniqueCount:
|
|
148
|
+
uniqueCount: r.size,
|
|
149
149
|
totalCount: a.length,
|
|
150
150
|
topValues: this.getTopValues(a, 5)
|
|
151
151
|
};
|
|
@@ -165,51 +165,51 @@ class H {
|
|
|
165
165
|
* Build prompt for LLM
|
|
166
166
|
*/
|
|
167
167
|
buildPrompt(e, t, n, s, a) {
|
|
168
|
-
const
|
|
169
|
-
let
|
|
168
|
+
const r = a && a > n.length;
|
|
169
|
+
let o = `You are a data analyst assistant. Answer the following question about a table dataset.
|
|
170
170
|
|
|
171
171
|
`;
|
|
172
|
-
|
|
173
|
-
`,
|
|
174
|
-
`,
|
|
172
|
+
o += `**Table Schema:**
|
|
173
|
+
`, o += `Table: ${t.name}
|
|
174
|
+
`, o += `Columns:
|
|
175
175
|
`;
|
|
176
176
|
for (const i of t.columns)
|
|
177
|
-
|
|
177
|
+
o += `- ${i.name} (${i.type})
|
|
178
178
|
`;
|
|
179
|
-
return
|
|
180
|
-
`, s && Object.keys(s).length > 0 && (
|
|
181
|
-
`,
|
|
179
|
+
return o += `
|
|
180
|
+
`, s && Object.keys(s).length > 0 && (o += `**Summary Statistics:**
|
|
181
|
+
`, o += JSON.stringify(s, null, 2), o += `
|
|
182
182
|
|
|
183
|
-
`),
|
|
184
|
-
`,
|
|
183
|
+
`), o += `**Sample Data** (${n.length} rows${r ? ` out of ${a} total` : ""}):
|
|
184
|
+
`, o += JSON.stringify(n.slice(0, 10), null, 2), o += `
|
|
185
185
|
|
|
186
|
-
`,
|
|
186
|
+
`, o += `**Question:** ${e}
|
|
187
187
|
|
|
188
|
-
`,
|
|
189
|
-
`,
|
|
190
|
-
`,
|
|
191
|
-
`,
|
|
192
|
-
`,
|
|
193
|
-
`,
|
|
194
|
-
`,
|
|
195
|
-
`,
|
|
196
|
-
`,
|
|
197
|
-
`,
|
|
198
|
-
`,
|
|
199
|
-
`,
|
|
200
|
-
`,
|
|
201
|
-
`,
|
|
202
|
-
`,
|
|
188
|
+
`, o += `**Instructions:**
|
|
189
|
+
`, o += `1. Answer ONLY based on the data provided above.
|
|
190
|
+
`, o += `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
|
+
`, o += `3. Provide a clear, concise answer.
|
|
192
|
+
`, o += `4. Include specific numbers or examples from the data when relevant.
|
|
193
|
+
`, o += `5. If the answer is based on sampled data, mention that it's an approximation.
|
|
194
|
+
`, o += `6. Format your response as JSON with the following structure:
|
|
195
|
+
`, o += `{
|
|
196
|
+
`, o += ` "answer": "Your answer text here",
|
|
197
|
+
`, o += ` "confidence": 0.0-1.0,
|
|
198
|
+
`, o += ` "cannotAnswer": false,
|
|
199
|
+
`, o += ` "isApproximate": ${r},
|
|
200
|
+
`, o += ` "supportingData": { "key": "value" } // optional
|
|
201
|
+
`, o += `}
|
|
202
|
+
`, o;
|
|
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: r, temperature: o } = 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", r, o);
|
|
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", r, o);
|
|
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 H {
|
|
|
219
219
|
*/
|
|
220
220
|
async callOpenAI(e, t, n, s, a) {
|
|
221
221
|
var i, l;
|
|
222
|
-
const
|
|
222
|
+
const r = 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 H {
|
|
|
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 (!r.ok)
|
|
237
|
+
throw new Error(`OpenAI API error: ${r.statusText}`);
|
|
238
|
+
return ((l = (i = (await r.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 r = 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 H {
|
|
|
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 (!r.ok)
|
|
260
|
+
throw new Error(`Anthropic API error: ${r.statusText}`);
|
|
261
|
+
return ((i = (await r.json()).content[0]) == null ? void 0 : i.text) || "";
|
|
262
262
|
}
|
|
263
263
|
/**
|
|
264
264
|
* Call custom API
|
|
@@ -275,8 +275,8 @@ class H {
|
|
|
275
275
|
});
|
|
276
276
|
if (!a.ok)
|
|
277
277
|
throw new Error(`Custom API error: ${a.statusText}`);
|
|
278
|
-
const
|
|
279
|
-
return
|
|
278
|
+
const r = await a.json();
|
|
279
|
+
return r.response || r.answer || JSON.stringify(r);
|
|
280
280
|
}
|
|
281
281
|
/**
|
|
282
282
|
* Parse LLM response
|
|
@@ -311,80 +311,80 @@ class H {
|
|
|
311
311
|
return `qa_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
|
-
function
|
|
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
|
-
} = c,
|
|
322
|
-
if (!
|
|
321
|
+
} = c, r = document.querySelector(e);
|
|
322
|
+
if (!r || r.tagName !== "TABLE")
|
|
323
323
|
return console.warn(`No table found with selector: ${e}`), null;
|
|
324
|
-
const i = Array.from(
|
|
324
|
+
const i = Array.from(r.rows);
|
|
325
325
|
if (i.length === 0)
|
|
326
326
|
return null;
|
|
327
327
|
let l = [], g = 0;
|
|
328
328
|
if (t && i[0]) {
|
|
329
329
|
const v = i[0];
|
|
330
|
-
l = Array.from(v.cells).map(($,
|
|
330
|
+
l = Array.from(v.cells).map(($, k) => {
|
|
331
331
|
var _;
|
|
332
|
-
return ((_ = $.textContent) == null ? void 0 : _.trim()) || "" || `Column${
|
|
332
|
+
return ((_ = $.textContent) == null ? void 0 : _.trim()) || "" || `Column${k + 1}`;
|
|
333
333
|
}), g = 1;
|
|
334
334
|
} else {
|
|
335
335
|
const v = i[0];
|
|
336
|
-
l = Array.from(v.cells).map(($,
|
|
336
|
+
l = Array.from(v.cells).map(($, k) => `Column${k + 1}`);
|
|
337
337
|
}
|
|
338
|
-
const
|
|
339
|
-
for (const v of
|
|
338
|
+
const h = [], u = n ? i.slice(g, g + n) : i.slice(g);
|
|
339
|
+
for (const v of u) {
|
|
340
340
|
const $ = Array.from(v.cells);
|
|
341
|
-
if (a && $.every((
|
|
341
|
+
if (a && $.every((E) => {
|
|
342
342
|
var _;
|
|
343
|
-
return !((_ =
|
|
343
|
+
return !((_ = E.textContent) != null && _.trim());
|
|
344
344
|
}))
|
|
345
345
|
continue;
|
|
346
|
-
const
|
|
347
|
-
$.forEach((
|
|
346
|
+
const k = {};
|
|
347
|
+
$.forEach((E, _) => {
|
|
348
348
|
var M;
|
|
349
349
|
const j = l[_] || `Column${_ + 1}`;
|
|
350
|
-
let
|
|
351
|
-
if (s &&
|
|
352
|
-
const
|
|
353
|
-
!isNaN(
|
|
350
|
+
let D = ((M = E.textContent) == null ? void 0 : M.trim()) || "";
|
|
351
|
+
if (s && D) {
|
|
352
|
+
const N = parseFloat(D);
|
|
353
|
+
!isNaN(N) && D === N.toString() && (D = N);
|
|
354
354
|
}
|
|
355
|
-
|
|
356
|
-
}),
|
|
355
|
+
k[j] = D;
|
|
356
|
+
}), h.push(k);
|
|
357
357
|
}
|
|
358
358
|
return {
|
|
359
|
-
schema: s &&
|
|
360
|
-
data:
|
|
359
|
+
schema: s && h.length > 0 ? P(h, "Extracted Table") : ie(l, h.length),
|
|
360
|
+
data: h,
|
|
361
361
|
source: "dom",
|
|
362
362
|
metadata: {
|
|
363
363
|
selector: e,
|
|
364
|
-
rowCount:
|
|
364
|
+
rowCount: h.length,
|
|
365
365
|
columnCount: l.length,
|
|
366
366
|
extractedAt: /* @__PURE__ */ new Date()
|
|
367
367
|
}
|
|
368
368
|
};
|
|
369
369
|
}
|
|
370
|
-
function
|
|
370
|
+
function re(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 r;
|
|
373
|
+
return e && e.length > 0 ? r = {
|
|
374
374
|
name: "Vue Data Grid",
|
|
375
|
-
columns: e.map((
|
|
376
|
-
name:
|
|
377
|
-
type: s && a.length > 0 ? L(a,
|
|
375
|
+
columns: e.map((o) => ({
|
|
376
|
+
name: o.field,
|
|
377
|
+
type: s && a.length > 0 ? L(a, o.field) : "string",
|
|
378
378
|
nullable: !0
|
|
379
379
|
})),
|
|
380
380
|
rowCount: a.length
|
|
381
|
-
} : a.length > 0 ?
|
|
382
|
-
schema:
|
|
381
|
+
} : a.length > 0 ? r = P(a, "Vue Data Grid") : r = { name: "Vue Data Grid", columns: [], rowCount: 0 }, {
|
|
382
|
+
schema: r,
|
|
383
383
|
data: a,
|
|
384
384
|
source: "vue",
|
|
385
385
|
metadata: {
|
|
386
386
|
rowCount: a.length,
|
|
387
|
-
columnCount:
|
|
387
|
+
columnCount: r.columns.length,
|
|
388
388
|
extractedAt: /* @__PURE__ */ new Date()
|
|
389
389
|
}
|
|
390
390
|
};
|
|
@@ -405,10 +405,10 @@ function ce(c) {
|
|
|
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 ? B(c.auth) : void 0, n = [];
|
|
409
|
+
function s(a, r = "") {
|
|
410
|
+
a.forEach((o) => {
|
|
411
|
+
o.item ? s(o.item, r ? `${r}/${o.name}` : o.name) : o.request && n.push(le(o, t));
|
|
412
412
|
});
|
|
413
413
|
}
|
|
414
414
|
return s(c.item), {
|
|
@@ -421,14 +421,14 @@ function ce(c) {
|
|
|
421
421
|
}
|
|
422
422
|
function le(c, e) {
|
|
423
423
|
const t = c.request, n = {};
|
|
424
|
-
t.header && t.header.forEach((
|
|
425
|
-
n[
|
|
424
|
+
t.header && t.header.forEach((r) => {
|
|
425
|
+
n[r.key] = r.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((r) => {
|
|
429
|
+
s[r.key] = r.value;
|
|
430
430
|
});
|
|
431
|
-
const a = t.auth ?
|
|
431
|
+
const a = t.auth ? B(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 B(c) {
|
|
443
443
|
const e = {};
|
|
444
444
|
return c.apikey ? c.apikey.forEach((t) => {
|
|
445
445
|
e[t.key] = t.value;
|
|
@@ -459,28 +459,28 @@ function I(c, e) {
|
|
|
459
459
|
t = t.replace(s, e[n]);
|
|
460
460
|
}), t;
|
|
461
461
|
}
|
|
462
|
-
async function
|
|
462
|
+
async function J(c) {
|
|
463
463
|
const { endpoint: e, variables: t = {}, additionalHeaders: n = {}, additionalParams: s = {} } = c;
|
|
464
464
|
try {
|
|
465
465
|
let a = I(e.url, t);
|
|
466
|
-
const
|
|
467
|
-
|
|
466
|
+
const r = { ...e.queryParams, ...t, ...s }, o = Object.keys(r).filter((u) => r[u] !== void 0 && r[u] !== "").map((u) => `${encodeURIComponent(u)}=${encodeURIComponent(I(String(r[u]), t))}`).join("&");
|
|
467
|
+
o && (a = a.includes("?") ? `${a}&${o}` : `${a}?${o}`);
|
|
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((u) => {
|
|
474
|
+
i[u] = I(i[u], t);
|
|
475
475
|
}), e.auth) {
|
|
476
476
|
if (e.auth.type === "apikey") {
|
|
477
|
-
const
|
|
478
|
-
e.auth.credentials.in === "header" && (i[
|
|
477
|
+
const u = e.auth.credentials.key || "access_key", w = I(e.auth.credentials.value || "", t);
|
|
478
|
+
e.auth.credentials.in === "header" && (i[u] = w);
|
|
479
479
|
} else if (e.auth.type === "bearer") {
|
|
480
|
-
const
|
|
481
|
-
i.Authorization = `Bearer ${
|
|
480
|
+
const u = I(e.auth.credentials.token || "", t);
|
|
481
|
+
i.Authorization = `Bearer ${u}`;
|
|
482
482
|
} else if (e.auth.type === "basic") {
|
|
483
|
-
const
|
|
483
|
+
const u = I(e.auth.credentials.username || "", t), w = I(e.auth.credentials.password || "", t), v = btoa(`${u}:${w}`);
|
|
484
484
|
i.Authorization = `Basic ${v}`;
|
|
485
485
|
}
|
|
486
486
|
}
|
|
@@ -488,8 +488,8 @@ async function U(c) {
|
|
|
488
488
|
method: e.method,
|
|
489
489
|
headers: i
|
|
490
490
|
}), g = {};
|
|
491
|
-
return l.headers.forEach((
|
|
492
|
-
g[
|
|
491
|
+
return l.headers.forEach((u, w) => {
|
|
492
|
+
g[w] = u;
|
|
493
493
|
}), l.ok ? {
|
|
494
494
|
success: !0,
|
|
495
495
|
data: await l.json(),
|
|
@@ -511,7 +511,7 @@ async function U(c) {
|
|
|
511
511
|
async function Ge(c, e = {}) {
|
|
512
512
|
const t = [];
|
|
513
513
|
for (const n of c) {
|
|
514
|
-
const s = await
|
|
514
|
+
const s = await J({ endpoint: n, variables: e });
|
|
515
515
|
t.push(s);
|
|
516
516
|
}
|
|
517
517
|
return t;
|
|
@@ -527,13 +527,13 @@ class de {
|
|
|
527
527
|
this.config = {
|
|
528
528
|
timeout: 3e4,
|
|
529
529
|
...e
|
|
530
|
-
}, t && (this.qaEngine = new
|
|
530
|
+
}, t && (this.qaEngine = new U(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 U(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 o = await
|
|
559
|
-
throw new Error(`TFM API error: ${
|
|
559
|
+
if (!s.ok) {
|
|
560
|
+
const o = await s.text();
|
|
561
|
+
throw new Error(`TFM API error: ${s.status} - ${o}`);
|
|
560
562
|
}
|
|
561
|
-
const
|
|
563
|
+
const a = await s.json(), r = Date.now() - t;
|
|
562
564
|
return {
|
|
563
565
|
success: !0,
|
|
564
|
-
result:
|
|
566
|
+
result: a.result || a,
|
|
565
567
|
metadata: {
|
|
566
|
-
processingTime:
|
|
568
|
+
processingTime: r,
|
|
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 re(e, t, n);
|
|
682
684
|
}
|
|
683
685
|
/**
|
|
684
686
|
* Update configuration
|
|
@@ -727,11 +729,11 @@ class de {
|
|
|
727
729
|
const s = {
|
|
728
730
|
...this.parsedCollection.variables,
|
|
729
731
|
...t
|
|
730
|
-
}, a = await
|
|
732
|
+
}, a = await J({ endpoint: n, variables: s });
|
|
731
733
|
if (!a.success)
|
|
732
734
|
throw new Error(`API request failed: ${a.error}`);
|
|
733
|
-
const
|
|
734
|
-
return { data:
|
|
735
|
+
const r = ue(a), o = P(r);
|
|
736
|
+
return { data: r, schema: o };
|
|
735
737
|
}
|
|
736
738
|
/**
|
|
737
739
|
* Query API data with natural language
|
|
@@ -746,12 +748,12 @@ class de {
|
|
|
746
748
|
question: e.question,
|
|
747
749
|
schema: s,
|
|
748
750
|
data: n
|
|
749
|
-
},
|
|
751
|
+
}, r = await this.qaEngine.answerQuestion(a), o = Date.now() - t;
|
|
750
752
|
return {
|
|
751
|
-
answer:
|
|
753
|
+
answer: r.answer,
|
|
752
754
|
apiResponse: n,
|
|
753
755
|
endpoint: e.dataSource.endpoint,
|
|
754
|
-
executionTime:
|
|
756
|
+
executionTime: o
|
|
755
757
|
};
|
|
756
758
|
}
|
|
757
759
|
/**
|
|
@@ -766,131 +768,131 @@ class de {
|
|
|
766
768
|
}
|
|
767
769
|
}
|
|
768
770
|
function Ye(c) {
|
|
769
|
-
const e = new de(c.config, c.qaConfig), t =
|
|
770
|
-
async function d
|
|
771
|
+
const e = new de(c.config, c.qaConfig), t = S(!1), n = S(null), s = S(null), a = c.data || S([]), r = c.schema || S(null), o = S([]), i = S([]), l = S(null), g = c.maxQuestionHistory || 50, h = c.useLocalFallback !== !1;
|
|
772
|
+
async function u(d, y) {
|
|
771
773
|
t.value = !0, n.value = null;
|
|
772
774
|
try {
|
|
773
775
|
const b = {
|
|
774
|
-
type:
|
|
776
|
+
type: d,
|
|
775
777
|
data: a.value,
|
|
776
|
-
schema:
|
|
777
|
-
options:
|
|
778
|
-
},
|
|
779
|
-
return s.value =
|
|
778
|
+
schema: r.value || void 0,
|
|
779
|
+
options: y
|
|
780
|
+
}, C = await e.analyze(b);
|
|
781
|
+
return s.value = C, C;
|
|
780
782
|
} catch (b) {
|
|
781
|
-
if (n.value = b instanceof Error ? b : new Error("Analysis failed"),
|
|
782
|
-
return
|
|
783
|
+
if (n.value = b instanceof Error ? b : new Error("Analysis failed"), h)
|
|
784
|
+
return w(d, y);
|
|
783
785
|
throw n.value;
|
|
784
786
|
} finally {
|
|
785
787
|
t.value = !1;
|
|
786
788
|
}
|
|
787
789
|
}
|
|
788
|
-
function
|
|
789
|
-
const b =
|
|
790
|
-
switch (
|
|
790
|
+
function w(d, y) {
|
|
791
|
+
const b = r.value || P(a.value);
|
|
792
|
+
switch (d) {
|
|
791
793
|
case "descriptive_stats": {
|
|
792
|
-
const
|
|
793
|
-
(
|
|
794
|
+
const C = b.columns.map(
|
|
795
|
+
(T) => H(a.value, T.name, T.type)
|
|
794
796
|
);
|
|
795
797
|
return {
|
|
796
|
-
type:
|
|
798
|
+
type: d,
|
|
797
799
|
timestamp: /* @__PURE__ */ new Date(),
|
|
798
|
-
descriptiveStats:
|
|
799
|
-
summary: `Calculated statistics for ${
|
|
800
|
+
descriptiveStats: C,
|
|
801
|
+
summary: `Calculated statistics for ${C.length} columns`,
|
|
800
802
|
insights: [],
|
|
801
803
|
confidence: 0.9
|
|
802
804
|
};
|
|
803
805
|
}
|
|
804
806
|
case "anomaly_detection": {
|
|
805
|
-
const
|
|
807
|
+
const C = b.columns.filter((x) => x.type === "number").map((x) => x.name), T = ae(
|
|
806
808
|
a.value,
|
|
807
|
-
|
|
808
|
-
|
|
809
|
+
C,
|
|
810
|
+
y == null ? void 0 : y.sensitivity
|
|
809
811
|
);
|
|
810
812
|
return {
|
|
811
|
-
type:
|
|
813
|
+
type: d,
|
|
812
814
|
timestamp: /* @__PURE__ */ new Date(),
|
|
813
|
-
anomalies:
|
|
814
|
-
summary: `Found ${
|
|
815
|
-
insights:
|
|
815
|
+
anomalies: T,
|
|
816
|
+
summary: `Found ${T.length} anomalies`,
|
|
817
|
+
insights: T.slice(0, 3).map((x) => x.reasons[0]),
|
|
816
818
|
confidence: 0.8
|
|
817
819
|
};
|
|
818
820
|
}
|
|
819
821
|
default:
|
|
820
|
-
throw new Error(`Local analysis not supported for type: ${
|
|
822
|
+
throw new Error(`Local analysis not supported for type: ${d}`);
|
|
821
823
|
}
|
|
822
824
|
}
|
|
823
825
|
async function v() {
|
|
824
|
-
return (await
|
|
826
|
+
return (await u("descriptive_stats")).descriptiveStats || [];
|
|
825
827
|
}
|
|
826
|
-
async function $(
|
|
827
|
-
return (await
|
|
828
|
+
async function $(d, y) {
|
|
829
|
+
return (await u("anomaly_detection", { sensitivity: y, features: d })).anomalies || [];
|
|
828
830
|
}
|
|
829
|
-
async function
|
|
830
|
-
return
|
|
831
|
+
async function k(d, y = 3) {
|
|
832
|
+
return u("clustering", { features: d, numClusters: y });
|
|
831
833
|
}
|
|
832
|
-
async function
|
|
833
|
-
return
|
|
834
|
+
async function E(d, y) {
|
|
835
|
+
return u("prediction", { targetColumn: d, ...y });
|
|
834
836
|
}
|
|
835
|
-
function _(
|
|
836
|
-
e.updateConfig(
|
|
837
|
+
function _(d) {
|
|
838
|
+
e.updateConfig(d);
|
|
837
839
|
}
|
|
838
|
-
function j(
|
|
839
|
-
a.value =
|
|
840
|
+
function j(d, y = !0) {
|
|
841
|
+
a.value = d, y && (r.value = P(d));
|
|
840
842
|
}
|
|
841
|
-
function
|
|
842
|
-
t.value = !1, n.value = null, s.value = null,
|
|
843
|
+
function D() {
|
|
844
|
+
t.value = !1, n.value = null, s.value = null, o.value = [], i.value = [], l.value = null;
|
|
843
845
|
}
|
|
844
|
-
async function M(
|
|
846
|
+
async function M(d, y) {
|
|
845
847
|
t.value = !0, n.value = null;
|
|
846
848
|
try {
|
|
847
|
-
const b =
|
|
848
|
-
question:
|
|
849
|
+
const b = r.value || P(a.value), C = {
|
|
850
|
+
question: d,
|
|
849
851
|
schema: b,
|
|
850
852
|
data: a.value,
|
|
851
853
|
sampleSize: 100,
|
|
852
854
|
includeAggregates: !0,
|
|
853
|
-
...
|
|
854
|
-
},
|
|
855
|
-
id:
|
|
856
|
-
text:
|
|
855
|
+
...y
|
|
856
|
+
}, x = (await e.askQuestion(C)).answer, X = {
|
|
857
|
+
id: x.questionId,
|
|
858
|
+
text: d,
|
|
857
859
|
timestamp: /* @__PURE__ */ new Date(),
|
|
858
860
|
context: {
|
|
859
861
|
tableSchema: b,
|
|
860
862
|
rowCount: a.value.length
|
|
861
863
|
}
|
|
862
864
|
};
|
|
863
|
-
return
|
|
865
|
+
return o.value.push(X), i.value.push(x), l.value = x, o.value.length > g && (o.value.shift(), i.value.shift()), x;
|
|
864
866
|
} catch (b) {
|
|
865
867
|
throw n.value = b instanceof Error ? b : new Error("Q&A failed"), n.value;
|
|
866
868
|
} finally {
|
|
867
869
|
t.value = !1;
|
|
868
870
|
}
|
|
869
871
|
}
|
|
870
|
-
async function
|
|
872
|
+
async function N() {
|
|
871
873
|
t.value = !0, n.value = null;
|
|
872
874
|
try {
|
|
873
|
-
const
|
|
874
|
-
return await e.generateSummary(a.value,
|
|
875
|
-
} catch (
|
|
876
|
-
throw n.value =
|
|
875
|
+
const d = r.value || P(a.value);
|
|
876
|
+
return await e.generateSummary(a.value, d);
|
|
877
|
+
} catch (d) {
|
|
878
|
+
throw n.value = d instanceof Error ? d : new Error("Summary generation failed"), n.value;
|
|
877
879
|
} finally {
|
|
878
880
|
t.value = !1;
|
|
879
881
|
}
|
|
880
882
|
}
|
|
881
883
|
function K() {
|
|
882
|
-
|
|
884
|
+
o.value = [], i.value = [], l.value = null;
|
|
883
885
|
}
|
|
884
|
-
function G(
|
|
885
|
-
const
|
|
886
|
-
return
|
|
886
|
+
function G(d) {
|
|
887
|
+
const y = e.extractFromDOM(d);
|
|
888
|
+
return y && (a.value = y.data, r.value = y.schema), y;
|
|
887
889
|
}
|
|
888
|
-
function Y(
|
|
889
|
-
const
|
|
890
|
-
a.value =
|
|
890
|
+
function Y(d, y, b) {
|
|
891
|
+
const C = e.normalizeVueData(d, y, b);
|
|
892
|
+
a.value = C.data, r.value = C.schema;
|
|
891
893
|
}
|
|
892
|
-
function W(
|
|
893
|
-
e.initializeQA(
|
|
894
|
+
function W(d) {
|
|
895
|
+
e.initializeQA(d);
|
|
894
896
|
}
|
|
895
897
|
return {
|
|
896
898
|
client: e,
|
|
@@ -898,30 +900,30 @@ function Ye(c) {
|
|
|
898
900
|
error: n,
|
|
899
901
|
lastResult: s,
|
|
900
902
|
data: a,
|
|
901
|
-
schema:
|
|
902
|
-
questionHistory:
|
|
903
|
+
schema: r,
|
|
904
|
+
questionHistory: o,
|
|
903
905
|
answerHistory: i,
|
|
904
906
|
lastAnswer: l,
|
|
905
|
-
analyze:
|
|
907
|
+
analyze: u,
|
|
906
908
|
getDescriptiveStats: v,
|
|
907
909
|
detectAnomalies: $,
|
|
908
|
-
performClustering:
|
|
909
|
-
predict:
|
|
910
|
+
performClustering: k,
|
|
911
|
+
predict: E,
|
|
910
912
|
askQuestion: M,
|
|
911
|
-
generateSummary:
|
|
913
|
+
generateSummary: N,
|
|
912
914
|
clearHistory: K,
|
|
913
915
|
extractFromDOM: G,
|
|
914
916
|
loadFromVueGrid: Y,
|
|
915
917
|
updateConfig: _,
|
|
916
918
|
initializeQA: W,
|
|
917
919
|
setData: j,
|
|
918
|
-
reset:
|
|
920
|
+
reset: D
|
|
919
921
|
};
|
|
920
922
|
}
|
|
921
|
-
const me = { class: "ti-question-input" },
|
|
923
|
+
const me = { class: "ti-question-input" }, he = { class: "ti-input-wrapper" }, pe = ["placeholder", "disabled", "onKeydown"], fe = ["disabled"], ge = { key: 0 }, ye = {
|
|
922
924
|
key: 1,
|
|
923
925
|
class: "ti-loading"
|
|
924
|
-
},
|
|
926
|
+
}, we = {
|
|
925
927
|
key: 0,
|
|
926
928
|
class: "ti-hint"
|
|
927
929
|
}, ve = /* @__PURE__ */ z({
|
|
@@ -937,36 +939,36 @@ const me = { class: "ti-question-input" }, pe = { class: "ti-input-wrapper" }, h
|
|
|
937
939
|
},
|
|
938
940
|
emits: ["submit"],
|
|
939
941
|
setup(c, { emit: e }) {
|
|
940
|
-
const t = c, n = e, s =
|
|
942
|
+
const t = c, n = e, s = S("");
|
|
941
943
|
function a() {
|
|
942
944
|
s.value.trim() && !t.disabled && !t.loading && (n("submit", s.value.trim()), s.value = "");
|
|
943
945
|
}
|
|
944
|
-
function o
|
|
946
|
+
function r(o) {
|
|
945
947
|
}
|
|
946
|
-
return (
|
|
947
|
-
m("div",
|
|
948
|
+
return (o, i) => (f(), p("div", me, [
|
|
949
|
+
m("div", he, [
|
|
948
950
|
Z(m("textarea", {
|
|
949
951
|
"onUpdate:modelValue": i[0] || (i[0] = (l) => s.value = l),
|
|
950
|
-
placeholder:
|
|
951
|
-
disabled:
|
|
952
|
+
placeholder: o.placeholder,
|
|
953
|
+
disabled: o.disabled,
|
|
952
954
|
class: "ti-textarea",
|
|
953
955
|
rows: "2",
|
|
954
956
|
onKeydown: [
|
|
955
|
-
V(
|
|
956
|
-
V(
|
|
957
|
+
R(V(a, ["exact", "prevent"]), ["enter"]),
|
|
958
|
+
R(V(r, ["shift"]), ["enter"])
|
|
957
959
|
]
|
|
958
|
-
}, null, 40,
|
|
960
|
+
}, null, 40, pe), [
|
|
959
961
|
[ee, s.value]
|
|
960
962
|
]),
|
|
961
963
|
m("button", {
|
|
962
|
-
disabled:
|
|
964
|
+
disabled: o.disabled || !s.value.trim(),
|
|
963
965
|
class: "ti-submit-btn",
|
|
964
966
|
onClick: a
|
|
965
967
|
}, [
|
|
966
|
-
|
|
968
|
+
o.loading ? (f(), p("span", ye, A(o.loadingLabel), 1)) : (f(), p("span", ge, A(o.submitLabel), 1))
|
|
967
969
|
], 8, fe)
|
|
968
970
|
]),
|
|
969
|
-
|
|
971
|
+
o.showHint ? (f(), p("div", we, A(o.hint), 1)) : q("", !0)
|
|
970
972
|
]));
|
|
971
973
|
}
|
|
972
974
|
}), F = (c, e) => {
|
|
@@ -974,81 +976,81 @@ const me = { class: "ti-question-input" }, pe = { class: "ti-input-wrapper" }, h
|
|
|
974
976
|
for (const [n, s] of e)
|
|
975
977
|
t[n] = s;
|
|
976
978
|
return t;
|
|
977
|
-
}, We = /* @__PURE__ */ F(ve, [["__scopeId", "data-v-90db5921"]]), be = { class: "ti-answer-header" }, Ae = { class: "ti-answer-icon" }, $e = { key: 0 },
|
|
979
|
+
}, We = /* @__PURE__ */ F(ve, [["__scopeId", "data-v-90db5921"]]), be = { class: "ti-answer-header" }, Ae = { class: "ti-answer-icon" }, $e = { key: 0 }, Ce = { key: 1 }, ke = { class: "ti-answer-meta" }, _e = { class: "ti-confidence" }, xe = { class: "ti-timestamp" }, Se = { class: "ti-answer-text" }, qe = {
|
|
978
980
|
key: 0,
|
|
979
981
|
class: "ti-approximate-notice"
|
|
980
|
-
},
|
|
982
|
+
}, Ee = {
|
|
981
983
|
key: 1,
|
|
982
984
|
class: "ti-reason"
|
|
983
|
-
},
|
|
985
|
+
}, De = {
|
|
984
986
|
key: 2,
|
|
985
987
|
class: "ti-supporting-data"
|
|
986
|
-
},
|
|
988
|
+
}, Te = {
|
|
987
989
|
key: 0,
|
|
988
990
|
class: "ti-supporting-content"
|
|
989
991
|
}, Ie = {
|
|
990
992
|
key: 0,
|
|
991
993
|
class: "ti-aggregates"
|
|
992
|
-
},
|
|
994
|
+
}, Pe = {
|
|
993
995
|
key: 1,
|
|
994
996
|
class: "ti-rows"
|
|
995
|
-
},
|
|
997
|
+
}, Ne = { class: "ti-table-wrapper" }, Me = { class: "ti-table" }, Oe = /* @__PURE__ */ z({
|
|
996
998
|
__name: "AnswerDisplay",
|
|
997
999
|
props: {
|
|
998
1000
|
answer: {}
|
|
999
1001
|
},
|
|
1000
1002
|
setup(c) {
|
|
1001
|
-
const e =
|
|
1003
|
+
const e = S(!1);
|
|
1002
1004
|
function t(n) {
|
|
1003
1005
|
return new Date(n).toLocaleTimeString();
|
|
1004
1006
|
}
|
|
1005
|
-
return (n, s) => (f(),
|
|
1007
|
+
return (n, s) => (f(), p("div", {
|
|
1006
1008
|
class: te(["ti-answer-display", { "ti-cannot-answer": n.answer.cannotAnswer }])
|
|
1007
1009
|
}, [
|
|
1008
1010
|
m("div", be, [
|
|
1009
1011
|
m("div", Ae, [
|
|
1010
|
-
n.answer.cannotAnswer ? (f(),
|
|
1012
|
+
n.answer.cannotAnswer ? (f(), p("span", Ce, "⚠️")) : (f(), p("span", $e, "💡"))
|
|
1011
1013
|
]),
|
|
1012
|
-
m("div",
|
|
1014
|
+
m("div", ke, [
|
|
1013
1015
|
m("div", _e, " Confidence: " + A(Math.round(n.answer.confidence * 100)) + "% ", 1),
|
|
1014
|
-
m("div",
|
|
1016
|
+
m("div", xe, A(t(n.answer.timestamp)), 1)
|
|
1015
1017
|
])
|
|
1016
1018
|
]),
|
|
1017
|
-
m("div",
|
|
1018
|
-
n.answer.isApproximate ? (f(),
|
|
1019
|
-
n.answer.reason && n.answer.cannotAnswer ? (f(),
|
|
1019
|
+
m("div", Se, A(n.answer.text), 1),
|
|
1020
|
+
n.answer.isApproximate ? (f(), p("div", qe, " ℹ️ This answer is based on sampled data and may be approximate. ")) : q("", !0),
|
|
1021
|
+
n.answer.reason && n.answer.cannotAnswer ? (f(), p("div", Ee, [
|
|
1020
1022
|
s[1] || (s[1] = m("strong", null, "Reason:", -1)),
|
|
1021
1023
|
ne(" " + A(n.answer.reason), 1)
|
|
1022
|
-
])) :
|
|
1023
|
-
n.answer.supportingData ? (f(),
|
|
1024
|
+
])) : q("", !0),
|
|
1025
|
+
n.answer.supportingData ? (f(), p("div", De, [
|
|
1024
1026
|
m("button", {
|
|
1025
1027
|
class: "ti-toggle-btn",
|
|
1026
1028
|
onClick: s[0] || (s[0] = (a) => e.value = !e.value)
|
|
1027
1029
|
}, A(e.value ? "▼" : "▶") + " Supporting Data ", 1),
|
|
1028
|
-
e.value ? (f(),
|
|
1029
|
-
n.answer.supportingData.aggregates ? (f(),
|
|
1030
|
+
e.value ? (f(), p("div", Te, [
|
|
1031
|
+
n.answer.supportingData.aggregates ? (f(), p("div", Ie, [
|
|
1030
1032
|
s[2] || (s[2] = m("h4", null, "Aggregates:", -1)),
|
|
1031
1033
|
m("pre", null, A(JSON.stringify(n.answer.supportingData.aggregates, null, 2)), 1)
|
|
1032
|
-
])) :
|
|
1033
|
-
n.answer.supportingData.rows && n.answer.supportingData.rows.length > 0 ? (f(),
|
|
1034
|
+
])) : q("", !0),
|
|
1035
|
+
n.answer.supportingData.rows && n.answer.supportingData.rows.length > 0 ? (f(), p("div", Pe, [
|
|
1034
1036
|
m("h4", null, "Sample Rows (" + A(n.answer.supportingData.rows.length) + "):", 1),
|
|
1035
|
-
m("div",
|
|
1037
|
+
m("div", Ne, [
|
|
1036
1038
|
m("table", Me, [
|
|
1037
1039
|
m("thead", null, [
|
|
1038
1040
|
m("tr", null, [
|
|
1039
|
-
(f(!0),
|
|
1041
|
+
(f(!0), p(O, null, Q(Object.keys(n.answer.supportingData.rows[0]), (a, r) => (f(), p("th", { key: r }, A(a), 1))), 128))
|
|
1040
1042
|
])
|
|
1041
1043
|
]),
|
|
1042
1044
|
m("tbody", null, [
|
|
1043
|
-
(f(!0),
|
|
1044
|
-
(f(!0),
|
|
1045
|
+
(f(!0), p(O, null, Q(n.answer.supportingData.rows.slice(0, 5), (a, r) => (f(), p("tr", { key: r }, [
|
|
1046
|
+
(f(!0), p(O, null, Q(Object.keys(a), (o, i) => (f(), p("td", { key: i }, A(a[o]), 1))), 128))
|
|
1045
1047
|
]))), 128))
|
|
1046
1048
|
])
|
|
1047
1049
|
])
|
|
1048
1050
|
])
|
|
1049
|
-
])) :
|
|
1050
|
-
])) :
|
|
1051
|
-
])) :
|
|
1051
|
+
])) : q("", !0)
|
|
1052
|
+
])) : q("", !0)
|
|
1053
|
+
])) : q("", !0)
|
|
1052
1054
|
], 2));
|
|
1053
1055
|
}
|
|
1054
1056
|
}), Xe = /* @__PURE__ */ F(Oe, [["__scopeId", "data-v-d1aaae1d"]]), Qe = { class: "ti-question-history" }, je = { class: "ti-history-header" }, ze = {
|
|
@@ -1057,10 +1059,10 @@ const me = { class: "ti-question-input" }, pe = { class: "ti-input-wrapper" }, h
|
|
|
1057
1059
|
}, Fe = {
|
|
1058
1060
|
key: 1,
|
|
1059
1061
|
class: "ti-history-list"
|
|
1060
|
-
},
|
|
1062
|
+
}, Re = ["onClick"], Ve = { class: "ti-question-header" }, Ue = { class: "ti-question-number" }, Le = { class: "ti-question-time" }, He = { class: "ti-question-text" }, Be = {
|
|
1061
1063
|
key: 0,
|
|
1062
1064
|
class: "ti-question-context"
|
|
1063
|
-
},
|
|
1065
|
+
}, Je = /* @__PURE__ */ z({
|
|
1064
1066
|
__name: "QuestionHistory",
|
|
1065
1067
|
props: {
|
|
1066
1068
|
questions: {}
|
|
@@ -1069,54 +1071,54 @@ const me = { class: "ti-question-input" }, pe = { class: "ti-input-wrapper" }, h
|
|
|
1069
1071
|
setup(c, { emit: e }) {
|
|
1070
1072
|
const t = c, n = se(() => [...t.questions].reverse());
|
|
1071
1073
|
function s(a) {
|
|
1072
|
-
const
|
|
1073
|
-
return l < 1 ? "Just now" : l < 60 ? `${l}m ago` : g < 24 ? `${g}h ago` : `${
|
|
1074
|
+
const r = new Date(a), i = (/* @__PURE__ */ new Date()).getTime() - r.getTime(), l = Math.floor(i / 6e4), g = Math.floor(i / 36e5), h = Math.floor(i / 864e5);
|
|
1075
|
+
return l < 1 ? "Just now" : l < 60 ? `${l}m ago` : g < 24 ? `${g}h ago` : `${h}d ago`;
|
|
1074
1076
|
}
|
|
1075
|
-
return (a,
|
|
1077
|
+
return (a, r) => (f(), p("div", Qe, [
|
|
1076
1078
|
m("div", je, [
|
|
1077
|
-
|
|
1078
|
-
a.questions.length > 0 ? (f(),
|
|
1079
|
+
r[1] || (r[1] = m("h3", null, "Question History", -1)),
|
|
1080
|
+
a.questions.length > 0 ? (f(), p("button", {
|
|
1079
1081
|
key: 0,
|
|
1080
1082
|
class: "ti-clear-btn",
|
|
1081
|
-
onClick:
|
|
1082
|
-
}, " Clear History ")) :
|
|
1083
|
+
onClick: r[0] || (r[0] = (o) => a.$emit("clear"))
|
|
1084
|
+
}, " Clear History ")) : q("", !0)
|
|
1083
1085
|
]),
|
|
1084
|
-
a.questions.length === 0 ? (f(),
|
|
1086
|
+
a.questions.length === 0 ? (f(), p("div", ze, r[2] || (r[2] = [
|
|
1085
1087
|
m("div", { class: "ti-empty-icon" }, "💬", -1),
|
|
1086
1088
|
m("p", null, "No questions asked yet", -1),
|
|
1087
1089
|
m("p", { class: "ti-empty-hint" }, "Ask a question about your data to get started", -1)
|
|
1088
|
-
]))) : (f(),
|
|
1089
|
-
(f(!0),
|
|
1090
|
-
key:
|
|
1090
|
+
]))) : (f(), p("div", Fe, [
|
|
1091
|
+
(f(!0), p(O, null, Q(n.value, (o, i) => (f(), p("div", {
|
|
1092
|
+
key: o.id,
|
|
1091
1093
|
class: "ti-history-item",
|
|
1092
|
-
onClick: (l) => a.$emit("select",
|
|
1094
|
+
onClick: (l) => a.$emit("select", o)
|
|
1093
1095
|
}, [
|
|
1094
|
-
m("div",
|
|
1095
|
-
m("span",
|
|
1096
|
-
m("span", Le, A(s(
|
|
1096
|
+
m("div", Ve, [
|
|
1097
|
+
m("span", Ue, "#" + A(a.questions.length - i), 1),
|
|
1098
|
+
m("span", Le, A(s(o.timestamp)), 1)
|
|
1097
1099
|
]),
|
|
1098
|
-
m("div",
|
|
1099
|
-
|
|
1100
|
-
], 8,
|
|
1100
|
+
m("div", He, A(o.text), 1),
|
|
1101
|
+
o.context ? (f(), p("div", Be, A(o.context.rowCount) + " rows ", 1)) : q("", !0)
|
|
1102
|
+
], 8, Re))), 128))
|
|
1101
1103
|
]))
|
|
1102
1104
|
]));
|
|
1103
1105
|
}
|
|
1104
|
-
}), Ze = /* @__PURE__ */ F(
|
|
1106
|
+
}), Ze = /* @__PURE__ */ F(Je, [["__scopeId", "data-v-c66393d9"]]);
|
|
1105
1107
|
export {
|
|
1106
1108
|
Xe as AnswerDisplay,
|
|
1107
|
-
|
|
1109
|
+
U as QAEngine,
|
|
1108
1110
|
Ze as QuestionHistory,
|
|
1109
1111
|
We as QuestionInput,
|
|
1110
1112
|
de as TabularIntelligence,
|
|
1111
|
-
|
|
1113
|
+
H as calculateStats,
|
|
1112
1114
|
ue as convertToTabular,
|
|
1113
1115
|
ae as detectAnomalies,
|
|
1114
|
-
|
|
1116
|
+
J as executeAPIRequest,
|
|
1115
1117
|
Ge as executeMultipleRequests,
|
|
1116
|
-
|
|
1118
|
+
oe as extractFromDOM,
|
|
1117
1119
|
L as inferColumnType,
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
+
P as inferSchema,
|
|
1121
|
+
re as normalizeVueData,
|
|
1120
1122
|
ce as parsePostmanCollection,
|
|
1121
1123
|
I as replaceVariables,
|
|
1122
1124
|
Ye as useTabularIntelligence
|