log recommendations

This commit is contained in:
Danel Kungla
2025-09-23 10:50:20 +03:00
parent fee8534fcc
commit 3dd82902fe
3 changed files with 21 additions and 5 deletions

View File

@@ -7,6 +7,7 @@ import { createUserAnalysesApi } from '@/packages/features/user-analyses/src/ser
import { getSupabaseServerClient } from '@/packages/supabase/src/clients/server-client';
import { PageBody, PageHeader } from '@kit/ui/page';
import { Skeleton } from '@kit/ui/skeleton';
import { Trans } from '@kit/ui/trans';
import { createI18nServerInstance } from '~/lib/i18n/i18n.server';
@@ -16,7 +17,6 @@ import Dashboard from '../_components/dashboard';
import DashboardCards from '../_components/dashboard-cards';
import Recommendations from '../_components/recommendations';
import { loadCurrentUserAccount } from '../_lib/server/load-user-account';
import Loading from '../loading';
export const generateMetadata = async () => {
const i18n = await createI18nServerInstance();
@@ -52,7 +52,7 @@ async function UserHomePage() {
/>
<PageBody>
<Dashboard account={account} bmiThresholds={bmiThresholds} />
<Suspense fallback={null}>
<Suspense fallback={<Skeleton className="h-10 w-100" />}>
<Recommendations account={account} />
</Suspense>
</PageBody>

View File

@@ -125,11 +125,10 @@ async function recommendationsLoader(
weight: weight.toString(),
},
},
max_output_tokens: 100,
});
const json = JSON.parse(response.output_text);
await supabaseClient
const updateAiResponse = await supabaseClient
.schema('medreport')
.from('ai_responses')
.insert({
@@ -144,7 +143,7 @@ async function recommendationsLoader(
weight,
}),
latest_data_change: latestISO,
response: JSON.stringify(response.output_text),
response: response.output_text,
});
return json.recommended;

View File

@@ -0,0 +1,17 @@
ALTER TABLE medreport.ai_responses ENABLE ROW LEVEL SECURITY;
CREATE POLICY "ai_responses_select" ON medreport.ai_responses FOR SELECT TO authenticated USING (true);
CREATE POLICY "ai_responses_insert" ON medreport.ai_responses FOR INSERT TO authenticated WITH CHECK (true);
grant select, insert, update, delete on table medreport.ai_responses to authenticated;
ALTER TABLE medreport.ai_responses
ALTER COLUMN prompt_id TYPE text
USING prompt_name::text;
ALTER TABLE medreport.ai_responses
ALTER COLUMN prompt_name TYPE text
USING prompt_name::text;
ALTER TABLE medreport.ai_responses
ADD CONSTRAINT ai_responses_id_pkey PRIMARY KEY (id);