fixing login sosmed dan ganti logo/icon app

This commit is contained in:
dios.one
2026-05-11 11:56:57 +07:00
parent 87b65d3822
commit 53a75adfdd
21 changed files with 1230 additions and 3067 deletions
+33 -14
View File
@@ -1,5 +1,5 @@
import safeParseAI from '../utils/safeParseAI';
import { getSuggestionsForIdentity } from '../utils/helpers';
import { getSuggestionsForIdentity, isIndonesian, setStoryLanguage } from '../utils/helpers';
import { AI_SERVICE_URL, AI_MODEL } from '../config/keys';
function buildPrompt(story) {
@@ -108,7 +108,7 @@ async function callAI(prompt) {
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
model: AI_MODEL,
max_tokens: 2048,
max_tokens: 4096,
messages: [{ role: 'user', content: prompt }],
}),
});
@@ -128,6 +128,9 @@ async function callAI(prompt) {
* Falls back to local generation if AI fails.
*/
export async function generateFromStory(story) {
// Set language detection from the full story BEFORE anything else
setStoryLanguage(story);
try {
const rawText = await callAI(buildPrompt(story));
const parsed = safeParseAI(rawText);
@@ -186,30 +189,46 @@ function generateFallback(story) {
}
}
// Generate varied habits from the story text and convert to rich objects
let habitTitles = getSuggestionsForIdentity(words);
if (habitTitles.length < 8) {
const titleHabits = getSuggestionsForIdentity(title);
titleHabits.forEach((h) => { if (!habitTitles.includes(h)) habitTitles.push(h); });
// Generate bilingual habits — pass story as both search text AND language text
const { generateHabitsFromIdentity } = require('../utils/helpers');
let allHabits = generateHabitsFromIdentity(story, story);
// If not enough from story keywords, also try title keywords
if (allHabits.length < 20) {
const titleHabits = generateHabitsFromIdentity(title, story);
titleHabits.forEach((h) => {
if (!allHabits.some((a) => a.title === h.title)) allHabits.push(h);
});
}
// Ensure at least 20
allHabits = allHabits.slice(0, 20);
const useId = isIndonesian(story);
const times = ['06:00', '06:30', '07:00', '07:30', '08:00', '12:00', '17:00', '18:00', '19:00', '20:00', '21:00', '21:30'];
const durations = [5, 10, 15, 20, 30, 10, 15, 20, 5, 10];
const toRichHabit = (t, i) => ({
title: t,
const toRichHabit = (h, i) => ({
title: h.title || h,
best_time: times[i % times.length],
duration: durations[i % durations.length],
frequency: i < 5 ? 'Every day' : ['Every day', '3x per week', 'Every morning', 'Every evening', 'Weekdays only'][i % 5],
frequency: i < 5
? (useId ? 'Setiap hari' : 'Every day')
: [useId ? 'Setiap hari' : 'Every day', '3x per week', useId ? 'Setiap pagi' : 'Every morning', useId ? 'Setiap malam' : 'Every evening', useId ? 'Hari kerja' : 'Weekdays only'][i % 5],
category: ['Discipline', 'Body', 'Mind', 'Emotion', 'Health', 'Skill', 'Social', 'Creative'][i % 8],
difficulty: i < 3 ? 'Easy' : i < 7 ? 'Medium' : 'Hard',
why: '',
why: h.description || '',
});
const summary = useId
? `Berdasarkan ceritamu, perjalanan ini tentang menjadi ${title.toLowerCase()}. Setiap hari adalah langkah lebih dekat menuju dirimu yang baru.`
: `Based on your story, this journey is about becoming ${title.toLowerCase()}. Every day is a step closer to the person you described.`;
return {
identity_title: title,
identity_summary: `Based on your story, this journey is about becoming ${title.toLowerCase()}. Every day is a step closer to the person you described.`,
priority_habits: habitTitles.slice(0, 5).map(toRichHabit),
suggested_habits: habitTitles.slice(5, 20).map((t, i) => toRichHabit(t, i + 5)),
identity_summary: summary,
priority_habits: allHabits.slice(0, 5).map((h, i) => toRichHabit(h, i)),
suggested_habits: allHabits.slice(5, 20).map((h, i) => toRichHabit(h, i + 5)),
source: 'fallback',
};
}