Skip to content

Commit

Permalink
chore(llm): adjust more precisely the fingerprint when it fails retur…
Browse files Browse the repository at this point in the history
…ning the right response format
  • Loading branch information
sneko committed Mar 15, 2024
1 parent fbb9b94 commit 85b2ade
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/features/initiative.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
WebsiteTemplateSchemaType,
resultSchemaDefinition,
} from '@etabli/src/gpt/template';
import { getServerTranslation } from '@etabli/src/i18n';
import { llmResponseFormatError, tokensReachTheLimitError } from '@etabli/src/models/entities/errors';
import { LiteInitiativeMapSchema, LiteInitiativeMapSchemaType } from '@etabli/src/models/entities/initiative';
import { prisma } from '@etabli/src/prisma';
Expand Down Expand Up @@ -646,6 +647,10 @@ export async function feedInitiativesFromDatabase() {

const initiativeGptTemplate = handlebars.compile(initiativeGptTemplateContent);

const { t } = getServerTranslation('common', {
lng: 'fr',
});

// Since the underlying wappalyzer analysis per initiative map can take some time due to being in a Chromium environment
// we parallelize hoping to save some time. But still, we take in considerations the LLM API rate limit
const iterationLlmManagerApiCalls = 2; // One for the embeddings of the tools, and the other for the computation of the initiative sheet
Expand Down Expand Up @@ -1051,9 +1056,7 @@ export async function feedInitiativesFromDatabase() {
}),
messageToAppend:
failedDueToLlmResponseFormat > 0
? `C'est la ${
failedDueToLlmResponseFormat === 1 ? 'deuxième' : `${failedDueToLlmResponseFormat + 1}ème`
} tentative car la dernière fois tu n'as pas respecté le format JSON attendu !`
? t('llm.template.initiative.responseFormatFailures', { count: failedDueToLlmResponseFormat })
: undefined,
})
);
Expand Down
6 changes: 6 additions & 0 deletions src/i18n/fr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@
"functionalUseCases": "casDUtilisationFonctionnels",
"tools": "outilsUtilises"
}
},
"template": {
"initiative": {
"responseFormatFailures_one": "Sache que c'est la deuxième tentative car la dernière fois tu n'as pas respecté le format de réponse attendu ! (on veut un JSON avec les propriétés citées, sans commentaire ni note autour)",
"responseFormatFailures_other": "On te renvoie la même demande car les {{count}} dernières fois tu n'as toujours pas respecté le format JSON attendu (sans commentaire ni note autour). Fais attention à bien formater ta réponse."
}
}
}
}

0 comments on commit 85b2ade

Please sign in to comment.