feat: add langueSource to parole
Déploiement API PROD / build (push) Successful in 2m6s
Déploiement API PROD / deploy (push) Successful in 49s

This commit is contained in:
2026-06-12 14:10:05 +04:00
parent a000af5c8b
commit 615d3fafa0
3 changed files with 37 additions and 7 deletions
@@ -125,6 +125,23 @@
"allowedTypes": [
"files"
]
},
"langueSource": {
"type": "enumeration",
"enum": ["ka", "fr", "en", "es", "de", "it"],
"default": "ka"
},
"sourceOriginale": {
"type": "relation",
"relation": "manyToOne",
"target": "api::parole.parole",
"inversedBy": "remixes"
},
"remixes": {
"type": "relation",
"relation": "oneToMany",
"target": "api::parole.parole",
"mappedBy": "sourceOriginale"
}
}
}
+11 -7
View File
@@ -117,7 +117,7 @@ module.exports = createCoreService('api::parole.parole', ({strapi}) => ({
const batch = await strapi.documents('api::parole.parole').findMany({
status: 'published',
populate: ['artistes', 'traductions'],
fields: ['documentId', 'titre', 'slug', 'transcription', 'annee'],
fields: ['documentId', 'titre', 'slug', 'transcription', 'annee', 'langueSource'],
limit: pageSize,
start,
})
@@ -138,10 +138,13 @@ module.exports = createCoreService('api::parole.parole', ({strapi}) => ({
for (const parole of paroles) {
const source = stripMarkdown(parole.transcription)
const sourceLang = parole.langueSource || 'ka'
const artists = (parole.artistes || []).map(a => a.alias)
const paroleMeta = { title: parole.titre, artists }
if (suspectFrench(source)) {
if (sourceLang !== 'ka') {
nonKa.push({ documentId: parole.documentId, slug: parole.slug, ...paroleMeta, suspected_lang: sourceLang })
} else if (suspectFrench(source)) {
nonKa.push({ documentId: parole.documentId, slug: parole.slug, ...paroleMeta, suspected_lang: 'fr' })
}
@@ -152,25 +155,26 @@ module.exports = createCoreService('api::parole.parole', ({strapi}) => ({
for (const lang of targetLangs) {
const { field, targetLang, userPrompt } = LANG_MAP[lang]
if (lang === sourceLang) continue
const target = stripMarkdown(parole.traductions?.[field])
if (!target) continue
langCounts[lang] = (langCounts[lang] || 0) + 1
if (type === 'instruct') {
const systemPrompt = sourceLang === 'ka'
? 'Tu es un expert en langue KA (créole guadeloupéen/martiniquais). Traduis le texte KA suivant.'
: `Tu es un expert en traduction. Traduis le texte suivant (langue source : ${sourceLang}).`
pairs.push({
messages: [
{
role: 'system',
content: 'Tu es un expert en langue KA (créole guadeloupéen/martiniquais). Traduis le texte KA suivant.',
},
{ role: 'system', content: systemPrompt },
{ role: 'user', content: `${userPrompt} :\n\n${source}` },
{ role: 'assistant', content: target },
],
})
} else {
pairs.push({
source_lang: 'ka',
source_lang: sourceLang,
target_lang: targetLang,
source,
target,
+9
View File
@@ -540,6 +540,10 @@ export interface ApiParoleParole extends Struct.CollectionTypeSchema {
>;
forceSlug: Schema.Attribute.Boolean;
gadeEmbed: Schema.Attribute.String;
langueSource: Schema.Attribute.Enumeration<
['ka', 'fr', 'en', 'es', 'de', 'it']
> &
Schema.Attribute.DefaultTo<'ka'>;
locale: Schema.Attribute.String & Schema.Attribute.Private;
localizations: Schema.Attribute.Relation<
'oneToMany',
@@ -551,7 +555,12 @@ export interface ApiParoleParole extends Struct.CollectionTypeSchema {
pawol: Schema.Attribute.Media<'files'>;
prioriteArtistes: Schema.Attribute.String;
publishedAt: Schema.Attribute.DateTime;
remixes: Schema.Attribute.Relation<'oneToMany', 'api::parole.parole'>;
slug: Schema.Attribute.String & Schema.Attribute.Unique;
sourceOriginale: Schema.Attribute.Relation<
'manyToOne',
'api::parole.parole'
>;
streamAudio: Schema.Attribute.Component<'store.album', true>;
streamVideo: Schema.Attribute.Component<'url.liens', true>;
titre: Schema.Attribute.String & Schema.Attribute.Required;