feat: route invoice analysis through referentiel ia

This commit is contained in:
Manus
2026-09-30 16:18:00 +00:00
parent 584e9631e5
commit e9d25d9270
16 changed files with 2907 additions and 26 deletions

View File

@@ -9,4 +9,6 @@ export const ENV = {
forgeApiKey: process.env.BUILT_IN_FORGE_API_KEY ?? "",
mistralApiKey: process.env.MISTRAL_API_KEY ?? "",
geminiApiKey: process.env.GEMINI_API_KEY ?? "",
referentielIaUrl: process.env.REFERENTIEL_IA_URL ?? "",
referentielIaToken: process.env.REFERENTIEL_IA_TOKEN ?? "",
};

View File

@@ -1,4 +1,5 @@
import { ENV } from "./env";
import { invokeReferentialIa } from "../referentialIa";
export type Role = "system" | "user" | "assistant" | "tool" | "function";
@@ -97,8 +98,8 @@ export type InvokeResult = {
};
};
export type LlmProvider = "mistral" | "manus" | "gemini";
export type LlmTransport = "mistral-api" | "manus-forge" | "gemini-api";
export type LlmProvider = "mistral" | "manus" | "gemini" | "referentiel";
export type LlmTransport = "mistral-api" | "manus-forge" | "gemini-api" | "referentiel-gateway";
export type UserLlmSettings = {
aiProvider?: string | null;
@@ -344,6 +345,9 @@ export function resolveLlmTrace(settings?: UserLlmSettings): ResolvedLlmTrace {
if (provider === "gemini") {
return { provider: "gemini", model: "gemini-2.0-flash", transport: "gemini-api" };
}
if (provider === "referentiel") {
return { provider: "referentiel", model: "referentiel-ia", transport: "referentiel-gateway" };
}
return { provider: "mistral", model: "mistral-large-latest", transport: "mistral-api" };
}
@@ -355,14 +359,17 @@ export async function invokeLLMWithUserSettings(
params: InvokeParams,
userSettings?: UserLlmSettings
): Promise<ResolvedLlmInvocation> {
const trace = resolveLlmTrace(userSettings);
if (trace.provider === "referentiel") {
return { response: await invokeReferentialIa(params), trace };
}
const apiKey = getApiKeyWithSettings(userSettings);
if (!apiKey || apiKey.trim().length === 0) {
throw new Error("Aucune clé API configurée pour le moteur IA sélectionné");
}
const trace = resolveLlmTrace(userSettings);
const provider = trace.provider;
const {
messages,
tools,