-
- {data.storyIds.length} top stories loaded
-
-
- (Story details will load when API is configured)
-
-
- );
- }
// Default fallback for unknown data types
return (
diff --git a/claudash/src/services/claudeService.js b/claudash/src/services/claudeService.js
index 07b3e69..a0e9e47 100644
--- a/claudash/src/services/claudeService.js
+++ b/claudash/src/services/claudeService.js
@@ -3,6 +3,7 @@ import {
DEFAULT_CLAUDE_MODEL,
MAX_TOKENS
} from '../utils/constants';
+import { condenseSourcesForClaude } from './sourceParser';
/**
* Make a request to Claude API
@@ -77,7 +78,7 @@ async function callClaude(prompt, messages = []) {
/**
* Build briefing prompt with memory
* @param {Object} currentData - Current source data
- * @param {Object} previousBriefing - Previous briefing object
+ * @param {Object} previousBriefing - Previous briefing object (condensed summary)
* @returns {string} The prompt
*/
function buildBriefingPrompt(currentData, previousBriefing) {
@@ -94,17 +95,23 @@ function buildBriefingPrompt(currentData, previousBriefing) {
CURRENT DATA:
`;
-
- // Add all current source data
- Object.entries(currentData.sources || currentData).forEach(([source, data]) => {
+
+ // CONDENSE DATA BEFORE SENDING TO CLAUDE
+ const condensedData = condenseSourcesForClaude(currentData.sources || currentData);
+ console.log('Original data size:', JSON.stringify(currentData).length);
+ console.log('Condensed data size:', JSON.stringify(condensedData).length);
+ console.log('Size reduction:', Math.round((1 - JSON.stringify(condensedData).length / JSON.stringify(currentData).length) * 100) + '%');
+
+ // Add all condensed source data
+ Object.entries(condensedData).forEach(([source, data]) => {
if (data && !data.error) {
prompt += `\n${source.toUpperCase()}:\n${JSON.stringify(data, null, 2)}\n`;
}
});
- // Add historical context if available
- if (previousBriefing && previousBriefing.briefing) {
- prompt += `\n\nYESTERDAY'S BRIEFING:\n${previousBriefing.briefing}\n`;
+ // Add historical context if available (now using condensed summary)
+ if (previousBriefing && previousBriefing.condensedSummary) {
+ prompt += `\n\nPREVIOUS BRIEFING SUMMARY:\n${previousBriefing.condensedSummary}\n`;
prompt += `\nHighlight what's changed, any follow-up stories, or interesting trends.`;
}
@@ -122,29 +129,69 @@ Focus on the most newsworthy and interesting items. Don't try to mention everyth
}
/**
- * Generate daily briefing
+ * Generate a condensed summary of a briefing for historical storage
+ * @param {string} fullBriefing - The full briefing text
+ * @returns {Promise