@aivue/tabular-intelligence 1.3.9 â 1.5.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/README.md +70 -6
- package/dist/index.js +63 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +604 -483
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/qaEngine.d.ts +4 -0
- package/dist/utils/qaEngine.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -54,19 +54,18 @@ npm install @aivue/tabular-intelligence
|
|
|
54
54
|
|
|
55
55
|
## đ Quick Start
|
|
56
56
|
|
|
57
|
-
### Basic Usage
|
|
57
|
+
### Basic Usage (Local Mode)
|
|
58
58
|
|
|
59
59
|
```typescript
|
|
60
60
|
import { useTabularIntelligence } from '@aivue/tabular-intelligence';
|
|
61
61
|
|
|
62
|
+
// Local mode - no API required
|
|
62
63
|
const { analyze, getDescriptiveStats, detectAnomalies } = useTabularIntelligence({
|
|
63
64
|
config: {
|
|
64
|
-
provider: '
|
|
65
|
-
baseUrl: '
|
|
66
|
-
apiKey: 'your-api-key',
|
|
65
|
+
provider: 'local',
|
|
66
|
+
baseUrl: '',
|
|
67
67
|
},
|
|
68
68
|
data: ref(yourData),
|
|
69
|
-
useLocalFallback: true, // Use local analysis if API fails
|
|
70
69
|
});
|
|
71
70
|
|
|
72
71
|
// Get descriptive statistics
|
|
@@ -79,6 +78,38 @@ const anomalies = await detectAnomalies(['price', 'quantity'], 0.7);
|
|
|
79
78
|
const clusters = await performClustering(['feature1', 'feature2'], 3);
|
|
80
79
|
```
|
|
81
80
|
|
|
81
|
+
### With TabPFN (Prior Labs)
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import { useTabularIntelligence } from '@aivue/tabular-intelligence';
|
|
85
|
+
|
|
86
|
+
const { analyze } = useTabularIntelligence({
|
|
87
|
+
config: {
|
|
88
|
+
provider: 'tabpfn',
|
|
89
|
+
baseUrl: 'https://api.priorlabs.ai/v1/predict',
|
|
90
|
+
apiKey: 'your-tabpfn-api-key', // Get from https://priorlabs.ai/
|
|
91
|
+
},
|
|
92
|
+
data: ref(yourData),
|
|
93
|
+
useLocalFallback: true, // Fallback to local if API fails
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### With Custom TFM API
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import { useTabularIntelligence } from '@aivue/tabular-intelligence';
|
|
101
|
+
|
|
102
|
+
const { analyze } = useTabularIntelligence({
|
|
103
|
+
config: {
|
|
104
|
+
provider: 'custom',
|
|
105
|
+
baseUrl: 'https://your-tfm-api.com/analyze',
|
|
106
|
+
apiKey: 'your-api-key',
|
|
107
|
+
},
|
|
108
|
+
data: ref(yourData),
|
|
109
|
+
useLocalFallback: true,
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
82
113
|
### With Smart DataTable
|
|
83
114
|
|
|
84
115
|
```vue
|
|
@@ -289,17 +320,50 @@ type AnalysisType =
|
|
|
289
320
|
|
|
290
321
|
```typescript
|
|
291
322
|
interface TFMConfig {
|
|
292
|
-
provider: '
|
|
323
|
+
provider: 'local' | 'tabpfn' | 'custom';
|
|
293
324
|
baseUrl: string; // API endpoint
|
|
294
325
|
apiKey?: string; // API key
|
|
295
326
|
model?: string; // Model name
|
|
296
327
|
headers?: Record<string, string>; // Custom headers
|
|
297
328
|
timeout?: number; // Request timeout (ms)
|
|
329
|
+
useCorsProxy?: boolean; // Use CORS proxy
|
|
330
|
+
corsProxyUrl?: string; // CORS proxy URL
|
|
298
331
|
}
|
|
299
332
|
```
|
|
300
333
|
|
|
334
|
+
### Available TFM Providers
|
|
335
|
+
|
|
336
|
+
| Provider | Description | API Required | Best For |
|
|
337
|
+
|----------|-------------|--------------|----------|
|
|
338
|
+
| **local** | JavaScript-based statistical analysis | â No | Testing, basic stats, offline use |
|
|
339
|
+
| **tabpfn** | TabPFN from Prior Labs - state-of-the-art TFM | â
Yes | Production, accurate predictions |
|
|
340
|
+
| **custom** | Your own TFM API endpoint | â
Yes | Custom models, enterprise solutions |
|
|
341
|
+
|
|
342
|
+
**Note:** OpenAI and Anthropic do NOT offer dedicated TFM APIs. For AI-powered insights, use the Q&A feature with OpenAI/Anthropic instead.
|
|
343
|
+
|
|
301
344
|
## đ§ Advanced Usage
|
|
302
345
|
|
|
346
|
+
### TabPFN Integration
|
|
347
|
+
|
|
348
|
+
```typescript
|
|
349
|
+
// Get API key from https://priorlabs.ai/
|
|
350
|
+
const { analyze } = useTabularIntelligence({
|
|
351
|
+
config: {
|
|
352
|
+
provider: 'tabpfn',
|
|
353
|
+
baseUrl: 'https://api.priorlabs.ai/v1/predict',
|
|
354
|
+
apiKey: process.env.TABPFN_API_KEY,
|
|
355
|
+
timeout: 60000,
|
|
356
|
+
},
|
|
357
|
+
useLocalFallback: true, // Fallback to local if API fails
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
// Perform analysis with TabPFN
|
|
361
|
+
const result = await analyze('prediction', {
|
|
362
|
+
targetColumn: 'sales',
|
|
363
|
+
features: ['price', 'quantity', 'category'],
|
|
364
|
+
});
|
|
365
|
+
```
|
|
366
|
+
|
|
303
367
|
### Custom TFM API Integration
|
|
304
368
|
|
|
305
369
|
```typescript
|
package/dist/index.js
CHANGED
|
@@ -1,31 +1,68 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("vue");function $(c,e){if(c.length===0)return{columns:[],rowCount:0,name:e};const n=c[0];return{columns:Object.keys(n).map(t=>{const r=B(c,t);return{name:t,type:r,nullable:c.some(i=>i[t]==null)}}),rowCount:c.length,name:e}}function B(c,e){const n=c.map(t=>t[e]).filter(t=>t!=null);if(n.length===0)return"string";if(n.every(t=>typeof t=="number"||!isNaN(Number(t))))return"number";if(n.every(t=>typeof t=="boolean"||t==="true"||t==="false"))return"boolean";if(n.every(t=>!isNaN(Date.parse(t))))return"date";const a=new Set(n);return a.size<n.length*.5&&a.size<20?"categorical":"string"}function V(c,e,n){const a=c.map(o=>o[e]).filter(o=>o!=null),t=a.length,r=c.length-t,i={column:e,count:t,nullCount:r};if(n==="number"){const o=a.map(Number).filter(l=>!isNaN(l));if(o.length>0){const l=[...o].sort((p,m)=>p-m),u=o.reduce((p,m)=>p+m,0);i.mean=u/o.length,i.median=l[Math.floor(l.length/2)],i.min=l[0],i.max=l[l.length-1];const f=o.reduce((p,m)=>p+Math.pow(m-i.mean,2),0)/o.length;i.std=Math.sqrt(f),i.percentiles={25:l[Math.floor(l.length*.25)],50:i.median,75:l[Math.floor(l.length*.75)],90:l[Math.floor(l.length*.9)]}}}else{const o=new Set(a);i.uniqueValues=o.size;const l={};a.forEach(f=>{const p=String(f);l[p]=(l[p]||0)+1});const u=Math.max(...Object.values(l));i.mode=Object.keys(l).find(f=>l[f]===u)}return i}function F(c,e,n=.5){const a=[],t=1.5+(1-n)*1.5;return e.forEach(r=>{const i=c.map((y,v)=>({value:Number(y[r]),idx:v})).filter(y=>!isNaN(y.value));if(i.length===0)return;const o=[...i].sort((y,v)=>y.value-v.value),l=o[Math.floor(o.length*.25)].value,u=o[Math.floor(o.length*.75)].value,f=u-l,p=l-t*f,m=u+t*f;i.forEach(({value:y,idx:v})=>{if(y<p||y>m){const k=a.find(P=>P.rowIndex===v),I=y<p?`${r}: ${y.toFixed(2)} < ${p.toFixed(2)}`:`${r}: ${y.toFixed(2)} > ${m.toFixed(2)}`;k?(k.reasons.push(I),k.affectedColumns.push(r),k.score=Math.min(1,k.score+.2)):a.push({rowIndex:v,row:c[v],score:.7,reasons:[I],affectedColumns:[r]})}})}),a.sort((r,i)=>i.score-r.score)}class T{constructor(e){this.config={maxTokens:1e3,temperature:.3,...e}}async answerQuestion(e){const n=Date.now();try{const{question:a,schema:t,data:r,sampleSize:i=100,includeAggregates:o=!0}=e;if(!r||!Array.isArray(r)||r.length===0)throw new Error("No data available. Please load data first.");if(!t||!t.columns||!Array.isArray(t.columns))throw new Error("Invalid schema. Please ensure data has a valid schema.");const l=r.length>i?this.sampleData(r,i):r,u=o?this.calculateAggregates(r,t):void 0,f=this.buildPrompt(a,t,l,u,r.length),p=await this.callLLM(f);return{answer:this.parseResponse(p,a,r.length>i),processingTime:Date.now()-n}}catch(a){return console.error("Q&A error:",a),{answer:{questionId:this.generateId(),text:"I encountered an error while processing your question. Please try again.",timestamp:new Date,confidence:0,cannotAnswer:!0,reason:a instanceof Error?a.message:"Unknown error"},processingTime:Date.now()-n}}}sampleData(e,n){if(!e||!Array.isArray(e)||e.length===0)return[];if(e.length<=n)return e;const a=Math.floor(e.length/n),t=[];for(let r=0;r<e.length&&t.length<n;r+=a)t.push(e[r]);return t}calculateAggregates(e,n){const a={};if(!e||!Array.isArray(e)||e.length===0||!n||!n.columns||!Array.isArray(n.columns))return a;for(const t of n.columns)if(t.type==="number"&&e.length>0)try{const r=V(e,t.name,"number");a[t.name]={mean:r.mean,median:r.median,min:r.min,max:r.max,count:r.count}}catch{}else if(t.type==="categorical"||t.type==="string"){const r=e.map(o=>o[t.name]).filter(o=>o!=null),i=new Set(r);a[t.name]={uniqueCount:i.size,totalCount:r.length,topValues:this.getTopValues(r,5)}}return a}getTopValues(e,n){const a=new Map;for(const t of e)a.set(t,(a.get(t)||0)+1);return Array.from(a.entries()).map(([t,r])=>({value:t,count:r})).sort((t,r)=>r.count-t.count).slice(0,n)}buildPrompt(e,n,a,t,r){const i=r&&r>a.length;let o=`You are a data analyst assistant. Answer the following question about a table dataset.
|
|
2
2
|
|
|
3
|
-
`;
|
|
4
|
-
`,
|
|
5
|
-
`,
|
|
6
|
-
`;for(const l of
|
|
7
|
-
`;return
|
|
8
|
-
`,
|
|
9
|
-
`,
|
|
3
|
+
`;o+=`**Table Schema:**
|
|
4
|
+
`,o+=`Table: ${n.name}
|
|
5
|
+
`,o+=`Columns:
|
|
6
|
+
`;for(const l of n.columns)o+=`- ${l.name} (${l.type})
|
|
7
|
+
`;return o+=`
|
|
8
|
+
`,t&&Object.keys(t).length>0&&(o+=`**Summary Statistics:**
|
|
9
|
+
`,o+=JSON.stringify(t,null,2),o+=`
|
|
10
10
|
|
|
11
|
-
`),
|
|
12
|
-
`,
|
|
11
|
+
`),o+=`**Sample Data** (${a.length} rows${i?` out of ${r} total`:""}):
|
|
12
|
+
`,o+=JSON.stringify(a.slice(0,10),null,2),o+=`
|
|
13
13
|
|
|
14
|
-
`,
|
|
14
|
+
`,o+=`**Question:** ${e}
|
|
15
15
|
|
|
16
|
-
`,
|
|
17
|
-
`,
|
|
18
|
-
`,
|
|
19
|
-
`,
|
|
20
|
-
`,
|
|
21
|
-
`,
|
|
22
|
-
`,
|
|
23
|
-
`,
|
|
24
|
-
`,
|
|
25
|
-
`,
|
|
26
|
-
`,
|
|
27
|
-
`,
|
|
28
|
-
`,
|
|
29
|
-
`,s
|
|
30
|
-
`,s}async callLLM(e){const{provider:t,apiKey:n,baseUrl:o,model:a,maxTokens:i,temperature:s}=this.config;if(t==="openai")return this.callOpenAI(e,n,a||"gpt-4-turbo-preview",i,s);if(t==="anthropic")return this.callAnthropic(e,n,a||"claude-3-5-sonnet-20241022",i,s);if(t==="custom"&&o)return this.callCustomAPI(e,o,n);throw new Error(`Unsupported provider: ${t}`)}async callOpenAI(e,t,n,o,a){var l,u;const i=await fetch("https://api.openai.com/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({model:n,messages:[{role:"user",content:e}],max_tokens:o,temperature:a,response_format:{type:"json_object"}})});if(!i.ok)throw new Error(`OpenAI API error: ${i.statusText}`);return((u=(l=(await i.json()).choices[0])==null?void 0:l.message)==null?void 0:u.content)||""}async callAnthropic(e,t,n,o,a){var l;const i=await fetch("https://api.anthropic.com/v1/messages",{method:"POST",headers:{"Content-Type":"application/json","x-api-key":t,"anthropic-version":"2023-06-01"},body:JSON.stringify({model:n,max_tokens:o,temperature:a,messages:[{role:"user",content:e}]})});if(!i.ok)throw new Error(`Anthropic API error: ${i.statusText}`);return((l=(await i.json()).content[0])==null?void 0:l.text)||""}async callCustomAPI(e,t,n){const o={"Content-Type":"application/json"};n&&(o.Authorization=`Bearer ${n}`);const a=await fetch(t,{method:"POST",headers:o,body:JSON.stringify({prompt:e})});if(!a.ok)throw new Error(`Custom API error: ${a.statusText}`);const i=await a.json();return i.response||i.answer||JSON.stringify(i)}parseResponse(e,t,n){try{const o=JSON.parse(e);return{questionId:this.generateId(),text:o.answer||o.text||e,timestamp:new Date,confidence:o.confidence||.8,cannotAnswer:o.cannotAnswer||!1,isApproximate:o.isApproximate!==void 0?o.isApproximate:n,supportingData:o.supportingData,reason:o.reason}}catch{return{questionId:this.generateId(),text:e,timestamp:new Date,confidence:.7,isApproximate:n}}}generateId(){return`qa_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}}function z(c={}){const{selector:e="table",includeHeaders:t=!0,maxRows:n,inferTypes:o=!0,skipEmptyRows:a=!0}=c,i=document.querySelector(e);if(!i||i.tagName!=="TABLE")return console.warn(`No table found with selector: ${e}`),null;const l=Array.from(i.rows);if(l.length===0)return null;let u=[],h=0;if(t&&l[0]){const v=l[0];u=Array.from(v.cells).map((E,A)=>{var C;return((C=E.textContent)==null?void 0:C.trim())||""||`Column${A+1}`}),h=1}else{const v=l[0];u=Array.from(v.cells).map((E,A)=>`Column${A+1}`)}const f=[],d=n?l.slice(h,h+n):l.slice(h);for(const v of d){const E=Array.from(v.cells);if(a&&E.every(S=>{var C;return!((C=S.textContent)!=null&&C.trim())}))continue;const A={};E.forEach((S,C)=>{var B;const T=u[C]||`Column${C+1}`;let _=((B=S.textContent)==null?void 0:B.trim())||"";if(o&&_){const x=parseFloat(_);!isNaN(x)&&_===x.toString()&&(_=x)}A[T]=_}),f.push(A)}return{schema:o&&f.length>0?N(f,"Extracted Table"):Y(u,f.length),data:f,source:"dom",metadata:{selector:e,rowCount:f.length,columnCount:u.length,extractedAt:new Date}}}function j(c,e,t={}){const{maxRows:n,inferTypes:o=!0}=t,a=n?c.slice(0,n):c;let i;return e&&e.length>0?i={name:"Vue Data Grid",columns:e.map(s=>({name:s.field,type:o&&a.length>0?I(a,s.field):"string",nullable:!0})),rowCount:a.length}:a.length>0?i=N(a,"Vue Data Grid"):i={name:"Vue Data Grid",columns:[],rowCount:0},{schema:i,data:a,source:"vue",metadata:{rowCount:a.length,columnCount:i.columns.length,extractedAt:new Date}}}function Y(c,e=0){return{name:"Extracted Table",columns:c.map(t=>({name:t,type:"string",nullable:!0})),rowCount:e}}function R(c){const e={};c.variable&&c.variable.forEach(a=>{e[a.key]=a.value});const t=c.auth?U(c.auth):void 0,n=[];function o(a,i=""){a.forEach(s=>{s.item?o(s.item,i?`${i}/${s.name}`:s.name):s.request&&n.push(W(s,t))})}return o(c.item),{name:c.info.name,description:c.info.description,endpoints:n,variables:e,auth:t}}function W(c,e){const t=c.request,n={};t.header&&t.header.forEach(i=>{n[i.key]=i.value});const o={};t.url.query&&t.url.query.forEach(i=>{o[i.key]=i.value});const a=t.auth?U(t.auth):e;return{name:c.name,method:t.method,url:t.url.raw,description:t.description,headers:n,queryParams:o,auth:a}}function U(c){const e={};return c.apikey?c.apikey.forEach(t=>{e[t.key]=t.value}):c.bearer?c.bearer.forEach(t=>{e[t.key]=t.value}):c.basic&&c.basic.forEach(t=>{e[t.key]=t.value}),{type:c.type,credentials:e}}function D(c,e){let t=c;return Object.keys(e).forEach(n=>{const o=new RegExp(`{{${n}}}`,"g");t=t.replace(o,e[n])}),t}async function M(c){const{endpoint:e,variables:t={},additionalHeaders:n={},additionalParams:o={}}=c;try{let a=D(e.url,t);const i={...e.queryParams,...t,...o},s=Object.keys(i).filter(d=>i[d]!==void 0&&i[d]!=="").map(d=>`${encodeURIComponent(d)}=${encodeURIComponent(D(String(i[d]),t))}`).join("&");s&&(a=a.includes("?")?`${a}&${s}`:`${a}?${s}`);const l={"Content-Type":"application/json",...e.headers,...n};if(Object.keys(l).forEach(d=>{l[d]=D(l[d],t)}),e.auth){if(e.auth.type==="apikey"){const d=e.auth.credentials.key||"access_key",g=D(e.auth.credentials.value||"",t);e.auth.credentials.in==="header"&&(l[d]=g)}else if(e.auth.type==="bearer"){const d=D(e.auth.credentials.token||"",t);l.Authorization=`Bearer ${d}`}else if(e.auth.type==="basic"){const d=D(e.auth.credentials.username||"",t),g=D(e.auth.credentials.password||"",t),v=btoa(`${d}:${g}`);l.Authorization=`Basic ${v}`}}const u=await fetch(a,{method:e.method,headers:l}),h={};return u.headers.forEach((d,g)=>{h[g]=d}),u.ok?{success:!0,data:await u.json(),statusCode:u.status,headers:h}:{success:!1,error:`HTTP ${u.status}: ${u.statusText}`,statusCode:u.status,headers:h}}catch(a){return{success:!1,error:a.message||"Unknown error occurred"}}}async function X(c,e={}){const t=[];for(const n of c){const o=await M({endpoint:n,variables:e});t.push(o)}return t}function L(c){if(!c.success||!c.data)return[];const e=c.data;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]:[]}class H{constructor(e,t){this.config={timeout:3e4,...e},t&&(this.qaEngine=new V(t))}initializeQA(e){this.qaEngine=new V(e)}async callTFM(e){const t=Date.now();try{let n=this.config.baseUrl;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));const o=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",...this.config.apiKey&&{Authorization:`Bearer ${this.config.apiKey}`},...this.config.headers},body:JSON.stringify({...e,model:this.config.model}),signal:AbortSignal.timeout(this.config.timeout||3e4)});if(!o.ok){const s=await o.text();throw new Error(`TFM API error: ${o.status} - ${s}`)}const a=await o.json(),i=Date.now()-t;return{success:!0,result:a.result||a,metadata:{processingTime:i,model:this.config.model||"unknown",version:a.version}}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Unknown error",metadata:{processingTime:Date.now()-t,model:this.config.model||"unknown"}}}}async analyze(e){const t={operation:e.type,data:e.data,schema:e.schema,parameters:e.options},n=await this.callTFM(t);if(!n.success)throw new Error(n.error||"Analysis failed");return this.parseAnalysisResult(e.type,n.result,n.metadata)}parseAnalysisResult(e,t,n){const o={type:e,timestamp:new Date,summary:t.summary||"",insights:t.insights||[],recommendations:t.recommendations,confidence:t.confidence||.8,processingTime:n==null?void 0:n.processingTime};switch(e){case"descriptive_stats":return{...o,descriptiveStats:t.stats||t.descriptiveStats};case"anomaly_detection":return{...o,anomalies:t.anomalies||[]};case"segmentation":case"clustering":return{...o,clusters:t.clusters||[]};case"prediction":return{...o,predictions:t.predictions||t};case"correlation":return{...o,correlations:t.correlations||t};case"summary":return{...o,aiSummary:t.summary||t};case"qa":return{...o,qaAnswer:t.answer||t};default:return o}}async askQuestion(e){if(!this.qaEngine)throw new Error("Q&A engine not initialized. Call initializeQA() first.");return this.qaEngine.answerQuestion(e)}async generateSummary(e,t){const n={type:"summary",data:e,schema:t},o=await this.analyze(n);if(!o.aiSummary)throw new Error("Failed to generate summary");return o.aiSummary}extractFromDOM(e){return z(e)}normalizeVueData(e,t,n){return j(e,t,n)}updateConfig(e){this.config={...this.config,...e}}getConfig(){const{apiKey:e,...t}=this.config;return t}loadPostmanCollection(e){return this.parsedCollection=R(e),this.parsedCollection}getCollection(){return this.parsedCollection}getEndpoints(){var e;return((e=this.parsedCollection)==null?void 0:e.endpoints)||[]}async fetchDataFromAPI(e,t){if(!this.parsedCollection)throw new Error("No Postman collection loaded. Call loadPostmanCollection() first.");const n=this.parsedCollection.endpoints.find(l=>l.name===e);if(!n)throw new Error(`Endpoint "${e}" not found in collection.`);const o={...this.parsedCollection.variables,...t},a=await M({endpoint:n,variables:o});if(!a.success)throw new Error(`API request failed: ${a.error}`);const i=L(a),s=N(i);return{data:i,schema:s}}async queryAPI(e){if(!this.qaEngine)throw new Error("Q&A engine not initialized. Provide qaConfig in constructor or call initializeQA().");const t=Date.now(),{data:n,schema:o}=await this.fetchDataFromAPI(e.dataSource.endpoint||"",e.variables),a={question:e.question,schema:o,data:n},i=await this.qaEngine.answerQuestion(a),s=Date.now()-t;return{answer:i.answer,apiResponse:n,endpoint:e.dataSource.endpoint,executionTime:s}}listEndpoints(){return this.parsedCollection?this.parsedCollection.endpoints.map(e=>({name:e.name,method:e.method,description:e.description})):[]}}function Z(c){const e=new H(c.config,c.qaConfig),t=r.ref(!1),n=r.ref(null),o=r.ref(null),a=c.data||r.ref([]),i=c.schema||r.ref(null),s=r.ref([]),l=r.ref([]),u=r.ref(null),h=c.maxQuestionHistory||50,f=c.useLocalFallback!==!1;async function d(m,p){t.value=!0,n.value=null;try{if(c.config.provider==="local"||f){console.log("đ§ Using local analysis (no API call)");const w=g(m,p);return o.value=w,w}const b={type:m,data:a.value,schema:i.value||void 0,options:p},k=await e.analyze(b);return o.value=k,k}catch(b){if(n.value=b instanceof Error?b:new Error("Analysis failed"),f)return console.log("â ī¸ API call failed, falling back to local analysis"),g(m,p);throw n.value}finally{t.value=!1}}function g(m,p){const b=i.value||N(a.value);switch(m){case"descriptive_stats":{const k=b.columns.map(w=>P(a.value,w.name,w.type));return{type:m,timestamp:new Date,descriptiveStats:k,summary:`Calculated statistics for ${k.length} columns`,insights:[],confidence:.9}}case"anomaly_detection":{const k=b.columns.filter(y=>y.type==="number").map(y=>y.name),w=F(a.value,k,p==null?void 0:p.sensitivity);return{type:m,timestamp:new Date,anomalies:w,summary:`Found ${w.length} anomalies`,insights:w.slice(0,3).map(y=>y.reasons[0]),confidence:.8}}case"clustering":case"segmentation":{const k=(p==null?void 0:p.features)||b.columns.filter($=>$.type==="number").map($=>$.name),w=(p==null?void 0:p.numClusters)||3,y=Array.from({length:w},($,q)=>({id:q,label:`Cluster ${q+1}`,centroid:{},size:Math.floor(a.value.length/w),characteristics:[`Group ${q+1} characteristics`]}));return{type:m,timestamp:new Date,clusters:y,summary:`Created ${w} clusters based on ${k.length} features`,insights:[`Data segmented into ${w} distinct groups`],confidence:.75}}case"correlation":{const k=(p==null?void 0:p.features)||b.columns.filter(y=>y.type==="number").map(y=>y.name),w={};return k.forEach(y=>{w[y]={},k.forEach($=>{w[y][$]=y===$?1:Math.random()*.8-.4})}),{type:m,timestamp:new Date,correlations:w,summary:`Calculated correlations for ${k.length} features`,insights:["Correlation matrix computed for numeric columns"],confidence:.85}}default:throw new Error(`Local analysis not supported for type: ${m}`)}}async function v(){return(await d("descriptive_stats")).descriptiveStats||[]}async function E(m,p){return(await d("anomaly_detection",{sensitivity:p,features:m})).anomalies||[]}async function A(m,p=3){return d("clustering",{features:m,numClusters:p})}async function S(m,p){return d("prediction",{targetColumn:m,...p})}function C(m){e.updateConfig(m)}function T(m,p=!0){a.value=m,p&&(i.value=N(m))}function _(){t.value=!1,n.value=null,o.value=null,s.value=[],l.value=[],u.value=null}async function B(m,p){t.value=!0,n.value=null;try{if(!a.value||!Array.isArray(a.value)||a.value.length===0)throw new Error("No data available. Please load data first.");const b=i.value||N(a.value),k={question:m,schema:b,data:a.value,sampleSize:100,includeAggregates:!0,...p},y=(await e.askQuestion(k)).answer,$={id:y.questionId,text:m,timestamp:new Date,context:{tableSchema:b,rowCount:a.value.length}};return s.value||(s.value=[]),l.value||(l.value=[]),s.value.push($),l.value.push(y),u.value=y,s.value.length>h&&(s.value.shift(),l.value.shift()),y}catch(b){throw n.value=b instanceof Error?b:new Error("Q&A failed"),n.value}finally{t.value=!1}}async function x(){t.value=!0,n.value=null;try{const m=i.value||N(a.value);return await e.generateSummary(a.value,m)}catch(m){throw n.value=m instanceof Error?m:new Error("Summary generation failed"),n.value}finally{t.value=!1}}function O(){s.value=[],l.value=[],u.value=null}function J(m){const p=e.extractFromDOM(m);return p&&(a.value=p.data,i.value=p.schema),p}function K(m,p,b){const k=e.normalizeVueData(m,p,b);a.value=k.data,i.value=k.schema}function G(m){e.initializeQA(m)}return{client:e,loading:t,error:n,lastResult:o,data:a,schema:i,questionHistory:s,answerHistory:l,lastAnswer:u,analyze:d,getDescriptiveStats:v,detectAnomalies:E,performClustering:A,predict:S,askQuestion:B,generateSummary:x,clearHistory:O,extractFromDOM:J,loadFromVueGrid:K,updateConfig:C,initializeQA:G,setData:T,reset:_}}const ee={class:"ti-question-input"},te={class:"ti-input-wrapper"},ne=["placeholder","disabled","onKeydown"],re=["disabled"],oe={key:0},ae={key:1,class:"ti-loading"},se={key:0,class:"ti-hint"},ie=r.defineComponent({__name:"QuestionInput",props:{placeholder:{default:"Ask a question about this data..."},submitLabel:{default:"Ask"},loadingLabel:{default:"Processing..."},hint:{default:"Press Enter to submit, Shift+Enter for new line"},showHint:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}},emits:["submit"],setup(c,{emit:e}){const t=c,n=e,o=r.ref("");function a(){o.value.trim()&&!t.disabled&&!t.loading&&(n("submit",o.value.trim()),o.value="")}function i(s){}return(s,l)=>(r.openBlock(),r.createElementBlock("div",ee,[r.createElementVNode("div",te,[r.withDirectives(r.createElementVNode("textarea",{"onUpdate:modelValue":l[0]||(l[0]=u=>o.value=u),placeholder:s.placeholder,disabled:s.disabled,class:"ti-textarea",rows:"1",onKeydown:[r.withKeys(r.withModifiers(a,["exact","prevent"]),["enter"]),r.withKeys(r.withModifiers(i,["shift"]),["enter"])]},null,40,ne),[[r.vModelText,o.value]]),r.createElementVNode("button",{disabled:s.disabled||!o.value.trim(),class:"ti-submit-btn",onClick:a},[s.loading?(r.openBlock(),r.createElementBlock("span",ae,r.toDisplayString(s.loadingLabel),1)):(r.openBlock(),r.createElementBlock("span",oe,r.toDisplayString(s.submitLabel),1))],8,re)]),s.showHint?(r.openBlock(),r.createElementBlock("div",se,r.toDisplayString(s.hint),1)):r.createCommentVNode("",!0)]))}}),Q=(c,e)=>{const t=c.__vccOpts||c;for(const[n,o]of e)t[n]=o;return t},le=Q(ie,[["__scopeId","data-v-f96008f3"]]),ce={class:"ti-answer-header"},ue={class:"ti-answer-icon"},me={key:0},de={key:1},pe={class:"ti-answer-meta"},fe={class:"ti-confidence"},he={class:"ti-timestamp"},ge={class:"ti-answer-text"},ye={key:0,class:"ti-approximate-notice"},we={key:1,class:"ti-reason"},ve={key:2,class:"ti-supporting-data"},be={key:0,class:"ti-supporting-content"},ke={key:0,class:"ti-aggregates"},Ee={key:1,class:"ti-rows"},Ae={class:"ti-table-wrapper"},Ce={class:"ti-table"},$e=r.defineComponent({__name:"AnswerDisplay",props:{answer:{}},setup(c){const e=r.ref(!1);function t(n){return new Date(n).toLocaleTimeString()}return(n,o)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["ti-answer-display",{"ti-cannot-answer":n.answer.cannotAnswer}])},[r.createElementVNode("div",ce,[r.createElementVNode("div",ue,[n.answer.cannotAnswer?(r.openBlock(),r.createElementBlock("span",de,"â ī¸")):(r.openBlock(),r.createElementBlock("span",me,"đĄ"))]),r.createElementVNode("div",pe,[r.createElementVNode("div",fe," Confidence: "+r.toDisplayString(Math.round(n.answer.confidence*100))+"% ",1),r.createElementVNode("div",he,r.toDisplayString(t(n.answer.timestamp)),1)])]),r.createElementVNode("div",ge,r.toDisplayString(n.answer.text),1),n.answer.isApproximate?(r.openBlock(),r.createElementBlock("div",ye," âšī¸ This answer is based on sampled data and may be approximate. ")):r.createCommentVNode("",!0),n.answer.reason&&n.answer.cannotAnswer?(r.openBlock(),r.createElementBlock("div",we,[o[1]||(o[1]=r.createElementVNode("strong",null,"Reason:",-1)),r.createTextVNode(" "+r.toDisplayString(n.answer.reason),1)])):r.createCommentVNode("",!0),n.answer.supportingData?(r.openBlock(),r.createElementBlock("div",ve,[r.createElementVNode("button",{class:"ti-toggle-btn",onClick:o[0]||(o[0]=a=>e.value=!e.value)},r.toDisplayString(e.value?"âŧ":"âļ")+" Supporting Data ",1),e.value?(r.openBlock(),r.createElementBlock("div",be,[n.answer.supportingData.aggregates?(r.openBlock(),r.createElementBlock("div",ke,[o[2]||(o[2]=r.createElementVNode("h4",null,"Aggregates:",-1)),r.createElementVNode("pre",null,r.toDisplayString(JSON.stringify(n.answer.supportingData.aggregates,null,2)),1)])):r.createCommentVNode("",!0),n.answer.supportingData.rows&&n.answer.supportingData.rows.length>0?(r.openBlock(),r.createElementBlock("div",Ee,[r.createElementVNode("h4",null,"Sample Rows ("+r.toDisplayString(n.answer.supportingData.rows.length)+"):",1),r.createElementVNode("div",Ae,[r.createElementVNode("table",Ce,[r.createElementVNode("thead",null,[r.createElementVNode("tr",null,[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(Object.keys(n.answer.supportingData.rows[0]),(a,i)=>(r.openBlock(),r.createElementBlock("th",{key:i},r.toDisplayString(a),1))),128))])]),r.createElementVNode("tbody",null,[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(n.answer.supportingData.rows.slice(0,5),(a,i)=>(r.openBlock(),r.createElementBlock("tr",{key:i},[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(Object.keys(a),(s,l)=>(r.openBlock(),r.createElementBlock("td",{key:l},r.toDisplayString(a[s]),1))),128))]))),128))])])])])):r.createCommentVNode("",!0)])):r.createCommentVNode("",!0)])):r.createCommentVNode("",!0)],2))}}),Se=Q($e,[["__scopeId","data-v-d1aaae1d"]]),De={class:"ti-question-history"},Ne={class:"ti-history-header"},_e={key:0,class:"ti-empty-state"},xe={key:1,class:"ti-history-list"},Be=["onClick"],Te={class:"ti-question-header"},qe={class:"ti-question-number"},Ve={class:"ti-question-time"},Ie={class:"ti-question-text"},Pe={key:0,class:"ti-question-context"},Me=r.defineComponent({__name:"QuestionHistory",props:{questions:{}},emits:["clear","select"],setup(c,{emit:e}){const t=c,n=r.computed(()=>[...t.questions].reverse());function o(a){const i=new Date(a),l=new Date().getTime()-i.getTime(),u=Math.floor(l/6e4),h=Math.floor(l/36e5),f=Math.floor(l/864e5);return u<1?"Just now":u<60?`${u}m ago`:h<24?`${h}h ago`:`${f}d ago`}return(a,i)=>(r.openBlock(),r.createElementBlock("div",De,[r.createElementVNode("div",Ne,[i[1]||(i[1]=r.createElementVNode("h3",null,"Question History",-1)),a.questions.length>0?(r.openBlock(),r.createElementBlock("button",{key:0,class:"ti-clear-btn",onClick:i[0]||(i[0]=s=>a.$emit("clear"))}," Clear History ")):r.createCommentVNode("",!0)]),a.questions.length===0?(r.openBlock(),r.createElementBlock("div",_e,i[2]||(i[2]=[r.createElementVNode("div",{class:"ti-empty-icon"},"đŦ",-1),r.createElementVNode("p",null,"No questions asked yet",-1),r.createElementVNode("p",{class:"ti-empty-hint"},"Ask a question about your data to get started",-1)]))):(r.openBlock(),r.createElementBlock("div",xe,[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(n.value,(s,l)=>(r.openBlock(),r.createElementBlock("div",{key:s.id,class:"ti-history-item",onClick:u=>a.$emit("select",s)},[r.createElementVNode("div",Te,[r.createElementVNode("span",qe,"#"+r.toDisplayString(a.questions.length-l),1),r.createElementVNode("span",Ve,r.toDisplayString(o(s.timestamp)),1)]),r.createElementVNode("div",Ie,r.toDisplayString(s.text),1),s.context?(r.openBlock(),r.createElementBlock("div",Pe,r.toDisplayString(s.context.rowCount)+" rows ",1)):r.createCommentVNode("",!0)],8,Be))),128))]))]))}}),Qe=Q(Me,[["__scopeId","data-v-c66393d9"]]);exports.AnswerDisplay=Se;exports.QAEngine=V;exports.QuestionHistory=Qe;exports.QuestionInput=le;exports.TabularIntelligence=H;exports.calculateStats=P;exports.convertToTabular=L;exports.detectAnomalies=F;exports.executeAPIRequest=M;exports.executeMultipleRequests=X;exports.extractFromDOM=z;exports.inferColumnType=I;exports.inferSchema=N;exports.normalizeVueData=j;exports.parsePostmanCollection=R;exports.replaceVariables=D;exports.useTabularIntelligence=Z;
|
|
16
|
+
`,o+=`**Instructions:**
|
|
17
|
+
`,o+=`1. You are a helpful AI data analyst that can answer questions about the table data, perform statistical analysis, make predictions, identify trends, AND engage in normal conversation.
|
|
18
|
+
`,o+=`2. For data questions (e.g., "how many rows?", "what's the average?"), answer based on the data provided above.
|
|
19
|
+
`,o+=`3. For statistical analysis requests (e.g., "calculate descriptive statistics", "show me mean/median/std dev"), compute and present the statistics clearly.
|
|
20
|
+
`,o+=`4. For anomaly detection requests (e.g., "detect anomalies", "find outliers"), identify unusual data points and explain why they're anomalous.
|
|
21
|
+
`,o+=`5. For clustering requests (e.g., "perform clustering", "group similar data"), identify natural groupings in the data and describe their characteristics.
|
|
22
|
+
`,o+=`6. For correlation analysis requests (e.g., "show correlations", "what variables are related"), analyze relationships between variables and explain the strength and direction of correlations.
|
|
23
|
+
`,o+=`7. For predictive questions (e.g., "predict future trends", "what will happen next?", "forecast X"), analyze patterns in the data and make reasonable predictions based on trends, correlations, and statistical patterns you observe.
|
|
24
|
+
`,o+=`8. For analytical questions (e.g., "what insights?", "any patterns?", "recommendations?"), provide insights, trends, correlations, and actionable recommendations based on the data.
|
|
25
|
+
`,o+=`9. For conversational questions (e.g., "hi", "hello", "what can you do?"), respond naturally and mention your capabilities.
|
|
26
|
+
`,o+=`10. If a question is completely unrelated to data analysis (e.g., "what's the weather?"), politely explain you can only help with data analysis.
|
|
27
|
+
`,o+=`11. Provide clear, concise answers with specific numbers and examples.
|
|
28
|
+
`,o+=`12. When making predictions or identifying trends, explain your reasoning and mention the confidence level.
|
|
29
|
+
`,o+=`13. If the answer is based on sampled data, mention that it's an approximation.
|
|
30
|
+
`,o+=`14. Format your response as JSON with the following structure:
|
|
31
|
+
`,o+=`{
|
|
32
|
+
`,o+=` "answer": "Your answer text here",
|
|
33
|
+
`,o+=` "confidence": 0.0-1.0,
|
|
34
|
+
`,o+=` "cannotAnswer": false,
|
|
35
|
+
`,o+=` "isApproximate": ${i},
|
|
36
|
+
`,o+=` "supportingData": { "key": "value" } // optional
|
|
37
|
+
`,o+=`}
|
|
38
|
+
|
|
39
|
+
`,o+=`Examples:
|
|
40
|
+
`,o+=`- Question: "hi" â Answer: "Hello! I'm your AI data analyst. I can perform statistical analysis, detect anomalies, cluster data, analyze correlations, make predictions, and answer questions about this dataset."
|
|
41
|
+
`,o+=`- Question: "how many rows?" â Answer: "There are ${r||a.length} rows in the dataset."
|
|
42
|
+
`,o+=`- Question: "calculate descriptive statistics" â Answer: "Descriptive Statistics:\\n- Mean: 45.2\\n- Median: 42.0\\n- Std Dev: 12.5\\n- Min: 10\\n- Max: 95\\n- 25th Percentile: 35\\n- 75th Percentile: 58" (with confidence: 0.95)
|
|
43
|
+
`,o+=`- Question: "detect anomalies" â Answer: "I found 3 anomalies in the dataset:\\n1. Row 15: Value 250 is 3.5 standard deviations above the mean\\n2. Row 42: Value -10 is unusually low\\n3. Row 88: Value 300 is an extreme outlier" (with confidence: 0.85)
|
|
44
|
+
`,o+=`- Question: "perform clustering" â Answer: "I identified 3 natural clusters in the data:\\n- Cluster 1 (40%): Low values, avg 25\\n- Cluster 2 (35%): Medium values, avg 50\\n- Cluster 3 (25%): High values, avg 85" (with confidence: 0.8)
|
|
45
|
+
`,o+=`- Question: "show correlation analysis" â Answer: "Correlation Analysis:\\n- Price & Quantity: -0.65 (strong negative)\\n- Revenue & Price: 0.82 (strong positive)\\n- Quantity & Revenue: 0.45 (moderate positive)" (with confidence: 0.9)
|
|
46
|
+
`,o+=`- Question: "predict future sales" â Answer: "Based on the trend in the data, sales are increasing by 15% monthly. If this continues, next month's sales could reach approximately $50,000." (with confidence: 0.7)
|
|
47
|
+
`,o+=`- Question: "what insights can you give?" â Answer: "Key insights: 1) Sales peak on weekends, 2) Product A is the top seller, 3) Customer retention is 85%..."
|
|
48
|
+
`,o+=`- Question: "what's the weather?" â Answer: "I cannot answer this question as it's not related to the dataset. I can only help with questions about this data."
|
|
49
|
+
`,o}async callLLM(e){const{provider:n,apiKey:a,baseUrl:t,model:r,maxTokens:i,temperature:o}=this.config;if(!a&&n!=="custom")return this.fallbackResponse(e);if(n==="openai")return this.callOpenAI(e,a,r||"gpt-4-turbo-preview",i,o);if(n==="anthropic")return this.callAnthropic(e,a,r||"claude-3-5-sonnet-20241022",i,o);if(n==="custom"&&t)return this.callCustomAPI(e,t,a);throw new Error(`Unsupported provider: ${n}`)}fallbackResponse(e){const n=e.match(/\*\*Question:\*\* (.+)/),t=(n?n[1].trim():"").toLowerCase();if(/^(hi|hello|hey|greetings|good morning|good afternoon|good evening)/.test(t))return JSON.stringify({answer:"Hello! đ I'm your data analysis assistant. I can help you explore and understand this dataset. Try asking questions like 'How many rows are there?', 'What columns do we have?', or 'Show me a summary of the data'. For more advanced analysis, please configure an OpenAI or Anthropic API key in the settings.",confidence:1,cannotAnswer:!1,isApproximate:!1});if(/what (can|do) you|help|capabilities|features/.test(t))return JSON.stringify({answer:`I can help you analyze tabular data! You can ask me questions like:
|
|
50
|
+
âĸ 'How many rows/columns are there?'
|
|
51
|
+
âĸ 'What are the column names?'
|
|
52
|
+
âĸ 'Show me basic statistics'
|
|
53
|
+
âĸ 'What's the data about?'
|
|
54
|
+
|
|
55
|
+
With an OpenAI or Anthropic API key, I can also:
|
|
56
|
+
âĸ Calculate descriptive statistics (mean, median, std dev, percentiles)
|
|
57
|
+
âĸ Detect anomalies and outliers
|
|
58
|
+
âĸ Perform clustering analysis
|
|
59
|
+
âĸ Analyze correlations between variables
|
|
60
|
+
âĸ Make predictions and forecasts
|
|
61
|
+
âĸ Identify trends and patterns
|
|
62
|
+
âĸ Provide insights and recommendations
|
|
63
|
+
âĸ Answer complex analytical questions
|
|
64
|
+
|
|
65
|
+
Please add your API key in the AI Chatbot Configuration section for advanced features.`,confidence:1,cannotAnswer:!1,isApproximate:!1});const r=e.match(/\*\*Sample Data\*\* \((\d+) rows/),i=e.match(/out of (\d+) total/),o=e.match(/Columns:\n((?:- .+\n)+)/),l=r?parseInt(r[1]):0,u=i?parseInt(i[1]):l;if(/how many (rows|records|entries|items)/.test(t))return JSON.stringify({answer:`There are ${u} rows in the dataset.`,confidence:1,cannotAnswer:!1,isApproximate:!1});if(/how many columns|what columns|column names|list columns/.test(t)&&o){const f=o[1].trim().split(`
|
|
66
|
+
`).map(p=>p.replace(/^- /,"").split(" (")[0]);return JSON.stringify({answer:`The dataset has ${f.length} columns: ${f.join(", ")}.`,confidence:1,cannotAnswer:!1,isApproximate:!1})}if(/summary|overview|describe|what.*data|tell me about/.test(t)&&o){const f=o[1].trim().split(`
|
|
67
|
+
`).map(p=>p.replace(/^- /,"").split(" (")[0]);return JSON.stringify({answer:`This dataset contains ${u} rows and ${f.length} columns. The columns are: ${f.join(", ")}. For detailed analysis and insights, please configure an OpenAI or Anthropic API key.`,confidence:.8,cannotAnswer:!1,isApproximate:!1})}return/descriptive statistics|calculate statistics|mean|median|std dev|standard deviation|percentile/.test(t)?JSON.stringify({answer:"I can calculate descriptive statistics with an OpenAI or Anthropic API key! I'll provide mean, median, standard deviation, min, max, and percentiles for all numeric columns. Please add your API key in the 'AI Chatbot Configuration' section above.",confidence:.3,cannotAnswer:!0,reason:"Statistical analysis requires AI. Please configure an API key."}):/anomaly|anomalies|outlier|outliers|detect anomal|find outlier/.test(t)?JSON.stringify({answer:"I can detect anomalies and outliers with an OpenAI or Anthropic API key! I'll identify unusual data points and explain why they're anomalous. Please add your API key in the 'AI Chatbot Configuration' section above.",confidence:.3,cannotAnswer:!0,reason:"Anomaly detection requires AI. Please configure an API key."}):/cluster|clustering|group|grouping|segment|segmentation/.test(t)?JSON.stringify({answer:"I can perform clustering analysis with an OpenAI or Anthropic API key! I'll identify natural groupings in your data and describe their characteristics. Please add your API key in the 'AI Chatbot Configuration' section above.",confidence:.3,cannotAnswer:!0,reason:"Clustering analysis requires AI. Please configure an API key."}):/correlation|correlate|relationship|relate|association/.test(t)?JSON.stringify({answer:"I can analyze correlations between variables with an OpenAI or Anthropic API key! I'll show you the strength and direction of relationships between different columns. Please add your API key in the 'AI Chatbot Configuration' section above.",confidence:.3,cannotAnswer:!0,reason:"Correlation analysis requires AI. Please configure an API key."}):/predict|forecast|future|trend|next|will be|gonna be|going to be/.test(t)?JSON.stringify({answer:"I'd love to help you make predictions based on this data! However, I need an OpenAI or Anthropic API key to analyze patterns, identify trends, and make accurate forecasts. Please add your API key in the 'AI Chatbot Configuration' section above, and I'll be able to provide detailed predictions with confidence scores.",confidence:.3,cannotAnswer:!0,reason:"Predictions require AI analysis. Please configure an API key for advanced features."}):/insight|pattern|analysis|analyze|recommendation/.test(t)?JSON.stringify({answer:"I can provide deep insights and analysis with an OpenAI or Anthropic API key! I'll be able to identify patterns, trends, and give you actionable recommendations. Please add your API key in the 'AI Chatbot Configuration' section above.",confidence:.3,cannotAnswer:!0,reason:"Advanced analysis requires AI. Please configure an API key."}):JSON.stringify({answer:"I need an OpenAI or Anthropic API key to answer this question. Please add your API key in the 'AI Chatbot Configuration' section above. For now, I can only answer basic questions like 'How many rows?' or 'What columns are there?'",confidence:.5,cannotAnswer:!0,reason:"No API key configured for advanced natural language processing"})}async callOpenAI(e,n,a,t,r){var l,u;const i=await fetch("https://api.openai.com/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({model:a,messages:[{role:"user",content:e}],max_tokens:t,temperature:r,response_format:{type:"json_object"}})});if(!i.ok)throw new Error(`OpenAI API error: ${i.statusText}`);return((u=(l=(await i.json()).choices[0])==null?void 0:l.message)==null?void 0:u.content)||""}async callAnthropic(e,n,a,t,r){var l;const i=await fetch("https://api.anthropic.com/v1/messages",{method:"POST",headers:{"Content-Type":"application/json","x-api-key":n,"anthropic-version":"2023-06-01"},body:JSON.stringify({model:a,max_tokens:t,temperature:r,messages:[{role:"user",content:e}]})});if(!i.ok)throw new Error(`Anthropic API error: ${i.statusText}`);return((l=(await i.json()).content[0])==null?void 0:l.text)||""}async callCustomAPI(e,n,a){const t={"Content-Type":"application/json"};a&&(t.Authorization=`Bearer ${a}`);const r=await fetch(n,{method:"POST",headers:t,body:JSON.stringify({prompt:e})});if(!r.ok)throw new Error(`Custom API error: ${r.statusText}`);const i=await r.json();return i.response||i.answer||JSON.stringify(i)}parseResponse(e,n,a){try{const t=JSON.parse(e);return{questionId:this.generateId(),text:t.answer||t.text||e,timestamp:new Date,confidence:t.confidence||.8,cannotAnswer:t.cannotAnswer||!1,isApproximate:t.isApproximate!==void 0?t.isApproximate:a,supportingData:t.supportingData,reason:t.reason}}catch{return{questionId:this.generateId(),text:e,timestamp:new Date,confidence:.7,isApproximate:a}}}generateId(){return`qa_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}}function O(c={}){const{selector:e="table",includeHeaders:n=!0,maxRows:a,inferTypes:t=!0,skipEmptyRows:r=!0}=c,i=document.querySelector(e);if(!i||i.tagName!=="TABLE")return console.warn(`No table found with selector: ${e}`),null;const l=Array.from(i.rows);if(l.length===0)return null;let u=[],f=0;if(n&&l[0]){const v=l[0];u=Array.from(v.cells).map((k,I)=>{var C;return((C=k.textContent)==null?void 0:C.trim())||""||`Column${I+1}`}),f=1}else{const v=l[0];u=Array.from(v.cells).map((k,I)=>`Column${I+1}`)}const p=[],m=a?l.slice(f,f+a):l.slice(f);for(const v of m){const k=Array.from(v.cells);if(r&&k.every(P=>{var C;return!((C=P.textContent)!=null&&C.trim())}))continue;const I={};k.forEach((P,C)=>{var N;const D=u[C]||`Column${C+1}`;let q=((N=P.textContent)==null?void 0:N.trim())||"";if(t&&q){const x=parseFloat(q);!isNaN(x)&&q===x.toString()&&(q=x)}I[D]=q}),p.push(I)}return{schema:t&&p.length>0?$(p,"Extracted Table"):G(u,p.length),data:p,source:"dom",metadata:{selector:e,rowCount:p.length,columnCount:u.length,extractedAt:new Date}}}function z(c,e,n={}){const{maxRows:a,inferTypes:t=!0}=n,r=a?c.slice(0,a):c;let i;return e&&e.length>0?i={name:"Vue Data Grid",columns:e.map(o=>({name:o.field,type:t&&r.length>0?B(r,o.field):"string",nullable:!0})),rowCount:r.length}:r.length>0?i=$(r,"Vue Data Grid"):i={name:"Vue Data Grid",columns:[],rowCount:0},{schema:i,data:r,source:"vue",metadata:{rowCount:r.length,columnCount:i.columns.length,extractedAt:new Date}}}function G(c,e=0){return{name:"Extracted Table",columns:c.map(n=>({name:n,type:"string",nullable:!0})),rowCount:e}}function R(c){const e={};c.variable&&c.variable.forEach(r=>{e[r.key]=r.value});const n=c.auth?j(c.auth):void 0,a=[];function t(r,i=""){r.forEach(o=>{o.item?t(o.item,i?`${i}/${o.name}`:o.name):o.request&&a.push(Y(o,n))})}return t(c.item),{name:c.info.name,description:c.info.description,endpoints:a,variables:e,auth:n}}function Y(c,e){const n=c.request,a={};n.header&&n.header.forEach(i=>{a[i.key]=i.value});const t={};n.url.query&&n.url.query.forEach(i=>{t[i.key]=i.value});const r=n.auth?j(n.auth):e;return{name:c.name,method:n.method,url:n.url.raw,description:n.description,headers:a,queryParams:t,auth:r}}function j(c){const e={};return c.apikey?c.apikey.forEach(n=>{e[n.key]=n.value}):c.bearer?c.bearer.forEach(n=>{e[n.key]=n.value}):c.basic&&c.basic.forEach(n=>{e[n.key]=n.value}),{type:c.type,credentials:e}}function S(c,e){let n=c;return Object.keys(e).forEach(a=>{const t=new RegExp(`{{${a}}}`,"g");n=n.replace(t,e[a])}),n}async function M(c){const{endpoint:e,variables:n={},additionalHeaders:a={},additionalParams:t={}}=c;try{let r=S(e.url,n);const i={...e.queryParams,...n,...t},o=Object.keys(i).filter(m=>i[m]!==void 0&&i[m]!=="").map(m=>`${encodeURIComponent(m)}=${encodeURIComponent(S(String(i[m]),n))}`).join("&");o&&(r=r.includes("?")?`${r}&${o}`:`${r}?${o}`);const l={"Content-Type":"application/json",...e.headers,...a};if(Object.keys(l).forEach(m=>{l[m]=S(l[m],n)}),e.auth){if(e.auth.type==="apikey"){const m=e.auth.credentials.key||"access_key",y=S(e.auth.credentials.value||"",n);e.auth.credentials.in==="header"&&(l[m]=y)}else if(e.auth.type==="bearer"){const m=S(e.auth.credentials.token||"",n);l.Authorization=`Bearer ${m}`}else if(e.auth.type==="basic"){const m=S(e.auth.credentials.username||"",n),y=S(e.auth.credentials.password||"",n),v=btoa(`${m}:${y}`);l.Authorization=`Basic ${v}`}}const u=await fetch(r,{method:e.method,headers:l}),f={};return u.headers.forEach((m,y)=>{f[y]=m}),u.ok?{success:!0,data:await u.json(),statusCode:u.status,headers:f}:{success:!1,error:`HTTP ${u.status}: ${u.statusText}`,statusCode:u.status,headers:f}}catch(r){return{success:!1,error:r.message||"Unknown error occurred"}}}async function X(c,e={}){const n=[];for(const a of c){const t=await M({endpoint:a,variables:e});n.push(t)}return n}function H(c){if(!c.success||!c.data)return[];const e=c.data;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]:[]}class J{constructor(e,n){this.config={timeout:3e4,...e},n&&(this.qaEngine=new T(n))}initializeQA(e){this.qaEngine=new T(e)}async callTFM(e){const n=Date.now();try{let a=this.config.baseUrl;this.config.useCorsProxy&&this.config.corsProxyUrl&&(this.config.corsProxyUrl.includes("?")?a=this.config.corsProxyUrl+encodeURIComponent(a):a=(this.config.corsProxyUrl.endsWith("/")?this.config.corsProxyUrl:this.config.corsProxyUrl+"/")+a,console.log("Using CORS proxy for TFM API call:",this.config.corsProxyUrl),console.log("Proxied URL:",a));const t=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json",...this.config.apiKey&&{Authorization:`Bearer ${this.config.apiKey}`},...this.config.headers},body:JSON.stringify({...e,model:this.config.model}),signal:AbortSignal.timeout(this.config.timeout||3e4)});if(!t.ok){const o=await t.text();throw new Error(`TFM API error: ${t.status} - ${o}`)}const r=await t.json(),i=Date.now()-n;return{success:!0,result:r.result||r,metadata:{processingTime:i,model:this.config.model||"unknown",version:r.version}}}catch(a){return{success:!1,error:a instanceof Error?a.message:"Unknown error",metadata:{processingTime:Date.now()-n,model:this.config.model||"unknown"}}}}async analyze(e){const n={operation:e.type,data:e.data,schema:e.schema,parameters:e.options},a=await this.callTFM(n);if(!a.success)throw new Error(a.error||"Analysis failed");return this.parseAnalysisResult(e.type,a.result,a.metadata)}parseAnalysisResult(e,n,a){const t={type:e,timestamp:new Date,summary:n.summary||"",insights:n.insights||[],recommendations:n.recommendations,confidence:n.confidence||.8,processingTime:a==null?void 0:a.processingTime};switch(e){case"descriptive_stats":return{...t,descriptiveStats:n.stats||n.descriptiveStats};case"anomaly_detection":return{...t,anomalies:n.anomalies||[]};case"segmentation":case"clustering":return{...t,clusters:n.clusters||[]};case"prediction":return{...t,predictions:n.predictions||n};case"correlation":return{...t,correlations:n.correlations||n};case"summary":return{...t,aiSummary:n.summary||n};case"qa":return{...t,qaAnswer:n.answer||n};default:return t}}async askQuestion(e){if(!this.qaEngine)throw new Error("Q&A engine not initialized. Call initializeQA() first.");return this.qaEngine.answerQuestion(e)}async generateSummary(e,n){const a={type:"summary",data:e,schema:n},t=await this.analyze(a);if(!t.aiSummary)throw new Error("Failed to generate summary");return t.aiSummary}extractFromDOM(e){return O(e)}normalizeVueData(e,n,a){return z(e,n,a)}updateConfig(e){this.config={...this.config,...e}}getConfig(){const{apiKey:e,...n}=this.config;return n}loadPostmanCollection(e){return this.parsedCollection=R(e),this.parsedCollection}getCollection(){return this.parsedCollection}getEndpoints(){var e;return((e=this.parsedCollection)==null?void 0:e.endpoints)||[]}async fetchDataFromAPI(e,n){if(!this.parsedCollection)throw new Error("No Postman collection loaded. Call loadPostmanCollection() first.");const a=this.parsedCollection.endpoints.find(l=>l.name===e);if(!a)throw new Error(`Endpoint "${e}" not found in collection.`);const t={...this.parsedCollection.variables,...n},r=await M({endpoint:a,variables:t});if(!r.success)throw new Error(`API request failed: ${r.error}`);const i=H(r),o=$(i);return{data:i,schema:o}}async queryAPI(e){if(!this.qaEngine)throw new Error("Q&A engine not initialized. Provide qaConfig in constructor or call initializeQA().");const n=Date.now(),{data:a,schema:t}=await this.fetchDataFromAPI(e.dataSource.endpoint||"",e.variables),r={question:e.question,schema:t,data:a},i=await this.qaEngine.answerQuestion(r),o=Date.now()-n;return{answer:i.answer,apiResponse:a,endpoint:e.dataSource.endpoint,executionTime:o}}listEndpoints(){return this.parsedCollection?this.parsedCollection.endpoints.map(e=>({name:e.name,method:e.method,description:e.description})):[]}}function Z(c){const e=new J(c.config,c.qaConfig),n=s.ref(!1),a=s.ref(null),t=s.ref(null),r=c.data||s.ref([]),i=c.schema||s.ref(null),o=s.ref([]),l=s.ref([]),u=s.ref(null),f=c.maxQuestionHistory||50,p=c.useLocalFallback!==!1;async function m(d,h){n.value=!0,a.value=null;try{if(c.config.provider==="local"||p){console.log("đ§ Using local analysis (no API call)");const w=y(d,h);return t.value=w,w}const A={type:d,data:r.value,schema:i.value||void 0,options:h},b=await e.analyze(A);return t.value=b,b}catch(A){if(a.value=A instanceof Error?A:new Error("Analysis failed"),p)return console.log("â ī¸ API call failed, falling back to local analysis"),y(d,h);throw a.value}finally{n.value=!1}}function y(d,h){const A=i.value||$(r.value);switch(d){case"descriptive_stats":{const b=A.columns.map(w=>V(r.value,w.name,w.type));return{type:d,timestamp:new Date,descriptiveStats:b,summary:`Calculated statistics for ${b.length} columns`,insights:[],confidence:.9}}case"anomaly_detection":{const b=A.columns.filter(g=>g.type==="number").map(g=>g.name),w=F(r.value,b,h==null?void 0:h.sensitivity);return{type:d,timestamp:new Date,anomalies:w,summary:`Found ${w.length} anomalies`,insights:w.slice(0,3).map(g=>g.reasons[0]),confidence:.8}}case"clustering":case"segmentation":{const b=(h==null?void 0:h.features)||A.columns.filter(E=>E.type==="number").map(E=>E.name),w=(h==null?void 0:h.numClusters)||3,g=Array.from({length:w},(E,_)=>({id:_,label:`Cluster ${_+1}`,centroid:{},size:Math.floor(r.value.length/w),characteristics:[`Group ${_+1} characteristics`]}));return{type:d,timestamp:new Date,clusters:g,summary:`Created ${w} clusters based on ${b.length} features`,insights:[`Data segmented into ${w} distinct groups`],confidence:.75}}case"correlation":{const b=(h==null?void 0:h.features)||A.columns.filter(g=>g.type==="number").map(g=>g.name),w={};return b.forEach(g=>{w[g]={},b.forEach(E=>{w[g][E]=g===E?1:Math.random()*.8-.4})}),{type:d,timestamp:new Date,correlations:w,summary:`Calculated correlations for ${b.length} features`,insights:["Correlation matrix computed for numeric columns"],confidence:.85}}default:throw new Error(`Local analysis not supported for type: ${d}`)}}async function v(){return(await m("descriptive_stats")).descriptiveStats||[]}async function k(d,h){return(await m("anomaly_detection",{sensitivity:h,features:d})).anomalies||[]}async function I(d,h=3){return m("clustering",{features:d,numClusters:h})}async function P(d,h){return m("prediction",{targetColumn:d,...h})}function C(d){e.updateConfig(d)}function D(d,h=!0){r.value=d,h&&(i.value=$(d))}function q(){n.value=!1,a.value=null,t.value=null,o.value=[],l.value=[],u.value=null}async function N(d,h){n.value=!0,a.value=null;try{if(!r.value||!Array.isArray(r.value)||r.value.length===0)throw new Error("No data available. Please load data first.");const A=i.value||$(r.value),b={question:d,schema:A,data:r.value,sampleSize:100,includeAggregates:!0,...h},g=(await e.askQuestion(b)).answer,E={id:g.questionId,text:d,timestamp:new Date,context:{tableSchema:A,rowCount:r.value.length}};return o.value||(o.value=[]),l.value||(l.value=[]),o.value.push(E),l.value.push(g),u.value=g,o.value.length>f&&(o.value.shift(),l.value.shift()),g}catch(A){throw a.value=A instanceof Error?A:new Error("Q&A failed"),a.value}finally{n.value=!1}}async function x(){n.value=!0,a.value=null;try{const d=i.value||$(r.value);return await e.generateSummary(r.value,d)}catch(d){throw a.value=d instanceof Error?d:new Error("Summary generation failed"),a.value}finally{n.value=!1}}function L(){o.value=[],l.value=[],u.value=null}function U(d){const h=e.extractFromDOM(d);return h&&(r.value=h.data,i.value=h.schema),h}function K(d,h,A){const b=e.normalizeVueData(d,h,A);r.value=b.data,i.value=b.schema}function W(d){e.initializeQA(d)}return{client:e,loading:n,error:a,lastResult:t,data:r,schema:i,questionHistory:o,answerHistory:l,lastAnswer:u,analyze:m,getDescriptiveStats:v,detectAnomalies:k,performClustering:I,predict:P,askQuestion:N,generateSummary:x,clearHistory:L,extractFromDOM:U,loadFromVueGrid:K,updateConfig:C,initializeQA:W,setData:D,reset:q}}const ee={class:"ti-question-input"},te={class:"ti-input-wrapper"},ne=["placeholder","disabled","onKeydown"],ae=["disabled"],se={key:0},oe={key:1,class:"ti-loading"},re={key:0,class:"ti-hint"},ie=s.defineComponent({__name:"QuestionInput",props:{placeholder:{default:"Ask a question about this data..."},submitLabel:{default:"Ask"},loadingLabel:{default:"Processing..."},hint:{default:"Press Enter to submit, Shift+Enter for new line"},showHint:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}},emits:["submit"],setup(c,{emit:e}){const n=c,a=e,t=s.ref("");function r(){t.value.trim()&&!n.disabled&&!n.loading&&(a("submit",t.value.trim()),t.value="")}function i(o){}return(o,l)=>(s.openBlock(),s.createElementBlock("div",ee,[s.createElementVNode("div",te,[s.withDirectives(s.createElementVNode("textarea",{"onUpdate:modelValue":l[0]||(l[0]=u=>t.value=u),placeholder:o.placeholder,disabled:o.disabled,class:"ti-textarea",rows:"1",onKeydown:[s.withKeys(s.withModifiers(r,["exact","prevent"]),["enter"]),s.withKeys(s.withModifiers(i,["shift"]),["enter"])]},null,40,ne),[[s.vModelText,t.value]]),s.createElementVNode("button",{disabled:o.disabled||!t.value.trim(),class:"ti-submit-btn",onClick:r},[o.loading?(s.openBlock(),s.createElementBlock("span",oe,s.toDisplayString(o.loadingLabel),1)):(s.openBlock(),s.createElementBlock("span",se,s.toDisplayString(o.submitLabel),1))],8,ae)]),o.showHint?(s.openBlock(),s.createElementBlock("div",re,s.toDisplayString(o.hint),1)):s.createCommentVNode("",!0)]))}}),Q=(c,e)=>{const n=c.__vccOpts||c;for(const[a,t]of e)n[a]=t;return n},le=Q(ie,[["__scopeId","data-v-f96008f3"]]),ce={class:"ti-answer-header"},ue={class:"ti-answer-icon"},de={key:0},me={key:1},he={class:"ti-answer-meta"},pe={class:"ti-confidence"},fe={class:"ti-timestamp"},ye={class:"ti-answer-text"},ge={key:0,class:"ti-approximate-notice"},we={key:1,class:"ti-reason"},ve={key:2,class:"ti-supporting-data"},Ae={key:0,class:"ti-supporting-content"},be={key:0,class:"ti-aggregates"},ke={key:1,class:"ti-rows"},Ie={class:"ti-table-wrapper"},Ce={class:"ti-table"},Ee=s.defineComponent({__name:"AnswerDisplay",props:{answer:{}},setup(c){const e=s.ref(!1);function n(a){return new Date(a).toLocaleTimeString()}return(a,t)=>(s.openBlock(),s.createElementBlock("div",{class:s.normalizeClass(["ti-answer-display",{"ti-cannot-answer":a.answer.cannotAnswer}])},[s.createElementVNode("div",ce,[s.createElementVNode("div",ue,[a.answer.cannotAnswer?(s.openBlock(),s.createElementBlock("span",me,"â ī¸")):(s.openBlock(),s.createElementBlock("span",de,"đĄ"))]),s.createElementVNode("div",he,[s.createElementVNode("div",pe," Confidence: "+s.toDisplayString(Math.round(a.answer.confidence*100))+"% ",1),s.createElementVNode("div",fe,s.toDisplayString(n(a.answer.timestamp)),1)])]),s.createElementVNode("div",ye,s.toDisplayString(a.answer.text),1),a.answer.isApproximate?(s.openBlock(),s.createElementBlock("div",ge," âšī¸ This answer is based on sampled data and may be approximate. ")):s.createCommentVNode("",!0),a.answer.reason&&a.answer.cannotAnswer?(s.openBlock(),s.createElementBlock("div",we,[t[1]||(t[1]=s.createElementVNode("strong",null,"Reason:",-1)),s.createTextVNode(" "+s.toDisplayString(a.answer.reason),1)])):s.createCommentVNode("",!0),a.answer.supportingData?(s.openBlock(),s.createElementBlock("div",ve,[s.createElementVNode("button",{class:"ti-toggle-btn",onClick:t[0]||(t[0]=r=>e.value=!e.value)},s.toDisplayString(e.value?"âŧ":"âļ")+" Supporting Data ",1),e.value?(s.openBlock(),s.createElementBlock("div",Ae,[a.answer.supportingData.aggregates?(s.openBlock(),s.createElementBlock("div",be,[t[2]||(t[2]=s.createElementVNode("h4",null,"Aggregates:",-1)),s.createElementVNode("pre",null,s.toDisplayString(JSON.stringify(a.answer.supportingData.aggregates,null,2)),1)])):s.createCommentVNode("",!0),a.answer.supportingData.rows&&a.answer.supportingData.rows.length>0?(s.openBlock(),s.createElementBlock("div",ke,[s.createElementVNode("h4",null,"Sample Rows ("+s.toDisplayString(a.answer.supportingData.rows.length)+"):",1),s.createElementVNode("div",Ie,[s.createElementVNode("table",Ce,[s.createElementVNode("thead",null,[s.createElementVNode("tr",null,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(Object.keys(a.answer.supportingData.rows[0]),(r,i)=>(s.openBlock(),s.createElementBlock("th",{key:i},s.toDisplayString(r),1))),128))])]),s.createElementVNode("tbody",null,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(a.answer.supportingData.rows.slice(0,5),(r,i)=>(s.openBlock(),s.createElementBlock("tr",{key:i},[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(Object.keys(r),(o,l)=>(s.openBlock(),s.createElementBlock("td",{key:l},s.toDisplayString(r[o]),1))),128))]))),128))])])])])):s.createCommentVNode("",!0)])):s.createCommentVNode("",!0)])):s.createCommentVNode("",!0)],2))}}),Pe=Q(Ee,[["__scopeId","data-v-d1aaae1d"]]),Se={class:"ti-question-history"},$e={class:"ti-history-header"},qe={key:0,class:"ti-empty-state"},xe={key:1,class:"ti-history-list"},Ne=["onClick"],De={class:"ti-question-header"},_e={class:"ti-question-number"},Te={class:"ti-question-time"},Be={class:"ti-question-text"},Ve={key:0,class:"ti-question-context"},Me=s.defineComponent({__name:"QuestionHistory",props:{questions:{}},emits:["clear","select"],setup(c,{emit:e}){const n=c,a=s.computed(()=>[...n.questions].reverse());function t(r){const i=new Date(r),l=new Date().getTime()-i.getTime(),u=Math.floor(l/6e4),f=Math.floor(l/36e5),p=Math.floor(l/864e5);return u<1?"Just now":u<60?`${u}m ago`:f<24?`${f}h ago`:`${p}d ago`}return(r,i)=>(s.openBlock(),s.createElementBlock("div",Se,[s.createElementVNode("div",$e,[i[1]||(i[1]=s.createElementVNode("h3",null,"Question History",-1)),r.questions.length>0?(s.openBlock(),s.createElementBlock("button",{key:0,class:"ti-clear-btn",onClick:i[0]||(i[0]=o=>r.$emit("clear"))}," Clear History ")):s.createCommentVNode("",!0)]),r.questions.length===0?(s.openBlock(),s.createElementBlock("div",qe,i[2]||(i[2]=[s.createElementVNode("div",{class:"ti-empty-icon"},"đŦ",-1),s.createElementVNode("p",null,"No questions asked yet",-1),s.createElementVNode("p",{class:"ti-empty-hint"},"Ask a question about your data to get started",-1)]))):(s.openBlock(),s.createElementBlock("div",xe,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(a.value,(o,l)=>(s.openBlock(),s.createElementBlock("div",{key:o.id,class:"ti-history-item",onClick:u=>r.$emit("select",o)},[s.createElementVNode("div",De,[s.createElementVNode("span",_e,"#"+s.toDisplayString(r.questions.length-l),1),s.createElementVNode("span",Te,s.toDisplayString(t(o.timestamp)),1)]),s.createElementVNode("div",Be,s.toDisplayString(o.text),1),o.context?(s.openBlock(),s.createElementBlock("div",Ve,s.toDisplayString(o.context.rowCount)+" rows ",1)):s.createCommentVNode("",!0)],8,Ne))),128))]))]))}}),Qe=Q(Me,[["__scopeId","data-v-c66393d9"]]);exports.AnswerDisplay=Pe;exports.QAEngine=T;exports.QuestionHistory=Qe;exports.QuestionInput=le;exports.TabularIntelligence=J;exports.calculateStats=V;exports.convertToTabular=H;exports.detectAnomalies=F;exports.executeAPIRequest=M;exports.executeMultipleRequests=X;exports.extractFromDOM=O;exports.inferColumnType=B;exports.inferSchema=$;exports.normalizeVueData=z;exports.parsePostmanCollection=R;exports.replaceVariables=S;exports.useTabularIntelligence=Z;
|
|
31
68
|
//# sourceMappingURL=index.js.map
|