feat(chatbot): toggle de mode branché sur les 5 interfaces chatbot
Placeholder (/ et /agences desktop), Sheet (/ mobile), Réseaux (/agences mobile), chatbot de /trouver-du-taf et Pensées (/media) envoient `profondeur` dans le body et l'enregistrent sur chaque message (badge conservé à la restauration). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015vcVGz8i4WpZm2dixKUiSD
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
4c57f30f6a
commit
52b79e1e8e
@@ -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">
|
||||
@@ -279,6 +282,11 @@
|
||||
<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 -->
|
||||
<div class="taff-chat-input-wrap">
|
||||
<textarea
|
||||
@@ -583,6 +591,7 @@ 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
|
||||
}
|
||||
@@ -593,6 +602,7 @@ const chatOpen = ref(false)
|
||||
const chatInput = ref('')
|
||||
const chatLoading = ref(false)
|
||||
const { messages: chatMessages, hasHistory: chatHasHistory, clear: clearChat } = useChatSession<ChatMessage>('taff')
|
||||
const chatProfondeur = useChatProfondeur('taff')
|
||||
const chatMessagesEl = ref<HTMLElement | null>(null)
|
||||
|
||||
async function sendChat() {
|
||||
@@ -601,17 +611,19 @@ 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.', transient: true })
|
||||
@@ -972,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