fix: tracer le moteur IA réellement invoqué
All checks were successful
Validation applicative / TypeScript, tests et build (push) Successful in 1m52s
All checks were successful
Validation applicative / TypeScript, tests et build (push) Successful in 1m52s
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { invokeLLMWithUserSettings } from "./_core/llm";
|
||||
import { invokeLLMWithUserSettings, type UserLlmSettings } from "./_core/llm";
|
||||
import { PDFDocument } from "pdf-lib";
|
||||
import { createLlmLog } from "./db";
|
||||
import PDFParser from "pdf2json";
|
||||
@@ -144,7 +144,7 @@ export async function extractInvoicesWithMistral(
|
||||
subscription?: string | null;
|
||||
recipient?: string | null;
|
||||
},
|
||||
aiSettings?: { aiProvider?: string | null; mistralApiKey?: string | null; manusForgeApiKey?: string | null; manusForgeApiUrl?: string | null }
|
||||
aiSettings?: UserLlmSettings
|
||||
): Promise<MultiInvoiceResult> {
|
||||
// Load user's field configuration
|
||||
const { getLlmFieldsConfigByUser } = await import("./db");
|
||||
@@ -241,7 +241,7 @@ Si une information n'est pas trouvée, utilise null. Ne retourne AUCUN texte en
|
||||
|
||||
// Call Mistral LLM with extracted text
|
||||
const fullPrompt = `${prompt}\n\nTexte extrait du PDF:\n${pdfText}`;
|
||||
const response = await invokeLLMWithUserSettings(
|
||||
const invocation = await invokeLLMWithUserSettings(
|
||||
{
|
||||
messages: [
|
||||
{
|
||||
@@ -252,6 +252,7 @@ Si une information n'est pas trouvée, utilise null. Ne retourne AUCUN texte en
|
||||
},
|
||||
aiSettings
|
||||
);
|
||||
const { response, trace } = invocation;
|
||||
|
||||
const rawResponse = typeof response.choices[0]?.message?.content === "string"
|
||||
? response.choices[0].message.content
|
||||
@@ -276,6 +277,9 @@ Si une information n'est pas trouvée, utilise null. Ne retourne AUCUN texte en
|
||||
sourceFileId,
|
||||
operation: "extraction",
|
||||
model,
|
||||
resolvedProvider: trace.provider,
|
||||
resolvedModel: trace.model,
|
||||
transport: trace.transport,
|
||||
promptSent: prompt,
|
||||
rawResponse: rawResponse.substring(0, 10000),
|
||||
cleanedResponse: cleanedResponse.substring(0, 10000),
|
||||
@@ -293,6 +297,9 @@ Si une information n'est pas trouvée, utilise null. Ne retourne AUCUN texte en
|
||||
sourceFileId,
|
||||
operation: "extraction",
|
||||
model,
|
||||
resolvedProvider: trace.provider,
|
||||
resolvedModel: trace.model,
|
||||
transport: trace.transport,
|
||||
promptSent: prompt.substring(0, 10000),
|
||||
rawResponse: rawResponse.substring(0, 10000),
|
||||
cleanedResponse: cleanedResponse.substring(0, 10000),
|
||||
|
||||
Reference in New Issue
Block a user