changes
This commit is contained in:
@@ -397,7 +397,6 @@ export async function findSimilar(userId, query) {
|
|||||||
return retrieveRelevantMemories(db, userId, query);
|
return retrieveRelevantMemories(db, userId, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Daily thought storage
|
|
||||||
export async function getDailyThoughtFromDb(date) {
|
export async function getDailyThoughtFromDb(date) {
|
||||||
const db = await loadDatabase();
|
const db = await loadDatabase();
|
||||||
const row = get(db, 'SELECT thought FROM daily_thoughts WHERE date = ?', [date]);
|
const row = get(db, 'SELECT thought FROM daily_thoughts WHERE date = ?', [date]);
|
||||||
|
|||||||
10
src/mood.js
10
src/mood.js
@@ -12,9 +12,6 @@ const dailyMoods = [
|
|||||||
let overrideMood = null;
|
let overrideMood = null;
|
||||||
let currentDailyMood = null;
|
let currentDailyMood = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* Get today's date as YYYY-MM-DD for comparison
|
|
||||||
*/
|
|
||||||
function getTodayDate() {
|
function getTodayDate() {
|
||||||
const d = new Date();
|
const d = new Date();
|
||||||
return d.toISOString().split('T')[0];
|
return d.toISOString().split('T')[0];
|
||||||
@@ -50,7 +47,6 @@ async function setDailyThought(thought) {
|
|||||||
async function generateDailyThought() {
|
async function generateDailyThought() {
|
||||||
const today = getTodayDate();
|
const today = getTodayDate();
|
||||||
|
|
||||||
// Check if we already have a thought for today in the DB
|
|
||||||
const existingThought = await getDailyThoughtFromDb(today);
|
const existingThought = await getDailyThoughtFromDb(today);
|
||||||
if (existingThought) {
|
if (existingThought) {
|
||||||
console.log('[mood] using existing thought for today:', existingThought);
|
console.log('[mood] using existing thought for today:', existingThought);
|
||||||
@@ -67,8 +63,7 @@ async function generateDailyThought() {
|
|||||||
];
|
];
|
||||||
const resp = await chatCompletion(messages, { temperature: 0.8, maxTokens: 40 });
|
const resp = await chatCompletion(messages, { temperature: 0.8, maxTokens: 40 });
|
||||||
newThought = (resp && resp.trim()) || '';
|
newThought = (resp && resp.trim()) || '';
|
||||||
|
|
||||||
// Truncate to 120 characters if it exceeds
|
|
||||||
if (newThought.length > 120) {
|
if (newThought.length > 120) {
|
||||||
newThought = newThought.substring(0, 117) + '...';
|
newThought = newThought.substring(0, 117) + '...';
|
||||||
}
|
}
|
||||||
@@ -85,8 +80,7 @@ async function generateDailyThought() {
|
|||||||
];
|
];
|
||||||
newThought = fallbacks[Math.floor(Math.random() * fallbacks.length)];
|
newThought = fallbacks[Math.floor(Math.random() * fallbacks.length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save to database
|
|
||||||
await saveDailyThought(today, newThought);
|
await saveDailyThought(today, newThought);
|
||||||
console.log('[mood] generated and saved new thought for today:', newThought);
|
console.log('[mood] generated and saved new thought for today:', newThought);
|
||||||
return newThought;
|
return newThought;
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ async function postJson(path, body) {
|
|||||||
const e = new Error(`Request timed out after ${timeout}ms`);
|
const e = new Error(`Request timed out after ${timeout}ms`);
|
||||||
e.code = 'UND_ERR_CONNECT_TIMEOUT';
|
e.code = 'UND_ERR_CONNECT_TIMEOUT';
|
||||||
controller.abort();
|
controller.abort();
|
||||||
// store on global so the catch sees it
|
|
||||||
throw e;
|
throw e;
|
||||||
}, timeout);
|
}, timeout);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user