Flowiseai + Sisense = RAG from a widget data values
flowiseai : https://flowiseai.com/
flowiseai git : https://github.com/FlowiseAI/Flowise
Leveraging flowiseai's LLM workflow, I created a custom tool and node.js-based fetch api code to enable augmented analysis and easy querying of data values for Sisense specific widgets with OpenAi GPT4o (You can use any llm including llama3, Anthropic, Huggingface,.... with same workflow). It took about 5 minutes to integrate and implement.
code sample start :
const fetch = require('node-fetch');
const apikey = 'your-api-key';
const baseUrl = 'https://your-sisense-url';
const dashboardId = $dashboard_id;
const widgetId = $widget_id;
const getWidgetMetadata = async () => {
const url = `${baseUrl}/api/v1/dashboards/${dashboardId}/widgets/${widgetId}`;
const options = {
method: 'GET',
headers: {
'Authorization': `Bearer ${apikey}`,
'Content-Type': 'application/json'
}
};
try {
const response = await fetch(url, options);
if (!response.ok) {
throw new Error(`Error fetching widget metadata: ${response.statusText}`);
}
const metadata = await response.json();
console.log('Widget Metadata:', JSON.stringify(metadata, null, 2));
return metadata;
} catch (error) {
return `Error in getWidgetMetadata: ${error.message}`;
}
};
const getJaql = (widgetStructure) => {
const result = [];
for (const panel of widgetStructure.metadata.panels) {
for (const item of panel.items) {
if (item && item.jaql) {
result.push(item.jaql);
}
}
}
const payload = {
datasource: widgetStructure.datasource,
metadata: result
};
console.log('Generated JAQL Payload:', JSON.stringify(payload, null, 2));
return JSON.stringify(payload);
};
const getWidgetChartData = async (jaqlQuery) => {
try {
const parsedJaqlQuery = JSON.parse(jaqlQuery);
if (!parsedJaqlQuery.datasource || !parsedJaqlQuery.datasource.title) {
throw new Error('Datasource title is missing in JAQL query');
}
const jaqlUrl = `${baseUrl}/api/datasources/${parsedJaqlQuery.datasource.title}/jaql`;
console.log(`JAQL URL: ${jaqlUrl}`);
console.log(`JAQL Query: ${JSON.stringify(parsedJaqlQuery, null, 2)}`);
const jaqlOptions = {
method: 'POST',
headers: {
'Authorization': `Bearer ${apikey}`,
'Content-Type': 'application/json'
},
body: jaqlQuery
};
const response = await fetch(jaqlUrl, jaqlOptions);
if (!response.ok) {
throw new Error(`Error fetching widget chart data: ${response.statusText}`);
}
const chartData = await response.json();
console.log('Widget Chart Data:', JSON.stringify(chartData, null, 2));
return chartData;
} catch (error) {
return `Error in getWidgetChartData: ${error.message}`;
}
};
const fetchWidgetData = async () => {
try {
const widgetDefinition = await getWidgetMetadata();
if (typeof widgetDefinition === 'string' && widgetDefinition.startsWith('Error')) {
return widgetDefinition;
}
: code sample end
dashboards/61bfddcd53ccb90035ce1626/widgets/61bfddcd53ccb90035ce1631 is
basic prompt style : dashboards/61bfddcd53ccb90035ce1626/widgets/61bfddcd53ccb90035ce1631 Analyze widget data value
gpt-4o response :
GPT 4o generated text through RAG from sisense rest api:
The analysis of the widget data values from the dashboard 61bfddcd53ccb90035ce1626
and widget 61bfddcd53ccb90035ce1631
is as follows:
Headers:
- Mall Region - Represents the regions or countries where the malls are located.
- Product Selling Codes - Represents the number of product selling codes in each region.
Top 10 Regions by Product Selling Codes:
- Indonesia: 15,317 product selling codes
- Viet Nam: 7,241 product selling codes
- Philippines: 6,494 product selling codes
- Malaysia: 4,369 product selling codes
- Singapore: 3,151 product selling codes
- South Korea: 2,447 product selling codes
- Thailand: 1,683 product selling codes
- Russia: 1,647 product selling codes
- Japan: 1,608 product selling codes
- United States: 1,048 product selling codes
Insights:
- Indonesia leads with the highest number of product selling codes at 15,317.
- Viet Nam and Philippines follow with 7,241 and 6,494 product selling codes, respectively.
- Malaysia and Singapore also have a significant number of product selling codes, with 4,369 and 3,151, respectively.
- South Korea, Thailand, Russia, Japan, and United States round out the top 10 with over 1,000 product selling codes each.
Summary:
The data indicates a high concentration of product selling codes in Southeast Asia, especially in Indonesia, Viet Nam, and the Philippines, suggesting robust market activity in those regions. The presence of significant numbers in countries like Japan, Russia, and the United States also highlights strong market participation there.
Data Table:
Mall Region | Product Selling Codes |
---|---|
Croatia | 5 |
Myanmar | 10 |
Azerbaijan | 15 |
Hungary | 15 |
Italy | 20 |
Romania | 21 |
Nepal | 21 |
Chile | 22 |
Slovakia | 23 |
Pakistan | 24 |
Estonia | 25 |
Mauritius | 26 |
Lebanon | 37 |
Nigeria | 38 |
Lithuania | 41 |
Bangladesh | 42 |
Kenya | 42 |
France | 49 |
Spain | 50 |
United Arab Emirates | 54 |
South Africa | 57 |
Switzerland | 68 |
Mexico | 80 |
Denmark | 86 |
Finland | 107 |
Canada | 117 |
Saudi Arabia | 132 |
Hong Kong China | 148 |
China | 180 |
Sweden | 190 |
Germany | 199 |
Norway | 224 |
Australia | 242 |
Ukraine | 269 |
Poland | 296 |
United Kingdom | 298 |
Turkey | 307 |
India | 542 |
Taiwan China | 583 |
United States | 1048 |
Japan | 1608 |
Russia | 1647 |
Thailand | 1683 |
South Korea | 2447 |
Singapore | 3151 |
Malaysia | 4369 |
Philippines | 6494 |
Viet Nam | 7241 |
Indonesia | 15317 |
This data can help identify key regions for potential business expansion and investment opportunities in different markets.
*next work will be RAG with Sisense Dashboard including multi widegts