Méthodes guidées : propositions de l'IA à partir d'une idée de départ
- Champ « Ton idée de départ » dans l'assistant, avec « Proposer toute
l'aventure » et « Proposer pour cette étape ».
- L'IA ne remplit que les champs vides, ou restés à leur valeur d'office et
jamais modifiés : elle ne touche jamais à ce que le MJ a écrit, qui lui
est transmis comme contexte. « Annuler la proposition » restaure l'état.
- Questions à choix : seule une valeur proposée est acceptée.
- Core : POST /api/campaigns/{id}/guided-assist (contexte de la campagne,
filtrage des réponses, 502 si l'IA est indisponible).
- Brain : POST /generate/guided-answers, réponses dans la langue de
l'interface.
Vérifié : brain (prompt, nettoyage), core (service, contrôleur), vitest
(champs libres, fusion, étape), parcours dans le navigateur (réponse
simulée, champ du MJ préservé, annulation, message d'erreur sans IA).
This commit is contained in:
@@ -9,6 +9,7 @@ from app.application.generate_page import GeneratePageUseCase
|
|||||||
from app.application.llm_json import load_json_object
|
from app.application.llm_json import load_json_object
|
||||||
from app.application.llm_retry import generate_with_retry
|
from app.application.llm_retry import generate_with_retry
|
||||||
from app.application.prompts import conversation_title as title_prompts
|
from app.application.prompts import conversation_title as title_prompts
|
||||||
|
from app.application.prompts import guided_answers as guided_answers_prompts
|
||||||
from app.application.prompts import narrative_fields as narrative_fields_prompts
|
from app.application.prompts import narrative_fields as narrative_fields_prompts
|
||||||
from app.application.prompts import scene_drafts as scene_drafts_prompts
|
from app.application.prompts import scene_drafts as scene_drafts_prompts
|
||||||
from app.application.prompts import session_recap as session_recap_prompts
|
from app.application.prompts import session_recap as session_recap_prompts
|
||||||
@@ -290,3 +291,82 @@ async def generate_session_recap(
|
|||||||
if not recap:
|
if not recap:
|
||||||
raise HTTPException(status_code=502, detail="Le modèle n'a renvoyé aucun récit.")
|
raise HTTPException(status_code=502, detail="Le modèle n'a renvoyé aucun récit.")
|
||||||
return SessionRecapResponseDTO(recap=recap)
|
return SessionRecapResponseDTO(recap=recap)
|
||||||
|
|
||||||
|
|
||||||
|
# --- Méthodes guidées : proposer des réponses à partir d'une idée (Mentor d'écriture) ----
|
||||||
|
|
||||||
|
|
||||||
|
class GuidedOptionDTO(BaseModel):
|
||||||
|
"""Choix possible d'une question à choix : valeur technique + libellé lisible."""
|
||||||
|
|
||||||
|
value: str
|
||||||
|
label: str = Field(default="")
|
||||||
|
|
||||||
|
|
||||||
|
class GuidedFieldDTO(BaseModel):
|
||||||
|
"""Une question de la méthode guidée (décrite par le front, relayée par le Core)."""
|
||||||
|
|
||||||
|
key: str
|
||||||
|
label: str = Field(default="")
|
||||||
|
hint: str = Field(default="")
|
||||||
|
step: str = Field(default="")
|
||||||
|
options: list[GuidedOptionDTO] = Field(default_factory=list)
|
||||||
|
|
||||||
|
|
||||||
|
class GuidedAnswersRequestDTO(BaseModel):
|
||||||
|
method_name: str = Field(default="")
|
||||||
|
method_principle: str = Field(default="")
|
||||||
|
idea: str = Field(default="")
|
||||||
|
context: str = Field(default="")
|
||||||
|
fields: list[GuidedFieldDTO] = Field(default_factory=list)
|
||||||
|
existing: dict[str, str] = Field(default_factory=dict)
|
||||||
|
|
||||||
|
|
||||||
|
class GuidedAnswersResponseDTO(BaseModel):
|
||||||
|
"""Une réponse proposée par clé (clés demandées uniquement, choix valides, non vides)."""
|
||||||
|
|
||||||
|
answers: dict[str, str]
|
||||||
|
|
||||||
|
|
||||||
|
@router.post("/generate/guided-answers", response_model=GuidedAnswersResponseDTO)
|
||||||
|
async def generate_guided_answers(
|
||||||
|
body: GuidedAnswersRequestDTO,
|
||||||
|
llm: Annotated[LLMProvider, Depends(get_llm_provider)],
|
||||||
|
language: Annotated[str, Depends(get_user_language)],
|
||||||
|
) -> GuidedAnswersResponseDTO:
|
||||||
|
"""Propose des réponses aux questions d'une méthode guidée à partir de l'idée du MJ.
|
||||||
|
|
||||||
|
Rien n'est enregistré : le front remplit les champs vides, le MJ relit et corrige. Une
|
||||||
|
question à choix n'accepte qu'une des valeurs proposées ; le reste est ignoré.
|
||||||
|
"""
|
||||||
|
by_key = {f.key: f for f in body.fields if f.key}
|
||||||
|
prompt = guided_answers_prompts.guided_answers_prompt(
|
||||||
|
body.method_name, body.method_principle, body.idea, body.context,
|
||||||
|
[f.model_dump() for f in body.fields], body.existing, language)
|
||||||
|
try:
|
||||||
|
raw = await generate_with_retry(llm, prompt, output_format="json", temperature=0.8)
|
||||||
|
except LLMProviderError as exc:
|
||||||
|
raise HTTPException(status_code=502, detail=str(exc)) from exc
|
||||||
|
|
||||||
|
parsed, _ = load_json_object(raw)
|
||||||
|
if not isinstance(parsed, dict):
|
||||||
|
raise HTTPException(status_code=502, detail="Le modèle n'a pas renvoyé de réponses exploitables.")
|
||||||
|
return GuidedAnswersResponseDTO(answers=_clean_guided_answers(parsed.get("answers"), by_key))
|
||||||
|
|
||||||
|
|
||||||
|
def _clean_guided_answers(raw: object, by_key: dict[str, GuidedFieldDTO]) -> dict[str, str]:
|
||||||
|
"""Garde les clés demandées, non vides ; une question à choix n'accepte qu'une valeur proposée."""
|
||||||
|
out: dict[str, str] = {}
|
||||||
|
if not isinstance(raw, dict):
|
||||||
|
return out
|
||||||
|
for key, value in raw.items():
|
||||||
|
field = by_key.get(str(key))
|
||||||
|
if field is None or not isinstance(value, (str, int, float)):
|
||||||
|
continue
|
||||||
|
text = str(value).strip()
|
||||||
|
if not text:
|
||||||
|
continue
|
||||||
|
if field.options and text not in {o.value for o in field.options}:
|
||||||
|
continue
|
||||||
|
out[field.key] = text
|
||||||
|
return out
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
"""Prompt des méthodes guidées (Mentor d'écriture) : à partir de l'idée de départ du MJ,
|
||||||
|
proposer des réponses aux questions de la méthode (Donjon en 5 salles, Enquête en nœuds,
|
||||||
|
Plan du méchant…).
|
||||||
|
|
||||||
|
Générique : le front décrit la méthode (nom, principe) et ses questions (clé, libellé,
|
||||||
|
aide, étape, choix possibles) ; ce module ne fait que formuler le prompt. Les réponses
|
||||||
|
déjà écrites par le MJ sont fournies pour rester cohérent et ne jamais être contredites.
|
||||||
|
"""
|
||||||
|
from app.core.language import language_name
|
||||||
|
|
||||||
|
|
||||||
|
def _field_line(field: dict) -> str:
|
||||||
|
key = str(field.get("key") or "").strip()
|
||||||
|
label = str(field.get("label") or key).strip()
|
||||||
|
hint = str(field.get("hint") or "").strip()
|
||||||
|
step = str(field.get("step") or "").strip()
|
||||||
|
line = f'- "{key}"'
|
||||||
|
if step:
|
||||||
|
line += f" [{step}]"
|
||||||
|
line += f" : {label}"
|
||||||
|
if hint:
|
||||||
|
line += f" — {hint}"
|
||||||
|
options = field.get("options") or []
|
||||||
|
if options:
|
||||||
|
values = ", ".join(f'"{o.get("value")}" ({o.get("label")})' for o in options if o.get("value"))
|
||||||
|
line += f" — UNE valeur parmi : {values}"
|
||||||
|
return line
|
||||||
|
|
||||||
|
|
||||||
|
def guided_answers_prompt(method_name: str, method_principle: str, idea: str, context: str,
|
||||||
|
fields: list[dict], existing: dict[str, str], language: str) -> str:
|
||||||
|
"""Construit le prompt. `fields` = [{key, label, hint, step, options}] ; `existing` = réponses du MJ."""
|
||||||
|
fields_list = "\n".join(_field_line(f) for f in fields or [] if f.get("key"))
|
||||||
|
existing_lines = "\n".join(
|
||||||
|
f'- "{k}" : {v.strip()}' for k, v in (existing or {}).items() if isinstance(v, str) and v.strip())
|
||||||
|
existing_block = (
|
||||||
|
"\nCe que le MJ a DÉJÀ écrit (à respecter, ne le contredis jamais) :\n"
|
||||||
|
f"{existing_lines}\n" if existing_lines else ""
|
||||||
|
)
|
||||||
|
context_block = f"\nContexte de la campagne :\n{context.strip()}\n" if context and context.strip() else ""
|
||||||
|
principle = f" Principe : {method_principle.strip()}" if method_principle and method_principle.strip() else ""
|
||||||
|
return (
|
||||||
|
"Tu es un auteur expérimenté de scénarios de jeu de rôle, qui aide un MJ à écrire son aventure "
|
||||||
|
f"avec la méthode « {method_name.strip() or 'guidée'} ».{principle}\n\n"
|
||||||
|
f"Idée de départ du MJ : {idea.strip() or '(aucune : propose une aventure originale)'}\n"
|
||||||
|
f"{context_block}{existing_block}\n"
|
||||||
|
"Questions de la méthode auxquelles tu dois répondre (n'utilise QUE ces clés) :\n"
|
||||||
|
f"{fields_list}\n\n"
|
||||||
|
"Règles IMPÉRATIVES :\n"
|
||||||
|
"- Réponds UNIQUEMENT par un objet JSON valide, sans texte autour.\n"
|
||||||
|
'- Format exact : {"answers": {"cle": "réponse", ...}}\n'
|
||||||
|
"- N'inclus QUE des clés de la liste. Pour une question à choix, renvoie EXACTEMENT une des "
|
||||||
|
"valeurs proposées.\n"
|
||||||
|
"- Développe l'idée du MJ : toutes les réponses forment UNE aventure cohérente, concrète et jouable "
|
||||||
|
"(noms, lieux, motivations précises ; pas de généralités).\n"
|
||||||
|
"- Sois concis : un nom en quelques mots, une description en 2 à 4 phrases.\n"
|
||||||
|
"- Donne toujours aux joueurs de vrais choix et plusieurs façons de progresser.\n"
|
||||||
|
f"- Rédige les réponses en {language_name(language)}.\n"
|
||||||
|
"Renvoie maintenant le JSON."
|
||||||
|
)
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
"""Méthodes guidées : prompt de propositions et nettoyage des réponses du modèle."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from app.api.routers.generation import GuidedFieldDTO, GuidedOptionDTO, _clean_guided_answers
|
||||||
|
from app.application.prompts.guided_answers import guided_answers_prompt
|
||||||
|
|
||||||
|
|
||||||
|
def _fields() -> dict[str, GuidedFieldDTO]:
|
||||||
|
return {
|
||||||
|
"title": GuidedFieldDTO(key="title", label="Nom de l'enquête"),
|
||||||
|
"node1.nature": GuidedFieldDTO(key="node1.nature", label="Genre de scène", options=[
|
||||||
|
GuidedOptionDTO(value="location", label="Un lieu"), GuidedOptionDTO(value="npc", label="Une personne")]),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_prompt_contains_idea_questions_choices_existing_answers_and_language():
|
||||||
|
prompt = guided_answers_prompt(
|
||||||
|
"Enquête en nœuds", "Trois pistes qui se recoupent.", "Une tour qui se rallume", "Campagne : Valfroide",
|
||||||
|
[{"key": "title", "label": "Nom de l'enquête", "hint": "Ex. : L'héritage", "step": "Le mystère"},
|
||||||
|
{"key": "node1.nature", "label": "Genre", "options": [{"value": "location", "label": "Un lieu"}]}],
|
||||||
|
{"truth": "Le notaire est coupable", "empty": " "}, "en")
|
||||||
|
|
||||||
|
assert "Une tour qui se rallume" in prompt
|
||||||
|
assert '"title" [Le mystère] : Nom de l\'enquête — Ex. : L\'héritage' in prompt
|
||||||
|
assert 'UNE valeur parmi : "location" (Un lieu)' in prompt
|
||||||
|
assert "Le notaire est coupable" in prompt
|
||||||
|
assert '"empty"' not in prompt, "une réponse vide n'est pas rappelée"
|
||||||
|
assert "Campagne : Valfroide" in prompt
|
||||||
|
assert "anglais" in prompt
|
||||||
|
|
||||||
|
|
||||||
|
def test_prompt_without_idea_asks_for_an_original_adventure():
|
||||||
|
prompt = guided_answers_prompt("Plan du méchant", "", " ", "", [{"key": "villain", "label": "Adversaire"}], {}, "fr")
|
||||||
|
assert "propose une aventure originale" in prompt
|
||||||
|
assert "français" in prompt
|
||||||
|
|
||||||
|
|
||||||
|
def test_clean_keeps_requested_keys_and_valid_choices_only():
|
||||||
|
out = _clean_guided_answers({
|
||||||
|
"title": " L'héritage empoisonné ",
|
||||||
|
"node1.nature": "npc",
|
||||||
|
"unknown": "ignorée",
|
||||||
|
"empty": "",
|
||||||
|
}, _fields())
|
||||||
|
assert out == {"title": "L'héritage empoisonné", "node1.nature": "npc"}
|
||||||
|
|
||||||
|
|
||||||
|
def test_clean_rejects_an_invalid_choice_and_non_text_values():
|
||||||
|
out = _clean_guided_answers({"node1.nature": "dragon", "title": ["liste"]}, _fields())
|
||||||
|
assert out == {}
|
||||||
|
assert _clean_guided_answers("pas un objet", _fields()) == {}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package com.loremind.application.campaigncontext;
|
||||||
|
|
||||||
|
import com.loremind.domain.campaigncontext.ports.GuidedMethodAssistant;
|
||||||
|
import com.loremind.domain.campaigncontext.ports.GuidedMethodAssistant.Choice;
|
||||||
|
import com.loremind.domain.campaigncontext.ports.GuidedMethodAssistant.Question;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IA des méthodes guidées (Mentor d'écriture) : propose des réponses aux questions d'une
|
||||||
|
* méthode à partir de l'idée de départ du MJ et de la campagne. Rien n'est enregistré : le
|
||||||
|
* front remplit les champs vides et le MJ relit, corrige ou relance.
|
||||||
|
*
|
||||||
|
* <p>Garde-fous : nombre de questions et longueur des textes bornés (le prompt reste
|
||||||
|
* raisonnable) ; en retour, seules les clés demandées sont gardées, et une question à choix
|
||||||
|
* n'accepte qu'une des valeurs proposées.</p>
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class GuidedAssistService {
|
||||||
|
|
||||||
|
static final int MAX_QUESTIONS = 80;
|
||||||
|
static final int MAX_TEXT = 4_000;
|
||||||
|
|
||||||
|
private final GuidedMethodAssistant assistant;
|
||||||
|
private final CampaignContextFormatter contextFormatter;
|
||||||
|
|
||||||
|
public GuidedAssistService(GuidedMethodAssistant assistant, CampaignContextFormatter contextFormatter) {
|
||||||
|
this.assistant = assistant;
|
||||||
|
this.contextFormatter = contextFormatter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Demande à proposer des réponses. @throws IllegalArgumentException aucune question valide */
|
||||||
|
public Map<String, String> suggest(String campaignId, String methodName, String principle, String idea,
|
||||||
|
List<Question> questions, Map<String, String> existing) {
|
||||||
|
List<Question> valid = questions == null ? List.of() : questions.stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.filter(q -> q.key() != null && !q.key().isBlank())
|
||||||
|
.limit(MAX_QUESTIONS)
|
||||||
|
.toList();
|
||||||
|
if (valid.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("Aucune question à laquelle répondre.");
|
||||||
|
}
|
||||||
|
Map<String, String> answers = assistant.answer(cap(methodName), cap(principle), cap(idea),
|
||||||
|
contextFormatter.format(campaignId), valid, capAll(existing));
|
||||||
|
return keepValid(answers, valid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Clés demandées uniquement, valeurs non vides ; choix limités aux valeurs proposées. */
|
||||||
|
static Map<String, String> keepValid(Map<String, String> answers, List<Question> questions) {
|
||||||
|
Map<String, String> out = new LinkedHashMap<>();
|
||||||
|
if (answers == null) return out;
|
||||||
|
Map<String, Question> byKey = questions.stream()
|
||||||
|
.collect(Collectors.toMap(Question::key, q -> q, (a, b) -> a, LinkedHashMap::new));
|
||||||
|
for (Map.Entry<String, String> e : answers.entrySet()) {
|
||||||
|
Question q = byKey.get(e.getKey());
|
||||||
|
String value = e.getValue() == null ? "" : e.getValue().trim();
|
||||||
|
if (q == null || value.isEmpty()) continue;
|
||||||
|
if (q.options() != null && !q.options().isEmpty()) {
|
||||||
|
Set<String> allowed = q.options().stream().map(Choice::value).collect(Collectors.toSet());
|
||||||
|
if (!allowed.contains(value)) continue;
|
||||||
|
}
|
||||||
|
out.put(q.key(), cap(value));
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map<String, String> capAll(Map<String, String> existing) {
|
||||||
|
Map<String, String> out = new LinkedHashMap<>();
|
||||||
|
if (existing == null) return out;
|
||||||
|
existing.forEach((k, v) -> {
|
||||||
|
if (k != null && v != null && !v.isBlank()) out.put(k, cap(v.trim()));
|
||||||
|
});
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String cap(String s) {
|
||||||
|
if (s == null) return "";
|
||||||
|
return s.length() > MAX_TEXT ? s.substring(0, MAX_TEXT) : s;
|
||||||
|
}
|
||||||
|
}
|
||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
package com.loremind.domain.campaigncontext.ports;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Port de sortie (Mentor d'écriture) : demande à l'IA de proposer des réponses aux
|
||||||
|
* questions d'une méthode guidée à partir de l'idée de départ du MJ. Implémenté par un
|
||||||
|
* client du Brain. One-shot ; rien n'est enregistré (le MJ relit et corrige dans l'assistant).
|
||||||
|
*/
|
||||||
|
public interface GuidedMethodAssistant {
|
||||||
|
|
||||||
|
/** Choix possible d'une question à choix : valeur technique + libellé lisible. */
|
||||||
|
record Choice(String value, String label) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Une question de la méthode, décrite par le front (libellés dans la langue du MJ).
|
||||||
|
*
|
||||||
|
* @param key clé de réponse (ex. {@code node1.name})
|
||||||
|
* @param label libellé de la question
|
||||||
|
* @param hint aide (exemple de réponse attendue), optionnelle
|
||||||
|
* @param step titre de l'étape, optionnel
|
||||||
|
* @param options choix possibles (vide pour une question libre)
|
||||||
|
*/
|
||||||
|
record Question(String key, String label, String hint, String step, List<Choice> options) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param methodName nom de la méthode (« Enquête en nœuds »…)
|
||||||
|
* @param principle principe de la méthode, en une phrase
|
||||||
|
* @param idea idée de départ du MJ (peut être vide)
|
||||||
|
* @param context contexte de la campagne (nom, description, système)
|
||||||
|
* @param questions questions auxquelles répondre
|
||||||
|
* @param existing réponses déjà écrites par le MJ (à respecter)
|
||||||
|
* @return une réponse proposée par clé (clés demandées uniquement)
|
||||||
|
*/
|
||||||
|
Map<String, String> answer(String methodName, String principle, String idea, String context,
|
||||||
|
List<Question> questions, Map<String, String> existing);
|
||||||
|
}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
package com.loremind.infrastructure.ai;
|
||||||
|
|
||||||
|
import com.loremind.domain.campaigncontext.ports.GuidedMethodAssistant;
|
||||||
|
import com.loremind.domain.campaigncontext.ports.exceptions.NarrativeAssistException;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.http.HttpEntity;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.client.ResourceAccessException;
|
||||||
|
import org.springframework.web.client.RestClientResponseException;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adapter de sortie : propositions de réponses aux méthodes guidées via le Brain
|
||||||
|
* ({@code POST /generate/guided-answers}, one-shot). La langue de l'interface est relayée par
|
||||||
|
* l'intercepteur du RestTemplate (en-tête {@code X-User-Language}).
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class BrainGuidedAnswersClient implements GuidedMethodAssistant {
|
||||||
|
|
||||||
|
private static final String PATH = "/generate/guided-answers";
|
||||||
|
|
||||||
|
private final RestTemplate restTemplate;
|
||||||
|
private final String baseUrl;
|
||||||
|
|
||||||
|
public BrainGuidedAnswersClient(RestTemplate restTemplate, @Value("${brain.base-url}") String baseUrl) {
|
||||||
|
this.restTemplate = restTemplate;
|
||||||
|
this.baseUrl = baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> answer(String methodName, String principle, String idea, String context,
|
||||||
|
List<Question> questions, Map<String, String> existing) {
|
||||||
|
Map<String, Object> req = new LinkedHashMap<>();
|
||||||
|
req.put("method_name", nz(methodName));
|
||||||
|
req.put("method_principle", nz(principle));
|
||||||
|
req.put("idea", nz(idea));
|
||||||
|
req.put("context", nz(context));
|
||||||
|
req.put("fields", toPayload(questions));
|
||||||
|
req.put("existing", existing == null ? Map.of() : existing);
|
||||||
|
return parse(call(req));
|
||||||
|
}
|
||||||
|
|
||||||
|
static List<Map<String, Object>> toPayload(List<Question> questions) {
|
||||||
|
List<Map<String, Object>> out = new ArrayList<>();
|
||||||
|
for (Question q : questions) {
|
||||||
|
Map<String, Object> f = new LinkedHashMap<>();
|
||||||
|
f.put("key", q.key());
|
||||||
|
f.put("label", nz(q.label()).isEmpty() ? q.key() : q.label());
|
||||||
|
f.put("hint", nz(q.hint()));
|
||||||
|
f.put("step", nz(q.step()));
|
||||||
|
List<Map<String, String>> options = new ArrayList<>();
|
||||||
|
if (q.options() != null) {
|
||||||
|
for (Choice c : q.options()) {
|
||||||
|
if (c != null && c.value() != null) options.add(Map.of("value", c.value(), "label", nz(c.label())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f.put("options", options);
|
||||||
|
out.add(f);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private Map<String, Object> call(Map<String, Object> req) {
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
Map<String, Object> resp;
|
||||||
|
try {
|
||||||
|
resp = restTemplate.postForObject(baseUrl + PATH, new HttpEntity<>(req, headers), Map.class);
|
||||||
|
} catch (ResourceAccessException e) {
|
||||||
|
throw new NarrativeAssistException("Le Brain est injoignable (timeout ou arrêté).", e);
|
||||||
|
} catch (RestClientResponseException e) {
|
||||||
|
throw new NarrativeAssistException(
|
||||||
|
"Le Brain a répondu HTTP " + e.getStatusCode().value() + " : " + e.getResponseBodyAsString(), e);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new NarrativeAssistException("Erreur inattendue lors de l'appel au Brain.", e);
|
||||||
|
}
|
||||||
|
if (resp == null) throw new NarrativeAssistException("Le Brain a renvoyé une réponse vide.");
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map<String, String> parse(Map<String, Object> resp) {
|
||||||
|
Map<String, String> out = new LinkedHashMap<>();
|
||||||
|
if (resp.get("answers") instanceof Map<?, ?> m) {
|
||||||
|
m.forEach((k, v) -> {
|
||||||
|
if (k != null && v != null) out.put(k.toString(), v.toString());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String nz(String s) {
|
||||||
|
return s == null ? "" : s;
|
||||||
|
}
|
||||||
|
}
|
||||||
+52
@@ -0,0 +1,52 @@
|
|||||||
|
package com.loremind.infrastructure.web.controller;
|
||||||
|
|
||||||
|
import com.loremind.application.campaigncontext.GuidedAssistService;
|
||||||
|
import com.loremind.domain.campaigncontext.ports.CampaignRepository;
|
||||||
|
import com.loremind.domain.campaigncontext.ports.GuidedMethodAssistant.Question;
|
||||||
|
import com.loremind.domain.campaigncontext.ports.exceptions.NarrativeAssistException;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.server.ResponseStatusException;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IA des méthodes guidées : propose des réponses aux questions d'une méthode à partir de
|
||||||
|
* l'idée de départ du MJ. Rien n'est enregistré.
|
||||||
|
*
|
||||||
|
* <p>{@code POST /api/campaigns/{campaignId}/guided-assist} → {@code {answers: {cle: valeur}}} ;
|
||||||
|
* 400 sans question, 404 campagne inconnue, 502 si l'IA est indisponible.</p>
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/campaigns/{campaignId}/guided-assist")
|
||||||
|
public class GuidedAssistController {
|
||||||
|
|
||||||
|
/** Corps : la méthode (nom, principe), l'idée, les questions et les réponses déjà écrites. */
|
||||||
|
public record SuggestRequest(String methodName, String principle, String idea,
|
||||||
|
List<Question> questions, Map<String, String> existing) {}
|
||||||
|
|
||||||
|
public record SuggestResponse(Map<String, String> answers) {}
|
||||||
|
|
||||||
|
private final GuidedAssistService service;
|
||||||
|
private final CampaignRepository campaignRepository;
|
||||||
|
|
||||||
|
public GuidedAssistController(GuidedAssistService service, CampaignRepository campaignRepository) {
|
||||||
|
this.service = service;
|
||||||
|
this.campaignRepository = campaignRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
public ResponseEntity<SuggestResponse> suggest(@PathVariable String campaignId, @RequestBody SuggestRequest body) {
|
||||||
|
if (!campaignRepository.existsById(campaignId)) {
|
||||||
|
return ResponseEntity.notFound().build();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return ResponseEntity.ok(new SuggestResponse(service.suggest(campaignId, body.methodName(),
|
||||||
|
body.principle(), body.idea(), body.questions(), body.existing())));
|
||||||
|
} catch (NarrativeAssistException e) {
|
||||||
|
throw new ResponseStatusException(HttpStatus.BAD_GATEWAY, e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+61
@@ -0,0 +1,61 @@
|
|||||||
|
package com.loremind.application.campaigncontext;
|
||||||
|
|
||||||
|
import com.loremind.domain.campaigncontext.ports.GuidedMethodAssistant;
|
||||||
|
import com.loremind.domain.campaigncontext.ports.GuidedMethodAssistant.Choice;
|
||||||
|
import com.loremind.domain.campaigncontext.ports.GuidedMethodAssistant.Question;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.mockito.InjectMocks;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
import static org.mockito.ArgumentMatchers.*;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
/** IA des méthodes guidées : questions validées, contexte de campagne transmis, réponses filtrées. */
|
||||||
|
@ExtendWith(MockitoExtension.class)
|
||||||
|
class GuidedAssistServiceTest {
|
||||||
|
|
||||||
|
@Mock private GuidedMethodAssistant assistant;
|
||||||
|
@Mock private CampaignContextFormatter contextFormatter;
|
||||||
|
@InjectMocks private GuidedAssistService service;
|
||||||
|
|
||||||
|
private static final Question TITLE = new Question("title", "Nom de l'enquête", "Ex. : L'héritage", "Le mystère", List.of());
|
||||||
|
private static final Question NATURE = new Question("node1.nature", "Genre de scène", null, "Première piste",
|
||||||
|
List.of(new Choice("location", "Un lieu"), new Choice("npc", "Une personne")));
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void suggest_sendsCampaignContextAndExistingAnswers_andFiltersTheResult() {
|
||||||
|
when(contextFormatter.format("c1")).thenReturn("Campagne : Valfroide");
|
||||||
|
when(assistant.answer(eq("Enquête en nœuds"), any(), eq("Une tour se rallume"), eq("Campagne : Valfroide"),
|
||||||
|
anyList(), anyMap())).thenReturn(Map.of(
|
||||||
|
"title", " L'héritage empoisonné ",
|
||||||
|
"node1.nature", "dragon", // choix invalide -> écarté
|
||||||
|
"invented", "clé inventée", // clé non demandée -> écartée
|
||||||
|
"node1.name", ""));
|
||||||
|
|
||||||
|
Map<String, String> out = service.suggest("c1", "Enquête en nœuds", "Trois pistes",
|
||||||
|
"Une tour se rallume", List.of(TITLE, NATURE), Map.of("truth", " Le notaire ", "blank", " "));
|
||||||
|
|
||||||
|
assertEquals(Map.of("title", "L'héritage empoisonné"), out);
|
||||||
|
verify(assistant).answer(any(), any(), any(), any(), eq(List.of(TITLE, NATURE)), eq(Map.of("truth", "Le notaire")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void suggest_keepsAValidChoice() {
|
||||||
|
when(assistant.answer(any(), any(), any(), any(), anyList(), anyMap())).thenReturn(Map.of("node1.nature", "npc"));
|
||||||
|
assertEquals(Map.of("node1.nature", "npc"), service.suggest("c1", "M", "", "", List.of(NATURE), null));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void suggest_withoutAnyValidQuestion_isRejected() {
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> service.suggest("c1", "M", "", "idée", List.of(), Map.of()));
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> service.suggest("c1", "M", "", "idée",
|
||||||
|
java.util.Arrays.asList(null, new Question(" ", "x", null, null, null)), Map.of()));
|
||||||
|
}
|
||||||
|
}
|
||||||
+72
@@ -0,0 +1,72 @@
|
|||||||
|
package com.loremind.infrastructure.web.controller;
|
||||||
|
|
||||||
|
import com.loremind.domain.campaigncontext.Campaign;
|
||||||
|
import com.loremind.domain.campaigncontext.ports.CampaignRepository;
|
||||||
|
import com.loremind.domain.campaigncontext.ports.GuidedMethodAssistant;
|
||||||
|
import com.loremind.domain.campaigncontext.ports.exceptions.NarrativeAssistException;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||||
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.*;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
@AutoConfigureMockMvc
|
||||||
|
@Transactional
|
||||||
|
class GuidedAssistControllerTest {
|
||||||
|
|
||||||
|
@Autowired private MockMvc mockMvc;
|
||||||
|
@Autowired private CampaignRepository campaignRepository;
|
||||||
|
@MockitoBean private GuidedMethodAssistant assistant;
|
||||||
|
|
||||||
|
private static final String BODY = """
|
||||||
|
{"methodName":"Enquête en nœuds","principle":"Trois pistes","idea":"Une tour se rallume",
|
||||||
|
"questions":[{"key":"title","label":"Nom","hint":"","step":"Le mystère","options":[]}],
|
||||||
|
"existing":{}}""";
|
||||||
|
|
||||||
|
private String campaignId() {
|
||||||
|
return campaignRepository.save(Campaign.builder().name("C").description("").build()).getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void suggest_returnsTheFilteredAnswers() throws Exception {
|
||||||
|
when(assistant.answer(any(), any(), any(), any(), anyList(), anyMap()))
|
||||||
|
.thenReturn(Map.of("title", "L'héritage empoisonné", "other", "x"));
|
||||||
|
mockMvc.perform(post("/api/campaigns/{id}/guided-assist", campaignId())
|
||||||
|
.contentType(MediaType.APPLICATION_JSON).content(BODY))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.answers.title").value("L'héritage empoisonné"))
|
||||||
|
.andExpect(jsonPath("$.answers.other").doesNotExist());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void suggest_unknownCampaign_is404_andUnavailableAi_is502() throws Exception {
|
||||||
|
mockMvc.perform(post("/api/campaigns/{id}/guided-assist", "999999999")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON).content(BODY))
|
||||||
|
.andExpect(status().isNotFound());
|
||||||
|
|
||||||
|
when(assistant.answer(any(), any(), any(), any(), anyList(), anyMap()))
|
||||||
|
.thenThrow(new NarrativeAssistException("Le Brain est injoignable"));
|
||||||
|
mockMvc.perform(post("/api/campaigns/{id}/guided-assist", campaignId())
|
||||||
|
.contentType(MediaType.APPLICATION_JSON).content(BODY))
|
||||||
|
.andExpect(status().isBadGateway());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void suggest_withoutQuestions_is400() throws Exception {
|
||||||
|
mockMvc.perform(post("/api/campaigns/{id}/guided-assist", campaignId())
|
||||||
|
.contentType(MediaType.APPLICATION_JSON).content("{\"idea\":\"x\",\"questions\":[]}"))
|
||||||
|
.andExpect(status().isBadRequest());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import { IDEA_KEY, applySuggestions, buildSuggestRequest, isFillable, markTouched } from './guided-assist';
|
||||||
|
import { INVESTIGATION_METHOD } from './methods/investigation.method';
|
||||||
|
import { GuidedField } from './guided-method.model';
|
||||||
|
|
||||||
|
/** Traduction factice : renvoie la clé, sauf les noms pré-remplis (valeurs d'office). */
|
||||||
|
const t = (key: string) => key.endsWith('defaults.node1.name') ? 'Première piste' : key;
|
||||||
|
const field = (key: string): GuidedField =>
|
||||||
|
INVESTIGATION_METHOD.steps.flatMap(s => s.fields ?? []).find(f => f.key === key)!;
|
||||||
|
|
||||||
|
describe('guided AI assist', () => {
|
||||||
|
it('treats empty fields and untouched defaults as free for the AI', () => {
|
||||||
|
expect(isFillable(INVESTIGATION_METHOD, field('truth'), {}, t)).toBe(true);
|
||||||
|
expect(isFillable(INVESTIGATION_METHOD, field('node1.name'), { 'node1.name': 'Première piste' }, t)).toBe(true);
|
||||||
|
expect(isFillable(INVESTIGATION_METHOD, field('node1.nature'), { 'node1.nature': 'location' }, t)).toBe(true);
|
||||||
|
expect(isFillable(INVESTIGATION_METHOD, field('node1.nature'), { 'node1.nature': 'npc' }, t)).toBe(false);
|
||||||
|
expect(isFillable(INVESTIGATION_METHOD, field('truth'), { truth: 'Le notaire' }, t)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('never considers a field the GM touched as free, even at its default value', () => {
|
||||||
|
const answers = markTouched({ 'node1.name': 'Première piste' }, 'node1.name');
|
||||||
|
expect(isFillable(INVESTIGATION_METHOD, field('node1.name'), answers, t)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('asks only free fields, sends what the GM wrote as context, and passes the idea', () => {
|
||||||
|
const req = buildSuggestRequest(INVESTIGATION_METHOD, { [IDEA_KEY]: ' Une tour ', truth: 'Le notaire est coupable' }, t);
|
||||||
|
expect(req.idea).toBe('Une tour');
|
||||||
|
expect(req.existing).toEqual({ truth: 'Le notaire est coupable' });
|
||||||
|
expect(req.questions.some(q => q.key === 'truth')).toBe(false);
|
||||||
|
const nature = req.questions.find(q => q.key === 'node1.nature')!;
|
||||||
|
expect(nature.options.map(o => o.value)).toEqual(['location', 'npc', 'event']);
|
||||||
|
expect(nature.hint).toBe('');
|
||||||
|
expect(req.methodName).toBe('guided.investigation.name');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('limits the questions to the requested step', () => {
|
||||||
|
const req = buildSuggestRequest(INVESTIGATION_METHOD, {}, t, ['node2']);
|
||||||
|
expect(req.questions.length).toBeGreaterThan(0);
|
||||||
|
expect(req.questions.every(q => q.key.startsWith('node2.'))).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('applies proposals to free fields only, and only valid choices', () => {
|
||||||
|
const answers = { truth: 'Le notaire', 'node1.nature': 'location' };
|
||||||
|
const { answers: next, filled } = applySuggestions(INVESTIGATION_METHOD, answers, {
|
||||||
|
truth: 'Autre vérité', 'node1.nature': 'npc', 'node2.nature': 'dragon', title: "L'héritage", unknown: 'x'
|
||||||
|
}, t);
|
||||||
|
expect(next['truth']).toBe('Le notaire');
|
||||||
|
expect(next['node1.nature']).toBe('npc');
|
||||||
|
expect(next['node2.nature']).toBeUndefined();
|
||||||
|
expect(next['title']).toBe("L'héritage");
|
||||||
|
expect(next['unknown']).toBeUndefined();
|
||||||
|
expect(filled).toBe(2);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
import { GuidedAnswers, GuidedField, GuidedMethod, GuidedStep } from './guided-method.model';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IA des méthodes guidées (logique pure, testée sans Angular) : questions envoyées au modèle,
|
||||||
|
* champs que l'IA a le droit de remplir, et fusion des réponses proposées.
|
||||||
|
*
|
||||||
|
* Règle d'or : l'IA ne remplace JAMAIS ce que le MJ a écrit. Elle ne remplit qu'un champ
|
||||||
|
* vide, ou resté à sa valeur d'office (nom pré-rempli « Première piste », premier choix
|
||||||
|
* d'une question à choix) tant que le MJ n'y a pas touché.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Clé de réponse réservée : l'idée de départ du MJ (gardée dans le brouillon). */
|
||||||
|
export const IDEA_KEY = 'idea';
|
||||||
|
/** Clé de réponse réservée : champs modifiés à la main par le MJ (séparés par des virgules). */
|
||||||
|
export const TOUCHED_KEY = 'touched';
|
||||||
|
|
||||||
|
/** Traduction d'une clé i18n (injectée : TranslateService.instant côté composant). */
|
||||||
|
export type Translate = (key: string) => string;
|
||||||
|
|
||||||
|
export interface GuidedQuestion {
|
||||||
|
key: string;
|
||||||
|
label: string;
|
||||||
|
hint: string;
|
||||||
|
step: string;
|
||||||
|
options: { value: string; label: string }[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GuidedSuggestRequest {
|
||||||
|
methodName: string;
|
||||||
|
principle: string;
|
||||||
|
idea: string;
|
||||||
|
questions: GuidedQuestion[];
|
||||||
|
existing: Record<string, string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Préfixe i18n de la méthode (`guided.<i18nKey>.`). */
|
||||||
|
function k(method: GuidedMethod, path: string): string {
|
||||||
|
return `guided.${method.i18nKey}.${path}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Valeur mise d'office par l'assistant (sans intervention du MJ), ou null. */
|
||||||
|
export function defaultValue(method: GuidedMethod, field: GuidedField, t: Translate): string | null {
|
||||||
|
if (field.kind === 'choice') return field.options?.[0] ?? null;
|
||||||
|
if (field.prefilled) return t(k(method, `defaults.${field.key}`));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function touchedKeys(answers: GuidedAnswers): Set<string> {
|
||||||
|
return new Set((answers[TOUCHED_KEY] ?? '').split(',').filter(Boolean));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Marque un champ comme modifié à la main (l'IA n'y touchera plus). */
|
||||||
|
export function markTouched(answers: GuidedAnswers, key: string): GuidedAnswers {
|
||||||
|
const touched = touchedKeys(answers);
|
||||||
|
if (touched.has(key)) return answers;
|
||||||
|
touched.add(key);
|
||||||
|
return { ...answers, [TOUCHED_KEY]: [...touched].join(',') };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Le champ est-il encore libre pour l'IA ? Vide, ou à sa valeur d'office et jamais touché. */
|
||||||
|
export function isFillable(method: GuidedMethod, field: GuidedField, answers: GuidedAnswers, t: Translate): boolean {
|
||||||
|
const value = (answers[field.key] ?? '').trim();
|
||||||
|
if (!value) return true;
|
||||||
|
return !touchedKeys(answers).has(field.key) && value === defaultValue(method, field, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
function formSteps(method: GuidedMethod, stepIds?: string[]): GuidedStep[] {
|
||||||
|
return method.steps.filter(s => s.kind === 'form' && (!stepIds || stepIds.includes(s.id)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requête de propositions pour les étapes demandées (toutes si absent) : seuls les champs
|
||||||
|
* encore libres sont demandés ; tout ce que le MJ a déjà écrit est transmis comme contexte.
|
||||||
|
*/
|
||||||
|
export function buildSuggestRequest(method: GuidedMethod, answers: GuidedAnswers, t: Translate,
|
||||||
|
stepIds?: string[]): GuidedSuggestRequest {
|
||||||
|
const questions: GuidedQuestion[] = [];
|
||||||
|
const existing: Record<string, string> = {};
|
||||||
|
for (const step of formSteps(method)) {
|
||||||
|
for (const field of step.fields ?? []) {
|
||||||
|
if (!isFillable(method, field, answers, t)) {
|
||||||
|
existing[field.key] = answers[field.key];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (stepIds && !stepIds.includes(step.id)) continue;
|
||||||
|
questions.push({
|
||||||
|
key: field.key,
|
||||||
|
label: t(k(method, `fields.${field.key}.label`)),
|
||||||
|
hint: field.kind === 'choice' ? '' : t(k(method, `fields.${field.key}.placeholder`)),
|
||||||
|
step: t(k(method, `steps.${step.id}.title`)),
|
||||||
|
options: (field.options ?? []).map(o => ({ value: o, label: t(k(method, `options.${field.key}.${o}`)) }))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
methodName: t(k(method, 'name')),
|
||||||
|
principle: t(k(method, 'tagline')),
|
||||||
|
idea: (answers[IDEA_KEY] ?? '').trim(),
|
||||||
|
questions,
|
||||||
|
existing
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Applique les propositions sur les seuls champs encore libres (jamais sur un champ du MJ). */
|
||||||
|
export function applySuggestions(method: GuidedMethod, answers: GuidedAnswers, suggestions: Record<string, string>,
|
||||||
|
t: Translate): { answers: GuidedAnswers; filled: number } {
|
||||||
|
const next = { ...answers };
|
||||||
|
let filled = 0;
|
||||||
|
for (const step of formSteps(method)) {
|
||||||
|
for (const field of step.fields ?? []) {
|
||||||
|
const proposal = suggestions[field.key]?.trim();
|
||||||
|
if (!proposal || !isFillable(method, field, answers, t)) continue;
|
||||||
|
if (field.kind === 'choice' && !field.options?.includes(proposal)) continue;
|
||||||
|
next[field.key] = proposal;
|
||||||
|
filled++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { answers: next, filled };
|
||||||
|
}
|
||||||
@@ -29,6 +29,40 @@
|
|||||||
</aside>
|
</aside>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<!-- IA : idée de départ du MJ, propositions pour toute la méthode ou pour l'étape. -->
|
||||||
|
@if (step.kind !== 'review') {
|
||||||
|
<section class="ai-idea" [attr.aria-label]="'guided.ai.title' | translate">
|
||||||
|
<label class="ai-idea-label" for="guided-idea">
|
||||||
|
<lucide-icon [img]="Sparkles" [size]="14"></lucide-icon>
|
||||||
|
{{ 'guided.ai.title' | translate }}
|
||||||
|
</label>
|
||||||
|
<textarea id="guided-idea" rows="2" [(ngModel)]="idea"
|
||||||
|
[placeholder]="'guided.ai.placeholder' | translate"></textarea>
|
||||||
|
<div class="ai-actions">
|
||||||
|
<button type="button" class="btn-ai" (click)="suggestAll()" [disabled]="!!suggesting">
|
||||||
|
{{ (suggesting === 'all' ? 'guided.ai.thinking' : 'guided.ai.suggestAll') | translate }}
|
||||||
|
</button>
|
||||||
|
@if (step.kind === 'form') {
|
||||||
|
<button type="button" class="btn-ai-secondary" (click)="suggestStep()" [disabled]="!!suggesting">
|
||||||
|
{{ (suggesting === 'step' ? 'guided.ai.thinking' : 'guided.ai.suggestStep') | translate }}
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
@if (canUndoSuggest && !suggesting) {
|
||||||
|
<button type="button" class="btn-link" (click)="undoSuggest()">{{ 'guided.ai.undo' | translate }}</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
@if (suggestFilled !== null) {
|
||||||
|
<p class="ai-note" role="status">
|
||||||
|
{{ (suggestFilled > 0 ? 'guided.ai.filled' : 'guided.ai.nothingToFill') | translate:{ count: suggestFilled } }}
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
@if (suggestError) {
|
||||||
|
<p class="ai-error" role="alert">{{ suggestError }}</p>
|
||||||
|
}
|
||||||
|
<p class="ai-hint">{{ 'guided.ai.hint' | translate }}</p>
|
||||||
|
</section>
|
||||||
|
}
|
||||||
|
|
||||||
<!-- Où ranger l'aventure -->
|
<!-- Où ranger l'aventure -->
|
||||||
@if (step.kind === 'placement') {
|
@if (step.kind === 'placement') {
|
||||||
<fieldset class="placement">
|
<fieldset class="placement">
|
||||||
|
|||||||
@@ -361,3 +361,68 @@
|
|||||||
@media (prefers-reduced-motion: reduce) {
|
@media (prefers-reduced-motion: reduce) {
|
||||||
.progress-fill { transition: none; }
|
.progress-fill { transition: none; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IA : idée de départ et propositions (ne remplit que les champs encore libres).
|
||||||
|
.ai-idea {
|
||||||
|
margin: 0 0 1.25rem;
|
||||||
|
padding: 0.8rem 0.9rem;
|
||||||
|
border: 1px solid rgba(251, 191, 36, 0.3);
|
||||||
|
background: rgba(251, 191, 36, 0.06);
|
||||||
|
border-radius: 10px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.55rem;
|
||||||
|
|
||||||
|
textarea {
|
||||||
|
background: #1f2937;
|
||||||
|
border: 1px solid #374151;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 0.6rem 0.8rem;
|
||||||
|
color: white;
|
||||||
|
font: inherit;
|
||||||
|
resize: vertical;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.ai-idea-label {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.35rem;
|
||||||
|
color: #fde68a;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ai-actions {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-ai, .btn-ai-secondary {
|
||||||
|
padding: 0.45rem 0.9rem;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
cursor: pointer;
|
||||||
|
border: 1px solid rgba(251, 191, 36, 0.45);
|
||||||
|
|
||||||
|
&:disabled { opacity: 0.6; cursor: default; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-ai { background: rgba(251, 191, 36, 0.18); color: #fde68a; font-weight: 600; }
|
||||||
|
.btn-ai-secondary { background: transparent; color: #fde68a; }
|
||||||
|
|
||||||
|
.btn-link {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
color: #a5b4fc;
|
||||||
|
text-decoration: underline;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ai-note { margin: 0; color: #c7d2fe; font-size: 0.85rem; }
|
||||||
|
.ai-error { margin: 0; color: #fca5a5; font-size: 0.85rem; }
|
||||||
|
.ai-hint { margin: 0; color: #9ca3af; font-size: 0.78rem; font-style: italic; }
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { ConfirmDialogService } from '../../../shared/confirm-dialog/confirm-dia
|
|||||||
import { WritingCoachTriggerComponent } from '../../../shared/writing-coach/writing-coach-trigger.component';
|
import { WritingCoachTriggerComponent } from '../../../shared/writing-coach/writing-coach-trigger.component';
|
||||||
import { GuidedAnswers, GuidedDraft, GuidedField, GuidedMethod, GuidedStep, answer } from '../guided-method.model';
|
import { GuidedAnswers, GuidedDraft, GuidedField, GuidedMethod, GuidedStep, answer } from '../guided-method.model';
|
||||||
import { findGuidedMethod } from '../guided-methods';
|
import { findGuidedMethod } from '../guided-methods';
|
||||||
|
import { IDEA_KEY, applySuggestions, buildSuggestRequest, markTouched } from '../guided-assist';
|
||||||
|
|
||||||
/** Clés de réponse réservées à l'assistant (placement + chaînage), communes à toutes les méthodes. */
|
/** Clés de réponse réservées à l'assistant (placement + chaînage), communes à toutes les méthodes. */
|
||||||
const PLACEMENT_MODE = 'placement.mode';
|
const PLACEMENT_MODE = 'placement.mode';
|
||||||
@@ -139,10 +140,82 @@ export class GuidedWizardComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setAnswer(key: string, value: string): void {
|
setAnswer(key: string, value: string): void {
|
||||||
this.answers = { ...this.answers, [key]: value };
|
// Un champ modifié par le MJ ne sera plus jamais remplacé par une proposition de l'IA.
|
||||||
|
this.answers = markTouched({ ...this.answers, [key]: value }, key);
|
||||||
this.saveDraft();
|
this.saveDraft();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- IA : propositions à partir de l'idée de départ ------------------------------------
|
||||||
|
|
||||||
|
/** Proposition en cours (anti double-clic) ; `all` = toute la méthode, sinon l'étape. */
|
||||||
|
suggesting: 'all' | 'step' | null = null;
|
||||||
|
suggestError: string | null = null;
|
||||||
|
/** Nombre de champs remplis par la dernière proposition (message de confirmation). */
|
||||||
|
suggestFilled: number | null = null;
|
||||||
|
/** Réponses avant la dernière proposition : « Annuler » les restaure. */
|
||||||
|
private beforeSuggest: GuidedAnswers | null = null;
|
||||||
|
|
||||||
|
get idea(): string {
|
||||||
|
return this.answers[IDEA_KEY] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
set idea(value: string) {
|
||||||
|
this.answers = { ...this.answers, [IDEA_KEY]: value };
|
||||||
|
this.saveDraft();
|
||||||
|
}
|
||||||
|
|
||||||
|
get canUndoSuggest(): boolean {
|
||||||
|
return this.beforeSuggest !== null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Propose des réponses pour tous les champs encore libres de la méthode. */
|
||||||
|
suggestAll(): void {
|
||||||
|
this.suggest('all');
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Propose des réponses pour les champs encore libres de l'étape affichée. */
|
||||||
|
suggestStep(): void {
|
||||||
|
this.suggest('step');
|
||||||
|
}
|
||||||
|
|
||||||
|
undoSuggest(): void {
|
||||||
|
if (!this.beforeSuggest) return;
|
||||||
|
this.answers = this.beforeSuggest;
|
||||||
|
this.beforeSuggest = null;
|
||||||
|
this.suggestFilled = null;
|
||||||
|
this.saveDraft();
|
||||||
|
}
|
||||||
|
|
||||||
|
private suggest(scope: 'all' | 'step'): void {
|
||||||
|
const method = this.method;
|
||||||
|
if (!method || this.suggesting) return;
|
||||||
|
const t = (key: string) => this.translate.instant(key) as string;
|
||||||
|
const stepIds = scope === 'step' && this.step ? [this.step.id] : undefined;
|
||||||
|
const request = buildSuggestRequest(method, this.answers, t, stepIds);
|
||||||
|
this.suggestError = null;
|
||||||
|
this.suggestFilled = null;
|
||||||
|
if (request.questions.length === 0) {
|
||||||
|
this.suggestFilled = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.suggesting = scope;
|
||||||
|
this.skeletonService.suggest(this.campaignId, request).subscribe({
|
||||||
|
next: ({ answers }) => {
|
||||||
|
const before = this.answers;
|
||||||
|
const result = applySuggestions(method, this.answers, answers ?? {}, t);
|
||||||
|
this.answers = result.answers;
|
||||||
|
this.beforeSuggest = result.filled > 0 ? before : this.beforeSuggest;
|
||||||
|
this.suggestFilled = result.filled;
|
||||||
|
this.suggesting = null;
|
||||||
|
this.saveDraft();
|
||||||
|
},
|
||||||
|
error: () => {
|
||||||
|
this.suggesting = null;
|
||||||
|
this.suggestError = this.translate.instant('guided.ai.error');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/** Placement par défaut + valeurs pré-remplies + premier choix des champs `choice`. */
|
/** Placement par défaut + valeurs pré-remplies + premier choix des champs `choice`. */
|
||||||
private applyDefaults(): void {
|
private applyDefaults(): void {
|
||||||
const a = { ...this.answers };
|
const a = { ...this.answers };
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { GuidedSkeleton, GuidedSkeletonResult } from './guided-skeleton.model';
|
import { GuidedSkeleton, GuidedSkeletonResult } from './guided-skeleton.model';
|
||||||
|
import { GuidedSuggestRequest } from '../campaigns/guided/guided-assist';
|
||||||
|
|
||||||
/** Service HTTP des méthodes guidées (Mentor d'écriture, phase M3). */
|
/** Service HTTP des méthodes guidées (Mentor d'écriture, phase M3). */
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
@@ -12,4 +13,9 @@ export class GuidedSkeletonService {
|
|||||||
create(campaignId: string, skeleton: GuidedSkeleton): Observable<GuidedSkeletonResult> {
|
create(campaignId: string, skeleton: GuidedSkeleton): Observable<GuidedSkeletonResult> {
|
||||||
return this.http.post<GuidedSkeletonResult>(`/api/campaigns/${campaignId}/guided-skeleton`, skeleton);
|
return this.http.post<GuidedSkeletonResult>(`/api/campaigns/${campaignId}/guided-skeleton`, skeleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** IA : réponses proposées aux questions d'une méthode, à partir de l'idée du MJ (rien n'est enregistré). */
|
||||||
|
suggest(campaignId: string, request: GuidedSuggestRequest): Observable<{ answers: Record<string, string> }> {
|
||||||
|
return this.http.post<{ answers: Record<string, string> }>(`/api/campaigns/${campaignId}/guided-assist`, request);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1289,7 +1289,14 @@
|
|||||||
"importFailedReason": "Import failed: {{reason}}",
|
"importFailedReason": "Import failed: {{reason}}",
|
||||||
"importNoRules": "No usable rules could be extracted from this PDF (scan without OCR, or unrecognized content).",
|
"importNoRules": "No usable rules could be extracted from this PDF (scan without OCR, or unrecognized content).",
|
||||||
"importOcrSuffix": " (including {{count}} page(s) via OCR)",
|
"importOcrSuffix": " (including {{count}} page(s) via OCR)",
|
||||||
"importNote": "{{added}} section(s) suggested from {{pages}} page(s){{ocr}}. Review and adjust below before saving."
|
"importNote": "{{added}} section(s) suggested from {{pages}} page(s){{ocr}}. Review and adjust below before saving.",
|
||||||
|
"langTabs": "Rules language",
|
||||||
|
"lang": {
|
||||||
|
"fr": "Français",
|
||||||
|
"en": "English"
|
||||||
|
},
|
||||||
|
"langHint": "Rules exist in two versions: the app and the AI use the one matching the interface language (or the other if it's empty). Importing a PDF fills both, whatever its language.",
|
||||||
|
"importTranslated": "Book in {{source}}: the {{target}} version was translated automatically (proper names kept); review it in its tab."
|
||||||
},
|
},
|
||||||
"ollamaModelManager": {
|
"ollamaModelManager": {
|
||||||
"installedModels": "Installed models",
|
"installedModels": "Installed models",
|
||||||
@@ -2613,7 +2620,7 @@
|
|||||||
"tagline": "A short adventure in five beats in a single place: a guardian, a challenge, a setback, the climax, the reward."
|
"tagline": "A short adventure in five beats in a single place: a guardian, a challenge, a setback, the climax, the reward."
|
||||||
},
|
},
|
||||||
"chooserTitle": "Write with a guided method",
|
"chooserTitle": "Write with a guided method",
|
||||||
"chooserIntro": "Pick a structure: the wizard asks you the right questions, step by step, then creates the chapter and its scenes. You write everything; nothing is generated.",
|
"chooserIntro": "Pick a structure: the wizard asks you the right questions, step by step, then creates the chapter and its scenes. You can write everything yourself, or start from an idea and let the AI suggest answers that you then edit.",
|
||||||
"chooserStart": "Start",
|
"chooserStart": "Start",
|
||||||
"chooserScenes": "{{count}} scenes",
|
"chooserScenes": "{{count}} scenes",
|
||||||
"reviewClock": "A \"{{name}}\" clock with {{segments}} segments will be created in each playthrough of the campaign.",
|
"reviewClock": "A \"{{name}}\" clock with {{segments}} segments will be created in each playthrough of the campaign.",
|
||||||
@@ -3113,6 +3120,18 @@
|
|||||||
},
|
},
|
||||||
"clockName": "The enemy's plan"
|
"clockName": "The enemy's plan"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"ai": {
|
||||||
|
"title": "Your starting idea",
|
||||||
|
"placeholder": "A few words are enough: a tower lighting up again, a forgotten pact, an autumn fair…",
|
||||||
|
"suggestAll": "Suggest the whole adventure",
|
||||||
|
"suggestStep": "Suggest for this step",
|
||||||
|
"thinking": "The AI is thinking…",
|
||||||
|
"undo": "Undo the suggestion",
|
||||||
|
"filled": "{{count}} field(s) filled by the AI: read them and change what you don't like.",
|
||||||
|
"nothingToFill": "Every field is already filled: clear the ones you want the AI to suggest.",
|
||||||
|
"error": "The AI didn't answer. Check the AI engine in Settings, then try again.",
|
||||||
|
"hint": "The AI only fills empty fields: it never touches what you wrote."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"remoteAccess": {
|
"remoteAccess": {
|
||||||
|
|||||||
@@ -1289,7 +1289,14 @@
|
|||||||
"importFailedReason": "Échec de l'import : {{reason}}",
|
"importFailedReason": "Échec de l'import : {{reason}}",
|
||||||
"importNoRules": "Aucune règle exploitable n'a été extraite de ce PDF (scan sans OCR, ou contenu non reconnu).",
|
"importNoRules": "Aucune règle exploitable n'a été extraite de ce PDF (scan sans OCR, ou contenu non reconnu).",
|
||||||
"importOcrSuffix": " (dont {{count}} page(s) via OCR)",
|
"importOcrSuffix": " (dont {{count}} page(s) via OCR)",
|
||||||
"importNote": "{{added}} section(s) proposée(s) depuis {{pages}} page(s){{ocr}}. Relisez et ajustez ci-dessous avant d'enregistrer."
|
"importNote": "{{added}} section(s) proposée(s) depuis {{pages}} page(s){{ocr}}. Relisez et ajustez ci-dessous avant d'enregistrer.",
|
||||||
|
"langTabs": "Langue des règles",
|
||||||
|
"lang": {
|
||||||
|
"fr": "Français",
|
||||||
|
"en": "English"
|
||||||
|
},
|
||||||
|
"langHint": "Les règles existent en deux versions : l'appli et l'IA utilisent celle de la langue de l'interface (ou l'autre si elle est vide). Importer un PDF remplit les deux, dans n'importe quelle langue.",
|
||||||
|
"importTranslated": "Livre en {{source}} : version {{target}} traduite automatiquement (noms propres conservés), relis-la dans son onglet."
|
||||||
},
|
},
|
||||||
"ollamaModelManager": {
|
"ollamaModelManager": {
|
||||||
"installedModels": "Modèles installés",
|
"installedModels": "Modèles installés",
|
||||||
@@ -2613,7 +2620,7 @@
|
|||||||
"tagline": "Une aventure courte en cinq temps dans un même lieu : un gardien, une épreuve, un revers, le climax, la récompense."
|
"tagline": "Une aventure courte en cinq temps dans un même lieu : un gardien, une épreuve, un revers, le climax, la récompense."
|
||||||
},
|
},
|
||||||
"chooserTitle": "Écrire avec une méthode guidée",
|
"chooserTitle": "Écrire avec une méthode guidée",
|
||||||
"chooserIntro": "Choisissez une structure : l'assistant vous pose les bonnes questions, étape par étape, puis crée le chapitre et ses scènes. Vous écrivez tout ; rien n'est généré.",
|
"chooserIntro": "Choisissez une structure : l'assistant vous pose les bonnes questions, étape par étape, puis crée le chapitre et ses scènes. Vous pouvez tout écrire vous-même, ou partir d'une idée et laisser l'IA proposer des réponses que vous corrigez.",
|
||||||
"chooserStart": "Commencer",
|
"chooserStart": "Commencer",
|
||||||
"chooserScenes": "{{count}} scènes",
|
"chooserScenes": "{{count}} scènes",
|
||||||
"reviewClock": "Une horloge « {{name}} » de {{segments}} segments sera créée dans chaque partie de la campagne.",
|
"reviewClock": "Une horloge « {{name}} » de {{segments}} segments sera créée dans chaque partie de la campagne.",
|
||||||
@@ -3113,6 +3120,18 @@
|
|||||||
},
|
},
|
||||||
"clockName": "Le plan de l'adversaire"
|
"clockName": "Le plan de l'adversaire"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"ai": {
|
||||||
|
"title": "Ton idée de départ",
|
||||||
|
"placeholder": "Quelques mots suffisent : une tour qui se rallume, un pacte oublié, une foire d'automne…",
|
||||||
|
"suggestAll": "Proposer toute l'aventure",
|
||||||
|
"suggestStep": "Proposer pour cette étape",
|
||||||
|
"thinking": "L'IA réfléchit…",
|
||||||
|
"undo": "Annuler la proposition",
|
||||||
|
"filled": "{{count}} champ(s) rempli(s) par l'IA : relis-les et corrige ce qui ne te plaît pas.",
|
||||||
|
"nothingToFill": "Tous les champs sont déjà remplis : vide ceux que tu veux faire proposer par l'IA.",
|
||||||
|
"error": "L'IA n'a pas répondu. Vérifie le moteur IA dans les Paramètres, puis réessaie.",
|
||||||
|
"hint": "L'IA ne remplit que les champs vides : elle ne touche jamais à ce que tu as écrit."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"remoteAccess": {
|
"remoteAccess": {
|
||||||
|
|||||||
@@ -234,7 +234,7 @@
|
|||||||
"tagline": "A short adventure in five beats in a single place: a guardian, a challenge, a setback, the climax, the reward."
|
"tagline": "A short adventure in five beats in a single place: a guardian, a challenge, a setback, the climax, the reward."
|
||||||
},
|
},
|
||||||
"chooserTitle": "Write with a guided method",
|
"chooserTitle": "Write with a guided method",
|
||||||
"chooserIntro": "Pick a structure: the wizard asks you the right questions, step by step, then creates the chapter and its scenes. You write everything; nothing is generated.",
|
"chooserIntro": "Pick a structure: the wizard asks you the right questions, step by step, then creates the chapter and its scenes. You can write everything yourself, or start from an idea and let the AI suggest answers that you then edit.",
|
||||||
"chooserStart": "Start",
|
"chooserStart": "Start",
|
||||||
"chooserScenes": "{{count}} scenes",
|
"chooserScenes": "{{count}} scenes",
|
||||||
"reviewClock": "A \"{{name}}\" clock with {{segments}} segments will be created in each playthrough of the campaign.",
|
"reviewClock": "A \"{{name}}\" clock with {{segments}} segments will be created in each playthrough of the campaign.",
|
||||||
@@ -734,6 +734,18 @@
|
|||||||
},
|
},
|
||||||
"clockName": "The enemy's plan"
|
"clockName": "The enemy's plan"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"ai": {
|
||||||
|
"title": "Your starting idea",
|
||||||
|
"placeholder": "A few words are enough: a tower lighting up again, a forgotten pact, an autumn fair…",
|
||||||
|
"suggestAll": "Suggest the whole adventure",
|
||||||
|
"suggestStep": "Suggest for this step",
|
||||||
|
"thinking": "The AI is thinking…",
|
||||||
|
"undo": "Undo the suggestion",
|
||||||
|
"filled": "{{count}} field(s) filled by the AI: read them and change what you don't like.",
|
||||||
|
"nothingToFill": "Every field is already filled: clear the ones you want the AI to suggest.",
|
||||||
|
"error": "The AI didn't answer. Check the AI engine in Settings, then try again.",
|
||||||
|
"hint": "The AI only fills empty fields: it never touches what you wrote."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -234,7 +234,7 @@
|
|||||||
"tagline": "Une aventure courte en cinq temps dans un même lieu : un gardien, une épreuve, un revers, le climax, la récompense."
|
"tagline": "Une aventure courte en cinq temps dans un même lieu : un gardien, une épreuve, un revers, le climax, la récompense."
|
||||||
},
|
},
|
||||||
"chooserTitle": "Écrire avec une méthode guidée",
|
"chooserTitle": "Écrire avec une méthode guidée",
|
||||||
"chooserIntro": "Choisissez une structure : l'assistant vous pose les bonnes questions, étape par étape, puis crée le chapitre et ses scènes. Vous écrivez tout ; rien n'est généré.",
|
"chooserIntro": "Choisissez une structure : l'assistant vous pose les bonnes questions, étape par étape, puis crée le chapitre et ses scènes. Vous pouvez tout écrire vous-même, ou partir d'une idée et laisser l'IA proposer des réponses que vous corrigez.",
|
||||||
"chooserStart": "Commencer",
|
"chooserStart": "Commencer",
|
||||||
"chooserScenes": "{{count}} scènes",
|
"chooserScenes": "{{count}} scènes",
|
||||||
"reviewClock": "Une horloge « {{name}} » de {{segments}} segments sera créée dans chaque partie de la campagne.",
|
"reviewClock": "Une horloge « {{name}} » de {{segments}} segments sera créée dans chaque partie de la campagne.",
|
||||||
@@ -734,6 +734,18 @@
|
|||||||
},
|
},
|
||||||
"clockName": "Le plan de l'adversaire"
|
"clockName": "Le plan de l'adversaire"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"ai": {
|
||||||
|
"title": "Ton idée de départ",
|
||||||
|
"placeholder": "Quelques mots suffisent : une tour qui se rallume, un pacte oublié, une foire d'automne…",
|
||||||
|
"suggestAll": "Proposer toute l'aventure",
|
||||||
|
"suggestStep": "Proposer pour cette étape",
|
||||||
|
"thinking": "L'IA réfléchit…",
|
||||||
|
"undo": "Annuler la proposition",
|
||||||
|
"filled": "{{count}} champ(s) rempli(s) par l'IA : relis-les et corrige ce qui ne te plaît pas.",
|
||||||
|
"nothingToFill": "Tous les champs sont déjà remplis : vide ceux que tu veux faire proposer par l'IA.",
|
||||||
|
"error": "L'IA n'a pas répondu. Vérifie le moteur IA dans les Paramètres, puis réessaie.",
|
||||||
|
"hint": "L'IA ne remplit que les champs vides : elle ne touche jamais à ce que tu as écrit."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user