Skip to content

Commit d523244

Browse files
Merge pull request #24 from ThomasJButler/v1.6
Update Dashboard Visualisations
2 parents 0ed76d4 + c14efa8 commit d523244

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/components/EnhancedVisualizations.svelte

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,15 @@
186186
};
187187
188188
try {
189+
// Get API key from localStorage
190+
const apiKey = localStorage.getItem('openai_api_key');
191+
192+
if (!apiKey) {
193+
queryModalData.error = 'Please add your OpenAI API key in Settings to use the query feature.';
194+
queryModalData.isLoading = false;
195+
return;
196+
}
197+
189198
// Chart-specific prompts for SQL generation - use explicit SQL templates for guaranteed compatibility
190199
const leagueFilter = selectedDateRange === 'all' ? '' : ` AND div = '${selectedDateRange}'`;
191200
@@ -203,10 +212,11 @@
203212
204213
const prompt = prompts[chartType] || `Generate this exact SQL query: SELECT * FROM matches WHERE season = '${selectedSeason}' LIMIT 100`;
205214
206-
// Generate SQL using the RAG API
215+
// Generate SQL using the RAG API with API key
207216
const queryResponse = await apiService.convertToSQL({
208217
question: prompt,
209-
season: selectedSeason
218+
season: selectedSeason,
219+
api_key: apiKey
210220
});
211221
212222
queryModalData.sql = queryResponse.sql;

0 commit comments

Comments
 (0)