merge: feat/aep-b1-chatbot — checkpoint AEP (intégration du 22/10)
This commit is contained in:
@@ -58,6 +58,17 @@
|
||||
<!-- Chatbot sous la carte (ordinateur) -->
|
||||
<div v-if="vf.etat.sousVue !== 'outremer'" class="hidden lg:block shrink-0">
|
||||
<ChatbotPlaceholder
|
||||
endpoint="/api/chatbot-reseaux"
|
||||
chat-key="agences"
|
||||
titre="Assistant Réseaux AEP"
|
||||
placeholder-replie="Pose une question sur les structures et agences du réseau…"
|
||||
placeholder-saisie="Décris ta situation…"
|
||||
intro="Je connais les 120 réseaux, collectifs et agences cartographiés dans AEP — ceux qui portent une vision écologique et politique de l'architecture. Décris ta situation : tu cherches un collectif, une agence inspirante, un partenaire sur un projet ?"
|
||||
exemple="Exemple : « Quelles agences travaillent sur le réemploi ? »"
|
||||
fiches-titre="Structures recommandées :"
|
||||
fiche-lien-modele="/agences#{id}"
|
||||
rendre-markdown
|
||||
message-limite="Limite de 20 questions par jour atteinte."
|
||||
@highlightOrgs="() => {}"
|
||||
@applyHashtag="(tag) => vf.ajouterFiltre('tags', sansDiese(tag))"
|
||||
/>
|
||||
|
||||
@@ -254,8 +254,11 @@
|
||||
<!-- Messages de la conversation -->
|
||||
<template v-for="(msg, i) in chatMessages" :key="i">
|
||||
<div :class="['taff-msg', msg.role === 'user' ? 'taff-msg--user' : 'taff-msg--bot']">
|
||||
<div v-if="msg.role === 'bot'" class="md-content" v-html="renderMd(msg.content)" />
|
||||
<span v-else>{{ msg.content }}</span>
|
||||
<template v-if="msg.role === 'bot'">
|
||||
<ChatModeBadge :profondeur="msg.profondeur" />
|
||||
<div class="md-content" v-html="renderMd(msg.content)" />
|
||||
</template>
|
||||
<span v-if="msg.role !== 'bot'">{{ msg.content }}</span>
|
||||
</div>
|
||||
<!-- Plateformes recommandées -->
|
||||
<div v-if="msg.role === 'bot' && msg.recommandations?.length" class="taff-chat-recos">
|
||||
@@ -275,6 +278,13 @@
|
||||
<div v-if="chatLoading" class="taff-msg taff-msg--bot">
|
||||
<span class="taff-typing"><span/><span/><span/></span>
|
||||
</div>
|
||||
|
||||
<ChatNewConversation v-if="chatHasHistory && !chatLoading" @reset="clearChat" />
|
||||
</div>
|
||||
|
||||
<!-- Mode de réponse -->
|
||||
<div class="taff-chat-mode">
|
||||
<ChatModeToggle v-model="chatProfondeur" :disabled="chatLoading" />
|
||||
</div>
|
||||
|
||||
<!-- Input -->
|
||||
@@ -581,6 +591,9 @@ interface ChatMessage {
|
||||
role: 'user' | 'bot'
|
||||
content: string
|
||||
recommandations?: { id: string; nom: string; raison: string }[]
|
||||
profondeur?: string
|
||||
/** Message d'erreur : affiché mais jamais persisté */
|
||||
transient?: boolean
|
||||
}
|
||||
|
||||
const { render: renderMd } = useMarkdown()
|
||||
@@ -588,7 +601,8 @@ const { render: renderMd } = useMarkdown()
|
||||
const chatOpen = ref(false)
|
||||
const chatInput = ref('')
|
||||
const chatLoading = ref(false)
|
||||
const chatMessages = ref<ChatMessage[]>([])
|
||||
const { messages: chatMessages, hasHistory: chatHasHistory, clear: clearChat } = useChatSession<ChatMessage>('taff')
|
||||
const chatProfondeur = useChatProfondeur('taff')
|
||||
const chatMessagesEl = ref<HTMLElement | null>(null)
|
||||
|
||||
async function sendChat() {
|
||||
@@ -597,20 +611,22 @@ async function sendChat() {
|
||||
chatMessages.value.push({ role: 'user', content: q })
|
||||
chatInput.value = ''
|
||||
chatLoading.value = true
|
||||
const mode = chatProfondeur.value
|
||||
await nextTick()
|
||||
chatMessagesEl.value?.scrollTo({ top: chatMessagesEl.value.scrollHeight, behavior: 'smooth' })
|
||||
try {
|
||||
const res = await $fetch<{ reponse_texte: string; plateformes_recommandees: { id: string; nom: string; raison: string }[] }>(
|
||||
'/api/chatbot-taff',
|
||||
{ method: 'POST', body: { question: q } }
|
||||
{ method: 'POST', body: { question: q, profondeur: mode } }
|
||||
)
|
||||
chatMessages.value.push({
|
||||
role: 'bot',
|
||||
content: res.reponse_texte,
|
||||
recommandations: res.plateformes_recommandees ?? [],
|
||||
profondeur: mode,
|
||||
})
|
||||
} catch (e: any) {
|
||||
chatMessages.value.push({ role: 'bot', content: e?.data?.statusMessage ?? 'Erreur — réessaie dans un instant.' })
|
||||
chatMessages.value.push({ role: 'bot', content: e?.data?.statusMessage ?? 'Erreur — réessaie dans un instant.', transient: true })
|
||||
} finally {
|
||||
chatLoading.value = false
|
||||
await nextTick()
|
||||
@@ -968,6 +984,8 @@ const parsedDescription = computed(() => {
|
||||
40% { transform: translateY(-5px); opacity: 1; }
|
||||
}
|
||||
|
||||
.taff-chat-mode { padding: 0.5rem 1rem 0; }
|
||||
|
||||
.taff-chat-input-wrap {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
|
||||
Reference in New Issue
Block a user