From 33fa0b4a89202b816abc59bfe2b3d463fb3289de Mon Sep 17 00:00:00 2001 From: nicoagostini Date: Sat, 7 Jun 2025 11:04:15 -0700 Subject: [PATCH] Suggestions updated --- .DS_Store | Bin 0 -> 6148 bytes src/router/user.js | 4 +++- src/util/suggestions.js | 8 ++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a5eaaa480b24a62c1c8c2546e7d60f2c6ed4e9bb GIT binary patch literal 6148 zcmeHKTWb?R82u)R&8CeSL7^|gf=@z>X)VR#OUwlcc!6%!2bH+VhPZaK6S7Gogg~D4 zKlm4X^_Tcxe9|+Qh23rXTCB_$X3kvB`F7^yG8rOb&AGQnR3Rb@MPOkY)rJuBqMVDI z9=QQzB1bpigMPsK=!=9Vj047jf7=1^-7Qd!h7{6S=KI^i-2Fc?CVIbF*(5%@$TM!K+4}Daz#ko#Ec37QLdE zbVA3}r6#>btBd|KsK?}`)wxkdU8Lt=x2OY!L!C66o`U^7vFEZ}zXxA?$j!;4xo|4G zMiO2nb+@n=mj-l-dIbIhsJQIQ9iknkpDbNWW+-PeT%;3DCUqsa(!oC3^a8lS5hnah zD)JQJ9U7$9BYoSz>Mx>+J{x}aCxIW$>h)hNmoHq~Dq2Nr$NJ!W;tOZy&gN0moxT&j z6V8Kv+;;nK{NbWkx!vO7%=N?JR0@1=2+I4ne(3Q!0Kwfn# z;{5MieE(02OwTxA9QdysV1>5RZemONY(2L*an{->A5laI-ddrQpwh>&Y>1d62A literal 0 HcmV?d00001 diff --git a/src/router/user.js b/src/router/user.js index c164a2d..8218dbc 100644 --- a/src/router/user.js +++ b/src/router/user.js @@ -172,6 +172,8 @@ module.exports = (middleware, users, plans, assets) => { const progress = await calculateProgress(plan, assets, users, req.session.userId); + const suggestions = await generateSuggestions(totalUserAssetValue, plan); + res.render('planDetail', { user: req.session.user, plan: plan, @@ -179,7 +181,7 @@ module.exports = (middleware, users, plans, assets) => { totalUserAssetValue: totalUserAssetValue, assets: userAssets, progress: progress, - suggestions: await suggestions.generateSuggestions(), + suggestions: suggestions, }); } catch (err) { diff --git a/src/util/suggestions.js b/src/util/suggestions.js index 9135a9f..d16e924 100644 --- a/src/util/suggestions.js +++ b/src/util/suggestions.js @@ -10,10 +10,14 @@ async function generateFact(factInput) { return response.text; } -async function generateSuggestions() { +async function generateSuggestions(totalUserAssetValue, plan) { const response = await ai.models.generateContent({ model: "gemini-2.0-flash", - contents: "Return a mock investment suggestion 3-5 lines only, please do not include any extra text or explanation.", + contents: `Return an investment suggestion 3-5 based on the user's total asset value and their plan. Please do not include any extra text or explanation. + + Total User Asset Value: ${totalUserAssetValue} + + Plan: ${plan}`, }); return response.text; }