fix: transmettre le moteur Référentiel IA
This commit is contained in:
@@ -48,9 +48,10 @@ describe("Référentiel IA", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("transmet une requête OpenAI-compatible à la passerelle sélectionnée", async () => {
|
||||
it("transmet le slug du moteur décidé avant la requête OpenAI-compatible", async () => {
|
||||
let receivedUrl = "";
|
||||
let receivedInit: RequestInit | undefined;
|
||||
let callCount = 0;
|
||||
const result = await invokeReferentialIa(
|
||||
{
|
||||
messages: [{ role: "user", content: "Extrais la facture" }],
|
||||
@@ -58,8 +59,22 @@ describe("Référentiel IA", () => {
|
||||
},
|
||||
connection,
|
||||
async (url, init) => {
|
||||
callCount += 1;
|
||||
receivedUrl = String(url);
|
||||
receivedInit = init;
|
||||
if (callCount === 1) {
|
||||
expect(receivedUrl).toBe("https://referentiel-ia.recette.santinova-soft.org/api/integration/v1/recommendations");
|
||||
expect(JSON.parse(String(receivedInit?.body))).toEqual({
|
||||
useCase: "texte",
|
||||
optimizeCost: true,
|
||||
needsFreeTier: false,
|
||||
includeConnection: false,
|
||||
});
|
||||
return jsonResponse({
|
||||
application: { name: "Démat. Facturation DSI" },
|
||||
decision: { selected: { engine: { name: "SANTINO Expert", slug: "santino-expert" } } },
|
||||
});
|
||||
}
|
||||
return jsonResponse({
|
||||
id: "ref-1",
|
||||
created: 1,
|
||||
@@ -72,12 +87,15 @@ describe("Référentiel IA", () => {
|
||||
expect(receivedUrl).toBe("https://referentiel-ia.recette.santinova-soft.org/api/integration/v1/invoke");
|
||||
expect(receivedInit?.headers).toMatchObject({ authorization: "Bearer test-token" });
|
||||
expect(JSON.parse(String(receivedInit?.body))).toMatchObject({
|
||||
engineSlug: "santino-expert",
|
||||
useCase: "texte",
|
||||
payload: {
|
||||
messages: [{ role: "user", content: "Extrais la facture" }],
|
||||
max_tokens: 1200,
|
||||
stream: false,
|
||||
},
|
||||
});
|
||||
expect(callCount).toBe(2);
|
||||
expect(result.choices[0]?.message.content).toBe("{}");
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user