Spaces:
Sleeping
Sleeping
Commit
·
2587ccc
1
Parent(s):
59ee354
fix: remove max_token param
Browse files
backend/ai_service.py
CHANGED
|
@@ -45,7 +45,14 @@ Ton narratif: {narrative_tone}
|
|
| 45 |
Pièces: {', '.join(rooms)}
|
| 46 |
Personnages: {', '.join(characters)}
|
| 47 |
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
# Run with timeout
|
| 51 |
response = await asyncio.wait_for(
|
|
@@ -95,8 +102,15 @@ IMPORTANT: Desland est SARCASTIQUE et INCISIF. Il se moque des théories absurde
|
|
| 95 |
- "Une capsule de café comme arme du crime ? Brillant. Je suppose qu'il l'a noyé dans un expresso."
|
| 96 |
- "Ah oui, très crédible. Le meurtrier qui laisse traîner son arme préférée dans la salle de bain. Excellent travail, détective."
|
| 97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
Ton narratif: {narrative_tone}
|
| 99 |
-
Sois sarcastique, condescendant et incisif. Moque la logique (ou l'absence de logique) de la suggestion."""
|
| 100 |
|
| 101 |
print(f"[AI Service] Calling OpenAI API...")
|
| 102 |
response = await asyncio.wait_for(
|
|
@@ -145,7 +159,14 @@ Ton narratif: {narrative_tone}
|
|
| 145 |
Si correcte: Desland est surpris et impressionné à contrecœur (mais toujours sarcastique).
|
| 146 |
Si fausse: Desland est condescendant et moqueur à propos de leur échec.
|
| 147 |
|
| 148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
|
| 150 |
response = await asyncio.wait_for(
|
| 151 |
asyncio.to_thread(self._generate_text, prompt), timeout=10.0
|
|
@@ -205,6 +226,7 @@ Sois sarcastique, minimise la victoire, suggère que c'était de la chance."""
|
|
| 205 |
return None
|
| 206 |
except Exception as e:
|
| 207 |
import traceback
|
|
|
|
| 208 |
print(f"[AI Service] Error generating victory comment: {e}")
|
| 209 |
print(traceback.format_exc())
|
| 210 |
return None
|
|
@@ -238,12 +260,20 @@ Exemples de ton style:
|
|
| 238 |
"Une capsule de café ? Brillant. Parce que évidemment, on commet des meurtres avec du Nespresso maintenant."
|
| 239 |
"Ah oui, excellente déduction Sherlock. Prochaine étape : accuser le chat du voisin."
|
| 240 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
Garde tes réponses brèves (1 phrase pour les commentaires, 2-3 pour les scénarios), EN FRANÇAIS, sarcastiques et mémorables.""",
|
| 242 |
},
|
| 243 |
{"role": "user", "content": prompt},
|
| 244 |
],
|
| 245 |
temperature=0.9,
|
| 246 |
-
max_tokens=150,
|
| 247 |
)
|
| 248 |
|
| 249 |
print(
|
|
|
|
| 45 |
Pièces: {', '.join(rooms)}
|
| 46 |
Personnages: {', '.join(characters)}
|
| 47 |
|
| 48 |
+
VOCABULAIRE À UTILISER (subtilement):
|
| 49 |
+
- "poupouille/péchailloux/tchoupinoux" = petit coquin
|
| 50 |
+
- "chnawax masqué" = vilain coquinou
|
| 51 |
+
- "armankaboul/Fourlestourtes" = bordel !
|
| 52 |
+
- "Koikoubaiseyyyyy" = surprise !
|
| 53 |
+
- "En alicrampté les coicoubaca sont de sortie" = il va y avoir du grabuge
|
| 54 |
+
|
| 55 |
+
COMMENCE obligatoirement par Desland se trompant sur son nom, puis introduis le meurtre avec son ton sarcastique et suspect caractéristique. Moque subtilement la situation et l'intelligence des enquêteurs. Utilise subtilement 1-2 expressions du vocabulaire."""
|
| 56 |
|
| 57 |
# Run with timeout
|
| 58 |
response = await asyncio.wait_for(
|
|
|
|
| 102 |
- "Une capsule de café comme arme du crime ? Brillant. Je suppose qu'il l'a noyé dans un expresso."
|
| 103 |
- "Ah oui, très crédible. Le meurtrier qui laisse traîner son arme préférée dans la salle de bain. Excellent travail, détective."
|
| 104 |
|
| 105 |
+
VOCABULAIRE À UTILISER (subtilement):
|
| 106 |
+
- "poupouille/péchailloux/tchoupinoux" = petit coquin
|
| 107 |
+
- "chnawax masqué" = vilain coquinou
|
| 108 |
+
- "armankaboul" = bordel !
|
| 109 |
+
- "All RS5, erreur réseau" = il y a erreur
|
| 110 |
+
- "Une poupée en pénitence calisse de sibouere" = quelque chose de bizarre
|
| 111 |
+
|
| 112 |
Ton narratif: {narrative_tone}
|
| 113 |
+
Sois sarcastique, condescendant et incisif. Moque la logique (ou l'absence de logique) de la suggestion. Utilise subtilement 1 expression du vocabulaire si approprié."""
|
| 114 |
|
| 115 |
print(f"[AI Service] Calling OpenAI API...")
|
| 116 |
response = await asyncio.wait_for(
|
|
|
|
| 159 |
Si correcte: Desland est surpris et impressionné à contrecœur (mais toujours sarcastique).
|
| 160 |
Si fausse: Desland est condescendant et moqueur à propos de leur échec.
|
| 161 |
|
| 162 |
+
VOCABULAIRE À UTILISER (subtilement):
|
| 163 |
+
- "poupouille/péchailloux/tchoupinoux" = petit coquin
|
| 164 |
+
- "chnawax masqué" = vilain coquinou
|
| 165 |
+
- "armankaboul/Fourlestourtes" = bordel !
|
| 166 |
+
- "Koikoubaiseyyyyy" = surprise !
|
| 167 |
+
- "All RS5, erreur réseau" = il y a erreur
|
| 168 |
+
|
| 169 |
+
Rends-le incisif et mémorable. Utilise subtilement 1 expression du vocabulaire si approprié."""
|
| 170 |
|
| 171 |
response = await asyncio.wait_for(
|
| 172 |
asyncio.to_thread(self._generate_text, prompt), timeout=10.0
|
|
|
|
| 226 |
return None
|
| 227 |
except Exception as e:
|
| 228 |
import traceback
|
| 229 |
+
|
| 230 |
print(f"[AI Service] Error generating victory comment: {e}")
|
| 231 |
print(traceback.format_exc())
|
| 232 |
return None
|
|
|
|
| 260 |
"Une capsule de café ? Brillant. Parce que évidemment, on commet des meurtres avec du Nespresso maintenant."
|
| 261 |
"Ah oui, excellente déduction Sherlock. Prochaine étape : accuser le chat du voisin."
|
| 262 |
|
| 263 |
+
VOCABULAIRE SPÉCIAL (utilise subtilement 1-2 expressions):
|
| 264 |
+
- "poupouille/péchailloux/tchoupinoux" = petit coquin
|
| 265 |
+
- "chnawax masqué" = vilain coquinou
|
| 266 |
+
- "armankaboul/Fourlestourtes et les bourbillats" = bordel !
|
| 267 |
+
- "Koikoubaiseyyyyy/triple monstre coucouuuuu" = surprise !
|
| 268 |
+
- "All RS5, erreur réseau" = il y a erreur
|
| 269 |
+
- "poupée en pénitence calisse de sibouere" = quelque chose de bizarre
|
| 270 |
+
- "En alicrampté les coicoubaca sont de sortie" = il va y avoir du grabuge
|
| 271 |
+
|
| 272 |
Garde tes réponses brèves (1 phrase pour les commentaires, 2-3 pour les scénarios), EN FRANÇAIS, sarcastiques et mémorables.""",
|
| 273 |
},
|
| 274 |
{"role": "user", "content": prompt},
|
| 275 |
],
|
| 276 |
temperature=0.9,
|
|
|
|
| 277 |
)
|
| 278 |
|
| 279 |
print(
|
frontend/src/components/InvestigationGrid.jsx
CHANGED
|
@@ -9,7 +9,6 @@ function InvestigationGrid({ suspects, weapons, rooms, myCards }) {
|
|
| 9 |
const initialNotes = saved ? JSON.parse(saved) : {}
|
| 10 |
|
| 11 |
// Initialize all items as 'unknown' if not already set
|
| 12 |
-
// This ensures cards not in my hand have a default status
|
| 13 |
const allItems = [
|
| 14 |
...(suspects?.map(s => ({ name: s, type: 'character' })) || []),
|
| 15 |
...(weapons?.map(w => ({ name: w, type: 'weapon' })) || []),
|
|
@@ -18,14 +17,22 @@ function InvestigationGrid({ suspects, weapons, rooms, myCards }) {
|
|
| 18 |
|
| 19 |
allItems.forEach(item => {
|
| 20 |
const key = `${item.type}:${item.name}`
|
| 21 |
-
//
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
initialNotes[key] = 'unknown'
|
| 24 |
}
|
| 25 |
})
|
| 26 |
|
| 27 |
setNotes(initialNotes)
|
| 28 |
-
}, [suspects, weapons, rooms])
|
| 29 |
|
| 30 |
// Save notes to localStorage
|
| 31 |
useEffect(() => {
|
|
@@ -33,6 +40,15 @@ function InvestigationGrid({ suspects, weapons, rooms, myCards }) {
|
|
| 33 |
}, [notes])
|
| 34 |
|
| 35 |
const toggleNote = (item, type) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
const key = `${type}:${item}`
|
| 37 |
setNotes(prev => {
|
| 38 |
const current = prev[key] || 'unknown'
|
|
@@ -61,6 +77,22 @@ function InvestigationGrid({ suspects, weapons, rooms, myCards }) {
|
|
| 61 |
return '⬜'
|
| 62 |
}
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
return (
|
| 65 |
<div className="bg-black/60 backdrop-blur-md p-6 rounded-lg border-2 border-haunted-shadow">
|
| 66 |
<h2 className="text-xl font-bold text-haunted-blood mb-4 animate-flicker">📋 Grille d'Enquête</h2>
|
|
@@ -74,7 +106,7 @@ function InvestigationGrid({ suspects, weapons, rooms, myCards }) {
|
|
| 74 |
<button
|
| 75 |
key={i}
|
| 76 |
onClick={() => toggleNote(suspect, 'character')}
|
| 77 |
-
className=
|
| 78 |
>
|
| 79 |
<span className="text-lg">{getIcon(suspect, 'character')}</span>
|
| 80 |
<span className="flex-1 truncate">{suspect}</span>
|
|
@@ -91,7 +123,7 @@ function InvestigationGrid({ suspects, weapons, rooms, myCards }) {
|
|
| 91 |
<button
|
| 92 |
key={i}
|
| 93 |
onClick={() => toggleNote(weapon, 'weapon')}
|
| 94 |
-
className=
|
| 95 |
>
|
| 96 |
<span className="text-lg">{getIcon(weapon, 'weapon')}</span>
|
| 97 |
<span className="flex-1 truncate">{weapon}</span>
|
|
@@ -108,7 +140,7 @@ function InvestigationGrid({ suspects, weapons, rooms, myCards }) {
|
|
| 108 |
<button
|
| 109 |
key={i}
|
| 110 |
onClick={() => toggleNote(room, 'room')}
|
| 111 |
-
className=
|
| 112 |
>
|
| 113 |
<span className="text-lg">{getIcon(room, 'room')}</span>
|
| 114 |
<span className="flex-1 truncate">{room}</span>
|
|
|
|
| 9 |
const initialNotes = saved ? JSON.parse(saved) : {}
|
| 10 |
|
| 11 |
// Initialize all items as 'unknown' if not already set
|
|
|
|
| 12 |
const allItems = [
|
| 13 |
...(suspects?.map(s => ({ name: s, type: 'character' })) || []),
|
| 14 |
...(weapons?.map(w => ({ name: w, type: 'weapon' })) || []),
|
|
|
|
| 17 |
|
| 18 |
allItems.forEach(item => {
|
| 19 |
const key = `${item.type}:${item.name}`
|
| 20 |
+
// Check if this is one of my cards
|
| 21 |
+
const isMyCard = myCards?.some(card =>
|
| 22 |
+
card.name === item.name && card.type === item.type
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
if (isMyCard) {
|
| 26 |
+
// Always mark my cards as 'mine' (locked)
|
| 27 |
+
initialNotes[key] = 'mine'
|
| 28 |
+
} else if (!(key in initialNotes)) {
|
| 29 |
+
// Only set to unknown if not already tracked
|
| 30 |
initialNotes[key] = 'unknown'
|
| 31 |
}
|
| 32 |
})
|
| 33 |
|
| 34 |
setNotes(initialNotes)
|
| 35 |
+
}, [suspects, weapons, rooms, myCards])
|
| 36 |
|
| 37 |
// Save notes to localStorage
|
| 38 |
useEffect(() => {
|
|
|
|
| 40 |
}, [notes])
|
| 41 |
|
| 42 |
const toggleNote = (item, type) => {
|
| 43 |
+
// Check if this is one of my cards - if so, don't allow toggling
|
| 44 |
+
const isMyCard = myCards?.some(card =>
|
| 45 |
+
card.name === item && card.type === type
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
if (isMyCard) {
|
| 49 |
+
return // Can't change status of my own cards
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
const key = `${type}:${item}`
|
| 53 |
setNotes(prev => {
|
| 54 |
const current = prev[key] || 'unknown'
|
|
|
|
| 77 |
return '⬜'
|
| 78 |
}
|
| 79 |
|
| 80 |
+
const getButtonClasses = (item, type) => {
|
| 81 |
+
const isMyCard = myCards?.some(card =>
|
| 82 |
+
card.name === item && card.type === type
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
+
const baseClasses = "flex items-center gap-2 px-3 py-2 rounded text-left text-sm border transition-all"
|
| 86 |
+
|
| 87 |
+
if (isMyCard) {
|
| 88 |
+
// Grayed out and locked for my cards
|
| 89 |
+
return `${baseClasses} bg-haunted-purple/20 text-haunted-fog/50 border-haunted-purple/40 cursor-not-allowed opacity-70`
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
// Normal interactive style for other cards
|
| 93 |
+
return `${baseClasses} bg-black/40 text-haunted-fog border-haunted-shadow hover:border-haunted-blood/50`
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
return (
|
| 97 |
<div className="bg-black/60 backdrop-blur-md p-6 rounded-lg border-2 border-haunted-shadow">
|
| 98 |
<h2 className="text-xl font-bold text-haunted-blood mb-4 animate-flicker">📋 Grille d'Enquête</h2>
|
|
|
|
| 106 |
<button
|
| 107 |
key={i}
|
| 108 |
onClick={() => toggleNote(suspect, 'character')}
|
| 109 |
+
className={getButtonClasses(suspect, 'character')}
|
| 110 |
>
|
| 111 |
<span className="text-lg">{getIcon(suspect, 'character')}</span>
|
| 112 |
<span className="flex-1 truncate">{suspect}</span>
|
|
|
|
| 123 |
<button
|
| 124 |
key={i}
|
| 125 |
onClick={() => toggleNote(weapon, 'weapon')}
|
| 126 |
+
className={getButtonClasses(weapon, 'weapon')}
|
| 127 |
>
|
| 128 |
<span className="text-lg">{getIcon(weapon, 'weapon')}</span>
|
| 129 |
<span className="flex-1 truncate">{weapon}</span>
|
|
|
|
| 140 |
<button
|
| 141 |
key={i}
|
| 142 |
onClick={() => toggleNote(room, 'room')}
|
| 143 |
+
className={getButtonClasses(room, 'room')}
|
| 144 |
>
|
| 145 |
<span className="text-lg">{getIcon(room, 'room')}</span>
|
| 146 |
<span className="flex-1 truncate">{room}</span>
|