feat: centraliser le moteur IA via le Référentiel
All checks were successful
Deploy Production / deploy (push) Has been skipped
Deploy Recette / deploy (push) Successful in 1m32s
Validation applicative / TypeScript, tests et build (push) Successful in 2m42s

This commit is contained in:
manus-admin
2026-09-14 08:35:32 +00:00
parent 290e3709e2
commit 9db76af02c
7 changed files with 259 additions and 19 deletions

View File

@@ -1,4 +1,5 @@
import { ENV } from "./env";
import { invokeSelectedReference } from "./aiReferenceClient";
export type Role = "system" | "user" | "assistant" | "tool" | "function";
@@ -266,7 +267,6 @@ const normalizeResponseFormat = ({
};
export async function invokeLLM(params: InvokeParams): Promise<InvokeResult> {
assertApiKey();
const {
messages,
@@ -280,7 +280,6 @@ export async function invokeLLM(params: InvokeParams): Promise<InvokeResult> {
} = params;
const payload: Record<string, unknown> = {
model: "gemini-2.5-flash",
messages: messages.map(normalizeMessage),
};
@@ -312,21 +311,5 @@ export async function invokeLLM(params: InvokeParams): Promise<InvokeResult> {
payload.response_format = normalizedResponseFormat;
}
const response = await fetch(resolveApiUrl(), {
method: "POST",
headers: {
"content-type": "application/json",
authorization: `Bearer ${ENV.forgeApiKey}`,
},
body: JSON.stringify(payload),
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(
`LLM invoke failed: ${response.status} ${response.statusText} – ${errorText}`
);
}
return (await response.json()) as InvokeResult;
return invokeSelectedReference<InvokeResult>(payload);
}