@aivue/tabular-intelligence 1.2.0 → 1.3.0
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/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -65
- package/dist/index.mjs.map +1 -1
- package/dist/utils/apiClient.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref as
|
|
1
|
+
import { ref as S, defineComponent as z, createElementBlock as h, openBlock as f, createElementVNode as m, createCommentVNode as E, withDirectives as Z, withKeys as V, withModifiers as R, vModelText as ee, toDisplayString as A, normalizeClass as te, createTextVNode as ne, Fragment as O, renderList as Q, computed as se } from "vue";
|
|
2
2
|
function N(c, e) {
|
|
3
3
|
if (c.length === 0)
|
|
4
4
|
return { columns: [], rowCount: 0, name: e };
|
|
@@ -37,9 +37,9 @@ function B(c, e, t) {
|
|
|
37
37
|
if (t === "number") {
|
|
38
38
|
const r = n.map(Number).filter((i) => !isNaN(i));
|
|
39
39
|
if (r.length > 0) {
|
|
40
|
-
const i = [...r].sort((p,
|
|
40
|
+
const i = [...r].sort((p, u) => p - u), l = r.reduce((p, u) => p + u, 0);
|
|
41
41
|
o.mean = l / r.length, o.median = i[Math.floor(i.length / 2)], o.min = i[0], o.max = i[i.length - 1];
|
|
42
|
-
const g = r.reduce((p,
|
|
42
|
+
const g = r.reduce((p, u) => p + Math.pow(u - o.mean, 2), 0) / r.length;
|
|
43
43
|
o.std = Math.sqrt(g), o.percentiles = {
|
|
44
44
|
25: i[Math.floor(i.length * 0.25)],
|
|
45
45
|
50: o.median,
|
|
@@ -65,10 +65,10 @@ function ae(c, e, t = 0.5) {
|
|
|
65
65
|
return e.forEach((a) => {
|
|
66
66
|
const o = c.map((y, v) => ({ value: Number(y[a]), idx: v })).filter((y) => !isNaN(y.value));
|
|
67
67
|
if (o.length === 0) return;
|
|
68
|
-
const r = [...o].sort((y, v) => y.value - v.value), i = r[Math.floor(r.length * 0.25)].value, l = r[Math.floor(r.length * 0.75)].value, g = l - i, p = i - s * g,
|
|
68
|
+
const r = [...o].sort((y, v) => y.value - v.value), i = r[Math.floor(r.length * 0.25)].value, l = r[Math.floor(r.length * 0.75)].value, g = l - i, p = i - s * g, u = l + s * g;
|
|
69
69
|
o.forEach(({ value: y, idx: v }) => {
|
|
70
|
-
if (y < p || y >
|
|
71
|
-
const $ = n.find((D) => D.rowIndex === v), C = y < p ? `${a}: ${y.toFixed(2)} < ${p.toFixed(2)}` : `${a}: ${y.toFixed(2)} > ${
|
|
70
|
+
if (y < p || y > u) {
|
|
71
|
+
const $ = n.find((D) => D.rowIndex === v), C = y < p ? `${a}: ${y.toFixed(2)} < ${p.toFixed(2)}` : `${a}: ${y.toFixed(2)} > ${u.toFixed(2)}`;
|
|
72
72
|
$ ? ($.reasons.push(C), $.affectedColumns.push(a), $.score = Math.min(1, $.score + 0.2)) : n.push({
|
|
73
73
|
rowIndex: v,
|
|
74
74
|
row: c[v],
|
|
@@ -335,8 +335,8 @@ function re(c = {}) {
|
|
|
335
335
|
const v = i[0];
|
|
336
336
|
l = Array.from(v.cells).map(($, C) => `Column${C + 1}`);
|
|
337
337
|
}
|
|
338
|
-
const p = [],
|
|
339
|
-
for (const v of
|
|
338
|
+
const p = [], u = n ? i.slice(g, g + n) : i.slice(g);
|
|
339
|
+
for (const v of u) {
|
|
340
340
|
const $ = Array.from(v.cells);
|
|
341
341
|
if (a && $.every((D) => {
|
|
342
342
|
var _;
|
|
@@ -463,24 +463,24 @@ async function U(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 o = { ...e.queryParams, ...s }, r = Object.keys(o).map((
|
|
466
|
+
const o = { ...e.queryParams, ...t, ...s }, r = Object.keys(o).filter((u) => o[u] !== void 0 && o[u] !== "").map((u) => `${encodeURIComponent(u)}=${encodeURIComponent(I(String(o[u]), t))}`).join("&");
|
|
467
467
|
r && (a = a.includes("?") ? `${a}&${r}` : `${a}?${r}`);
|
|
468
468
|
const i = {
|
|
469
469
|
"Content-Type": "application/json",
|
|
470
470
|
...e.headers,
|
|
471
471
|
...n
|
|
472
472
|
};
|
|
473
|
-
if (Object.keys(i).forEach((
|
|
474
|
-
i[
|
|
473
|
+
if (Object.keys(i).forEach((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", y = I(e.auth.credentials.value || "", t);
|
|
478
|
+
e.auth.credentials.in === "header" && (i[u] = y);
|
|
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), y = I(e.auth.credentials.password || "", t), v = btoa(`${u}:${y}`);
|
|
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[y] =
|
|
491
|
+
return l.headers.forEach((u, y) => {
|
|
492
|
+
g[y] = u;
|
|
493
493
|
}), l.ok ? {
|
|
494
494
|
success: !0,
|
|
495
495
|
data: await l.json(),
|
|
@@ -766,12 +766,12 @@ class de {
|
|
|
766
766
|
}
|
|
767
767
|
}
|
|
768
768
|
function Ye(c) {
|
|
769
|
-
const e = new de(c.config, c.qaConfig), t =
|
|
770
|
-
async function d
|
|
769
|
+
const e = new de(c.config, c.qaConfig), t = S(!1), n = S(null), s = S(null), a = c.data || S([]), o = c.schema || S(null), r = S([]), i = S([]), l = S(null), g = c.maxQuestionHistory || 50, p = c.useLocalFallback !== !1;
|
|
770
|
+
async function u(d, w) {
|
|
771
771
|
t.value = !0, n.value = null;
|
|
772
772
|
try {
|
|
773
773
|
const b = {
|
|
774
|
-
type:
|
|
774
|
+
type: d,
|
|
775
775
|
data: a.value,
|
|
776
776
|
schema: o.value || void 0,
|
|
777
777
|
options: w
|
|
@@ -779,21 +779,21 @@ function Ye(c) {
|
|
|
779
779
|
return s.value = k, k;
|
|
780
780
|
} catch (b) {
|
|
781
781
|
if (n.value = b instanceof Error ? b : new Error("Analysis failed"), p)
|
|
782
|
-
return y(
|
|
782
|
+
return y(d, w);
|
|
783
783
|
throw n.value;
|
|
784
784
|
} finally {
|
|
785
785
|
t.value = !1;
|
|
786
786
|
}
|
|
787
787
|
}
|
|
788
|
-
function y(
|
|
788
|
+
function y(d, w) {
|
|
789
789
|
const b = o.value || N(a.value);
|
|
790
|
-
switch (
|
|
790
|
+
switch (d) {
|
|
791
791
|
case "descriptive_stats": {
|
|
792
792
|
const k = b.columns.map(
|
|
793
793
|
(x) => B(a.value, x.name, x.type)
|
|
794
794
|
);
|
|
795
795
|
return {
|
|
796
|
-
type:
|
|
796
|
+
type: d,
|
|
797
797
|
timestamp: /* @__PURE__ */ new Date(),
|
|
798
798
|
descriptiveStats: k,
|
|
799
799
|
summary: `Calculated statistics for ${k.length} columns`,
|
|
@@ -808,7 +808,7 @@ function Ye(c) {
|
|
|
808
808
|
w == null ? void 0 : w.sensitivity
|
|
809
809
|
);
|
|
810
810
|
return {
|
|
811
|
-
type:
|
|
811
|
+
type: d,
|
|
812
812
|
timestamp: /* @__PURE__ */ new Date(),
|
|
813
813
|
anomalies: x,
|
|
814
814
|
summary: `Found ${x.length} anomalies`,
|
|
@@ -817,35 +817,35 @@ function Ye(c) {
|
|
|
817
817
|
};
|
|
818
818
|
}
|
|
819
819
|
default:
|
|
820
|
-
throw new Error(`Local analysis not supported for type: ${
|
|
820
|
+
throw new Error(`Local analysis not supported for type: ${d}`);
|
|
821
821
|
}
|
|
822
822
|
}
|
|
823
823
|
async function v() {
|
|
824
|
-
return (await
|
|
824
|
+
return (await u("descriptive_stats")).descriptiveStats || [];
|
|
825
825
|
}
|
|
826
|
-
async function $(
|
|
827
|
-
return (await
|
|
826
|
+
async function $(d, w) {
|
|
827
|
+
return (await u("anomaly_detection", { sensitivity: w, features: d })).anomalies || [];
|
|
828
828
|
}
|
|
829
|
-
async function C(
|
|
830
|
-
return
|
|
829
|
+
async function C(d, w = 3) {
|
|
830
|
+
return u("clustering", { features: d, numClusters: w });
|
|
831
831
|
}
|
|
832
|
-
async function D(
|
|
833
|
-
return
|
|
832
|
+
async function D(d, w) {
|
|
833
|
+
return u("prediction", { targetColumn: d, ...w });
|
|
834
834
|
}
|
|
835
|
-
function _(
|
|
836
|
-
e.updateConfig(
|
|
835
|
+
function _(d) {
|
|
836
|
+
e.updateConfig(d);
|
|
837
837
|
}
|
|
838
|
-
function j(
|
|
839
|
-
a.value =
|
|
838
|
+
function j(d, w = !0) {
|
|
839
|
+
a.value = d, w && (o.value = N(d));
|
|
840
840
|
}
|
|
841
841
|
function T() {
|
|
842
842
|
t.value = !1, n.value = null, s.value = null, r.value = [], i.value = [], l.value = null;
|
|
843
843
|
}
|
|
844
|
-
async function M(
|
|
844
|
+
async function M(d, w) {
|
|
845
845
|
t.value = !0, n.value = null;
|
|
846
846
|
try {
|
|
847
847
|
const b = o.value || N(a.value), k = {
|
|
848
|
-
question:
|
|
848
|
+
question: d,
|
|
849
849
|
schema: b,
|
|
850
850
|
data: a.value,
|
|
851
851
|
sampleSize: 100,
|
|
@@ -853,7 +853,7 @@ function Ye(c) {
|
|
|
853
853
|
...w
|
|
854
854
|
}, q = (await e.askQuestion(k)).answer, X = {
|
|
855
855
|
id: q.questionId,
|
|
856
|
-
text:
|
|
856
|
+
text: d,
|
|
857
857
|
timestamp: /* @__PURE__ */ new Date(),
|
|
858
858
|
context: {
|
|
859
859
|
tableSchema: b,
|
|
@@ -870,10 +870,10 @@ function Ye(c) {
|
|
|
870
870
|
async function P() {
|
|
871
871
|
t.value = !0, n.value = null;
|
|
872
872
|
try {
|
|
873
|
-
const
|
|
874
|
-
return await e.generateSummary(a.value,
|
|
875
|
-
} catch (
|
|
876
|
-
throw n.value =
|
|
873
|
+
const d = o.value || N(a.value);
|
|
874
|
+
return await e.generateSummary(a.value, d);
|
|
875
|
+
} catch (d) {
|
|
876
|
+
throw n.value = d instanceof Error ? d : new Error("Summary generation failed"), n.value;
|
|
877
877
|
} finally {
|
|
878
878
|
t.value = !1;
|
|
879
879
|
}
|
|
@@ -881,16 +881,16 @@ function Ye(c) {
|
|
|
881
881
|
function K() {
|
|
882
882
|
r.value = [], i.value = [], l.value = null;
|
|
883
883
|
}
|
|
884
|
-
function G(
|
|
885
|
-
const w = e.extractFromDOM(
|
|
884
|
+
function G(d) {
|
|
885
|
+
const w = e.extractFromDOM(d);
|
|
886
886
|
return w && (a.value = w.data, o.value = w.schema), w;
|
|
887
887
|
}
|
|
888
|
-
function Y(
|
|
889
|
-
const k = e.normalizeVueData(
|
|
888
|
+
function Y(d, w, b) {
|
|
889
|
+
const k = e.normalizeVueData(d, w, b);
|
|
890
890
|
a.value = k.data, o.value = k.schema;
|
|
891
891
|
}
|
|
892
|
-
function W(
|
|
893
|
-
e.initializeQA(
|
|
892
|
+
function W(d) {
|
|
893
|
+
e.initializeQA(d);
|
|
894
894
|
}
|
|
895
895
|
return {
|
|
896
896
|
client: e,
|
|
@@ -902,7 +902,7 @@ function Ye(c) {
|
|
|
902
902
|
questionHistory: r,
|
|
903
903
|
answerHistory: i,
|
|
904
904
|
lastAnswer: l,
|
|
905
|
-
analyze:
|
|
905
|
+
analyze: u,
|
|
906
906
|
getDescriptiveStats: v,
|
|
907
907
|
detectAnomalies: $,
|
|
908
908
|
performClustering: C,
|
|
@@ -937,7 +937,7 @@ const me = { class: "ti-question-input" }, pe = { class: "ti-input-wrapper" }, h
|
|
|
937
937
|
},
|
|
938
938
|
emits: ["submit"],
|
|
939
939
|
setup(c, { emit: e }) {
|
|
940
|
-
const t = c, n = e, s =
|
|
940
|
+
const t = c, n = e, s = S("");
|
|
941
941
|
function a() {
|
|
942
942
|
s.value.trim() && !t.disabled && !t.loading && (n("submit", s.value.trim()), s.value = "");
|
|
943
943
|
}
|
|
@@ -966,7 +966,7 @@ const me = { class: "ti-question-input" }, pe = { class: "ti-input-wrapper" }, h
|
|
|
966
966
|
r.loading ? (f(), h("span", we, A(r.loadingLabel), 1)) : (f(), h("span", ge, A(r.submitLabel), 1))
|
|
967
967
|
], 8, fe)
|
|
968
968
|
]),
|
|
969
|
-
r.showHint ? (f(), h("div", ye, A(r.hint), 1)) :
|
|
969
|
+
r.showHint ? (f(), h("div", ye, A(r.hint), 1)) : E("", !0)
|
|
970
970
|
]));
|
|
971
971
|
}
|
|
972
972
|
}), F = (c, e) => {
|
|
@@ -974,7 +974,7 @@ const me = { class: "ti-question-input" }, pe = { class: "ti-input-wrapper" }, h
|
|
|
974
974
|
for (const [n, s] of e)
|
|
975
975
|
t[n] = s;
|
|
976
976
|
return t;
|
|
977
|
-
}, We = /* @__PURE__ */ F(ve, [["__scopeId", "data-v-90db5921"]]), be = { class: "ti-answer-header" }, Ae = { class: "ti-answer-icon" }, $e = { key: 0 }, ke = { key: 1 }, Ce = { class: "ti-answer-meta" }, _e = { class: "ti-confidence" }, qe = { class: "ti-timestamp" },
|
|
977
|
+
}, We = /* @__PURE__ */ F(ve, [["__scopeId", "data-v-90db5921"]]), be = { class: "ti-answer-header" }, Ae = { class: "ti-answer-icon" }, $e = { key: 0 }, ke = { key: 1 }, Ce = { class: "ti-answer-meta" }, _e = { class: "ti-confidence" }, qe = { class: "ti-timestamp" }, Se = { class: "ti-answer-text" }, Ee = {
|
|
978
978
|
key: 0,
|
|
979
979
|
class: "ti-approximate-notice"
|
|
980
980
|
}, De = {
|
|
@@ -998,7 +998,7 @@ const me = { class: "ti-question-input" }, pe = { class: "ti-input-wrapper" }, h
|
|
|
998
998
|
answer: {}
|
|
999
999
|
},
|
|
1000
1000
|
setup(c) {
|
|
1001
|
-
const e =
|
|
1001
|
+
const e = S(!1);
|
|
1002
1002
|
function t(n) {
|
|
1003
1003
|
return new Date(n).toLocaleTimeString();
|
|
1004
1004
|
}
|
|
@@ -1014,12 +1014,12 @@ const me = { class: "ti-question-input" }, pe = { class: "ti-input-wrapper" }, h
|
|
|
1014
1014
|
m("div", qe, A(t(n.answer.timestamp)), 1)
|
|
1015
1015
|
])
|
|
1016
1016
|
]),
|
|
1017
|
-
m("div",
|
|
1018
|
-
n.answer.isApproximate ? (f(), h("div",
|
|
1017
|
+
m("div", Se, A(n.answer.text), 1),
|
|
1018
|
+
n.answer.isApproximate ? (f(), h("div", Ee, " ℹ️ This answer is based on sampled data and may be approximate. ")) : E("", !0),
|
|
1019
1019
|
n.answer.reason && n.answer.cannotAnswer ? (f(), h("div", De, [
|
|
1020
1020
|
s[1] || (s[1] = m("strong", null, "Reason:", -1)),
|
|
1021
1021
|
ne(" " + A(n.answer.reason), 1)
|
|
1022
|
-
])) :
|
|
1022
|
+
])) : E("", !0),
|
|
1023
1023
|
n.answer.supportingData ? (f(), h("div", Te, [
|
|
1024
1024
|
m("button", {
|
|
1025
1025
|
class: "ti-toggle-btn",
|
|
@@ -1029,7 +1029,7 @@ const me = { class: "ti-question-input" }, pe = { class: "ti-input-wrapper" }, h
|
|
|
1029
1029
|
n.answer.supportingData.aggregates ? (f(), h("div", Ie, [
|
|
1030
1030
|
s[2] || (s[2] = m("h4", null, "Aggregates:", -1)),
|
|
1031
1031
|
m("pre", null, A(JSON.stringify(n.answer.supportingData.aggregates, null, 2)), 1)
|
|
1032
|
-
])) :
|
|
1032
|
+
])) : E("", !0),
|
|
1033
1033
|
n.answer.supportingData.rows && n.answer.supportingData.rows.length > 0 ? (f(), h("div", Ne, [
|
|
1034
1034
|
m("h4", null, "Sample Rows (" + A(n.answer.supportingData.rows.length) + "):", 1),
|
|
1035
1035
|
m("div", Pe, [
|
|
@@ -1046,9 +1046,9 @@ const me = { class: "ti-question-input" }, pe = { class: "ti-input-wrapper" }, h
|
|
|
1046
1046
|
])
|
|
1047
1047
|
])
|
|
1048
1048
|
])
|
|
1049
|
-
])) :
|
|
1050
|
-
])) :
|
|
1051
|
-
])) :
|
|
1049
|
+
])) : E("", !0)
|
|
1050
|
+
])) : E("", !0)
|
|
1051
|
+
])) : E("", !0)
|
|
1052
1052
|
], 2));
|
|
1053
1053
|
}
|
|
1054
1054
|
}), Xe = /* @__PURE__ */ F(Oe, [["__scopeId", "data-v-d1aaae1d"]]), Qe = { class: "ti-question-history" }, je = { class: "ti-history-header" }, ze = {
|
|
@@ -1079,7 +1079,7 @@ const me = { class: "ti-question-input" }, pe = { class: "ti-input-wrapper" }, h
|
|
|
1079
1079
|
key: 0,
|
|
1080
1080
|
class: "ti-clear-btn",
|
|
1081
1081
|
onClick: o[0] || (o[0] = (r) => a.$emit("clear"))
|
|
1082
|
-
}, " Clear History ")) :
|
|
1082
|
+
}, " Clear History ")) : E("", !0)
|
|
1083
1083
|
]),
|
|
1084
1084
|
a.questions.length === 0 ? (f(), h("div", ze, o[2] || (o[2] = [
|
|
1085
1085
|
m("div", { class: "ti-empty-icon" }, "💬", -1),
|
|
@@ -1096,7 +1096,7 @@ const me = { class: "ti-question-input" }, pe = { class: "ti-input-wrapper" }, h
|
|
|
1096
1096
|
m("span", Le, A(s(r.timestamp)), 1)
|
|
1097
1097
|
]),
|
|
1098
1098
|
m("div", Be, A(r.text), 1),
|
|
1099
|
-
r.context ? (f(), h("div", Je, A(r.context.rowCount) + " rows ", 1)) :
|
|
1099
|
+
r.context ? (f(), h("div", Je, A(r.context.rowCount) + " rows ", 1)) : E("", !0)
|
|
1100
1100
|
], 8, Ve))), 128))
|
|
1101
1101
|
]))
|
|
1102
1102
|
]));
|