From d0e1430ada7637f41936637deab3137d5302ee47 Mon Sep 17 00:00:00 2001 From: DavePk04 <Dave.Pikop.Pokam@ulb.be> Date: Sat, 15 Mar 2025 17:41:52 +0100 Subject: [PATCH] session.ts: add createAIMessageAPI function --- frontend/src/lib/api/sessions.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/frontend/src/lib/api/sessions.ts b/frontend/src/lib/api/sessions.ts index 5e056ac8..d4a6e2ef 100644 --- a/frontend/src/lib/api/sessions.ts +++ b/frontend/src/lib/api/sessions.ts @@ -53,6 +53,26 @@ export async function createMessageAPI( return await response.json(); } +export async function createAIMessageAPI( + fetch: fetchType, + sessionId: string, + content: string +): Promise<any | null> { + const response = await fetch(`/tmp-api/v1/chat/`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + session_id: sessionId, + role: "user", + content: content + }) + }); + + if (!response.ok) return null; + + return await response.json(); +} + export async function updateMessageAPI( fetch: fetchType, id: number, -- GitLab