cancel
Showing results for 
Search instead for 
Did you mean: 

Flowiseai + Sisense = RAG from a widget data values

saxoji
7 - Data Storage
7 - Data Storage

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.

스크린샷 2024-06-04 오후 4.29.32.png 

스크린샷 2024-06-04 오후 4.31.04.png

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

스크린샷 2024-06-04 오후 4.38.19.png

 

basic prompt style : dashboards/61bfddcd53ccb90035ce1626/widgets/61bfddcd53ccb90035ce1631 Analyze widget data value

gpt-4o response : 

스크린샷 2024-06-04 오후 4.37.02.png

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:

  1. Mall Region - Represents the regions or countries where the malls are located.
  2. Product Selling Codes - Represents the number of product selling codes in each region.

Top 10 Regions by Product Selling Codes:

  1. Indonesia: 15,317 product selling codes
  2. Viet Nam: 7,241 product selling codes
  3. Philippines: 6,494 product selling codes
  4. Malaysia: 4,369 product selling codes
  5. Singapore: 3,151 product selling codes
  6. South Korea: 2,447 product selling codes
  7. Thailand: 1,683 product selling codes
  8. Russia: 1,647 product selling codes
  9. Japan: 1,608 product selling codes
  10. 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  

  

1 REPLY 1

DRay
Community Team Member
Community Team Member

Hello @saxoji,

This is a great post! It looks like you are planning on a series. I would like to meet with you to discuss how to publish this content to get it in front of the most people. Please message me directly if you would like to meet and talk.

Thank you.

David Raynor (DRay)

saxoji
7 - Data Storage
7 - Data Storage

Hello, This is Benedict at Linkbricks (Sisense Korea Implementation Partner).
Thanks for your comments.

I'll get back to you when I'm done with one busy project.