Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48f929a8f3 | ||
|
|
fd82d77709 | ||
|
|
189a2e4bf6 | ||
|
|
e322435bd8 |
No files matched your search
+10
-3
@@ -143,14 +143,21 @@ def get_messages(project_id: int, db: Session = Depends(get_db), current_user: U
|
||||
|
||||
@app.post("/api/projects/{project_id}/messages", response_model=List[MessageResponse])
|
||||
async def create_message(project_id: int, message: MessageCreate, db: Session = Depends(get_db), current_user: User = Depends(get_current_user)):
|
||||
db.add(Message(role=message.role, content=message.content, project_id=project_id)); db.commit()
|
||||
final_content = message.content
|
||||
if message.file_content and message.file_name:
|
||||
final_content = f"[Fichier attaché : {message.file_name}]\n```\n{message.file_content}\n```\n\n{message.content}"
|
||||
|
||||
db.add(Message(role=message.role, content=final_content, project_id=project_id))
|
||||
db.commit()
|
||||
|
||||
history = db.query(Message).filter(Message.project_id == project_id).order_by(Message.created_at.asc()).all()
|
||||
settings = db.query(SystemSettings).first()
|
||||
conf = message.config.dict() if message.config else {"workers": ["gemini-3.5-flash-lite"]}
|
||||
|
||||
ai_resp = await run_orchestrator(db, history, settings, conf) # Transmission de DB
|
||||
ai_resp = await run_orchestrator(db, history, settings, conf)
|
||||
|
||||
db.add(Message(role="assistant", content=ai_resp, project_id=project_id)); db.commit()
|
||||
db.add(Message(role="assistant", content=ai_resp, project_id=project_id))
|
||||
db.commit()
|
||||
return db.query(Message).filter(Message.project_id == project_id).order_by(Message.created_at.asc()).all()
|
||||
|
||||
# --- ROUTES MODÈLES & FINANCES ---
|
||||
|
||||
@@ -50,6 +50,8 @@ class MessageBase(BaseModel):
|
||||
|
||||
class MessageCreate(MessageBase):
|
||||
config: Optional[OrchestratorConfig] = None
|
||||
file_content: Optional[str] = None
|
||||
file_name: Optional[str] = None
|
||||
|
||||
class MessageResponse(MessageBase):
|
||||
id: int
|
||||
|
||||
+237
-98
@@ -23,7 +23,7 @@
|
||||
|
||||
<div id="app" class="flex w-full h-full relative bg-aethas-dark">
|
||||
|
||||
<!-- MODAL PARAMÈTRES (Sécurité) -->
|
||||
<!-- MODAL PARAMÈTRES -->
|
||||
<div v-if="isSettingsModalOpen" class="fixed inset-0 bg-black/80 z-[100] flex items-center justify-center p-4">
|
||||
<div class="bg-aethas-panel border border-gray-600 rounded-2xl w-full max-w-md overflow-hidden shadow-[0_0_30px_rgba(0,0,0,0.7)]">
|
||||
<div class="p-4 border-b border-gray-700 flex justify-between items-center bg-gray-800/50">
|
||||
@@ -63,7 +63,7 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 overflow-y-auto p-4 space-y-6">
|
||||
<div class="flex-1 overflow-y-auto p-4 space-y-6 custom-scrollbar">
|
||||
<div v-if="pinnedProjects.length > 0">
|
||||
<h3 class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2">Épinglés</h3>
|
||||
<ul class="space-y-1">
|
||||
@@ -91,7 +91,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- NOUVEAU : ENCART FINANCIER SOUS LE MENU RÉCENTS -->
|
||||
<!-- ENCART FINANCIER -->
|
||||
<div class="px-4 pb-2 border-b border-gray-700">
|
||||
<div v-if="financesList.length > 0" class="flex flex-col gap-1.5 mb-2">
|
||||
<div v-for="fin in financesList" :key="fin.provider" class="text-[10px] bg-gray-800/80 border border-gray-600/50 px-2 py-1.5 rounded flex justify-between items-center shadow-inner">
|
||||
@@ -101,7 +101,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="p-4 flex justify-between items-center cursor-pointer hover:bg-gray-800 transition-colors" @click="activeView = 'settings'">
|
||||
<div class="p-4 flex justify-between items-center cursor-pointer hover:bg-gray-800 transition-colors" @click="openSettings">
|
||||
<div class="flex items-center gap-2">
|
||||
<img v-if="user.avatar_path" :src="user.avatar_path" class="w-8 h-8 rounded-full object-cover border border-gray-600 bg-gray-900">
|
||||
<div v-else class="w-8 h-8 rounded-full bg-gradient-to-tr from-aethas-cyan to-aethas-purple flex items-center justify-center text-sm font-bold shadow-md">{{ user.username.charAt(0).toUpperCase() }}</div>
|
||||
@@ -136,8 +136,8 @@
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- VUE : CONFIGURATION (Par Niveaux) -->
|
||||
<div v-if="activeView === 'settings'" class="flex-1 overflow-y-auto p-4 md:p-8">
|
||||
<!-- VUE : CONFIGURATION -->
|
||||
<div v-if="activeView === 'settings'" class="flex-1 overflow-y-auto p-4 md:p-8 custom-scrollbar">
|
||||
<div class="max-w-4xl mx-auto space-y-6">
|
||||
<h2 class="text-2xl font-bold text-white flex items-center gap-2 border-b border-gray-700 pb-4"><i data-lucide="settings-2" class="w-6 h-6 text-aethas-cyan"></i> Configuration Système</h2>
|
||||
|
||||
@@ -147,7 +147,6 @@
|
||||
<button v-if="user.is_superadmin" @click="settingsTab = 'super'" :class="['py-2 px-4 text-sm font-semibold border-b-2 transition-colors', settingsTab === 'super' ? 'border-aethas-purple text-purple-400' : 'border-transparent text-gray-400 hover:text-white']">Super-Admin</button>
|
||||
</div>
|
||||
|
||||
<!-- Tab: Utilisateur -->
|
||||
<div v-if="settingsTab === 'user'" class="space-y-6">
|
||||
<div class="bg-gray-800 p-6 rounded-xl border border-gray-700">
|
||||
<h3 class="text-lg font-semibold text-white mb-4">Personnalisation du Profil</h3>
|
||||
@@ -159,7 +158,6 @@
|
||||
<i data-lucide="upload" class="w-4 h-4 inline mr-1"></i> Uploader un nouvel Avatar
|
||||
<input type="file" accept="image/*" @change="uploadAvatar" class="hidden">
|
||||
</label>
|
||||
<p class="text-xs text-gray-500 mt-2">L'image sera automatiquement recadrée et redimensionnée à l'affichage pour s'adapter parfaitement à l'interface.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -175,11 +173,9 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tab: Admin -->
|
||||
<div v-if="settingsTab === 'admin' && user.is_admin" class="space-y-6">
|
||||
<div class="bg-gray-800 p-6 rounded-xl border border-gray-700">
|
||||
<h3 class="text-lg font-semibold text-red-400 mb-4">Outils Administrateur</h3>
|
||||
<p class="text-sm text-gray-400 mb-4">Fonctionnalités réservées aux administrateurs pour la gestion des modèles et le suivi de base.</p>
|
||||
<div class="flex gap-4">
|
||||
<button @click="activeView = 'models'" class="bg-gray-700 hover:bg-gray-600 text-white px-4 py-2 rounded-lg text-sm border border-gray-600">Ouvrir le panneau Modèles IA</button>
|
||||
<a href="/api/models/export" target="_blank" class="bg-gray-700 hover:bg-gray-600 text-white px-4 py-2 rounded-lg text-sm border border-gray-600">Exporter DB Modèles (JSON)</a>
|
||||
@@ -187,26 +183,23 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tab: Super-Admin -->
|
||||
<div v-if="settingsTab === 'super' && user.is_superadmin" class="space-y-6">
|
||||
<div class="bg-gray-800 p-6 rounded-xl border border-gray-700 border-l-4 border-l-aethas-purple">
|
||||
<h3 class="text-lg font-semibold text-purple-400 mb-4">Espace Réservé Super-Admin</h3>
|
||||
<p class="text-sm text-gray-400">La gestion complète du serveur mail, des clés API et de l'élévation des droits utilisateurs sera disponible ici lors du prochain patch de développement.</p>
|
||||
<p class="text-sm text-gray-400">Gestion globale du système.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- VUE : MODÈLES ET FINANCES (Admin Only) -->
|
||||
<div v-if="activeView === 'models' && user.is_admin" class="flex-1 overflow-y-auto p-4 md:p-8 space-y-6">
|
||||
<!-- VUE : MODÈLES ET FINANCES -->
|
||||
<div v-if="activeView === 'models' && user.is_admin" class="flex-1 overflow-y-auto p-4 md:p-8 space-y-6 custom-scrollbar">
|
||||
<div class="flex justify-between items-end border-b border-gray-700 pb-4">
|
||||
<div>
|
||||
<h2 class="text-2xl font-bold text-white flex items-center gap-2"><i data-lucide="cpu" class="w-6 h-6 text-aethas-cyan"></i> Modèles & Finances API</h2>
|
||||
<p class="text-sm text-gray-400 mt-1">Dernière extraction : <span class="text-gray-200 font-mono">{{ formatDate(modelInfo.last_sync_date) }}</span> <span class="text-xs bg-gray-800 px-2 py-0.5 rounded border border-gray-600 ml-2 uppercase">{{ modelInfo.last_sync_type || 'Aucune' }}</span></p>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<button @click="syncModels" :disabled="isSyncing" class="bg-aethas-cyan hover:bg-cyan-600 text-aethas-dark font-semibold py-2 px-4 rounded flex items-center gap-2 text-sm disabled:opacity-50"><i data-lucide="refresh-cw" :class="{'animate-spin': isSyncing}" class="w-4 h-4"></i> Forcer Extraction</button>
|
||||
</div>
|
||||
<button @click="syncModels" :disabled="isSyncing" class="bg-aethas-cyan hover:bg-cyan-600 text-aethas-dark font-semibold py-2 px-4 rounded flex items-center gap-2 text-sm disabled:opacity-50"><i data-lucide="refresh-cw" :class="{'animate-spin': isSyncing}" class="w-4 h-4"></i> Forcer Extraction</button>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
@@ -253,86 +246,160 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- VUE : CHAT PAR DÉFAUT -->
|
||||
<template v-if="activeView === 'chat'">
|
||||
<!-- VUE : CHAT -->
|
||||
<div v-show="activeView === 'chat'" class="flex-1 flex flex-col min-h-0">
|
||||
<div v-if="!activeProject" class="flex-1 overflow-y-auto p-4 flex flex-col items-center justify-center">
|
||||
<img src="/assets/logo.png" class="w-24 h-24 mb-6 rounded-full border-2 border-aethas-cyan shadow-[0_0_15px_rgba(6,182,212,0.5)]">
|
||||
<h2 class="text-2xl font-bold text-gray-200 mb-2">Comment puis-je vous aider aujourd'hui ?</h2>
|
||||
<p class="text-gray-500 text-sm">Sélectionnez ou créez un projet dans la barre latérale.</p>
|
||||
</div>
|
||||
|
||||
<div v-else class="flex-1 overflow-y-auto p-4 md:p-8 space-y-6 flex flex-col custom-scrollbar" id="chat-container">
|
||||
<div v-if="messages.length === 0" class="flex-1 flex items-center justify-center text-gray-500 italic">Démarrez la conversation ci-dessous.</div>
|
||||
<template v-else>
|
||||
<div class="flex-1 overflow-y-auto p-4 md:p-8 space-y-6 flex flex-col custom-scrollbar" id="chat-container">
|
||||
<div v-if="messages.length === 0" class="flex-1 flex items-center justify-center text-gray-500 italic">Démarrez la conversation ci-dessous.</div>
|
||||
|
||||
<div v-for="msg in messages" :key="msg.id" :class="['max-w-4xl rounded-2xl p-4', msg.role === 'user' ? 'bg-gray-800 ml-auto border border-gray-700' : 'bg-aethas-panel mr-auto border border-aethas-cyan/30 flex flex-col']">
|
||||
<div class="flex items-center gap-2 mb-2">
|
||||
<img v-if="msg.role === 'user' && user.avatar_path" :src="user.avatar_path" class="w-5 h-5 rounded-full object-cover">
|
||||
<span class="text-xs font-semibold uppercase tracking-wider text-gray-400">{{ msg.role === 'user' ? 'Vous' : 'AETHAS38' }}</span>
|
||||
</div>
|
||||
<div v-for="msg in messages" :key="msg.id" :class="['max-w-4xl rounded-2xl p-4', msg.role === 'user' ? 'bg-gray-800 ml-auto border border-gray-700' : 'bg-aethas-panel mr-auto border border-aethas-cyan/30 flex flex-col']">
|
||||
<div class="flex items-center gap-2 mb-2">
|
||||
<img v-if="msg.role === 'user' && user.avatar_path" :src="user.avatar_path" class="w-5 h-5 rounded-full object-cover">
|
||||
<span class="text-xs font-semibold uppercase tracking-wider text-gray-400">{{ msg.role === 'user' ? 'Vous' : 'AETHAS38' }}</span>
|
||||
</div>
|
||||
|
||||
<div class="text-gray-200 text-sm leading-relaxed w-full">
|
||||
<template v-for="(part, index) in parseMessage(msg.content)" :key="index">
|
||||
<div v-if="part.type === 'text'" class="whitespace-pre-wrap font-sans">{{ part.content }}</div>
|
||||
<div v-if="part.type === 'code'" class="my-4 bg-gray-900 rounded-lg border border-gray-700 overflow-hidden shadow-inner">
|
||||
<div class="flex justify-between items-center px-4 py-2 bg-gray-800 border-b border-gray-700">
|
||||
<span class="text-xs text-gray-400 font-mono flex items-center gap-2"><i data-lucide="file-code-2" class="w-4 h-4"></i> {{ part.language || 'code' }}</span>
|
||||
<button @click="downloadFile(part.content, part.language)" class="text-aethas-cyan hover:text-white flex items-center gap-1 text-xs transition-colors bg-gray-700 hover:bg-gray-600 px-2 py-1 rounded"><i data-lucide="download" class="w-3 h-3"></i> Fichier</button>
|
||||
<div class="text-gray-200 text-sm leading-relaxed w-full">
|
||||
<template v-for="(part, index) in parseMessage(msg.content)" :key="index">
|
||||
<div v-if="part.type === 'text'" class="whitespace-pre-wrap font-sans">{{ part.content }}</div>
|
||||
<div v-if="part.type === 'code'" class="my-4 bg-gray-900 rounded-lg border border-gray-700 overflow-hidden shadow-inner">
|
||||
<div class="flex justify-between items-center px-4 py-2 bg-gray-800 border-b border-gray-700">
|
||||
<span class="text-xs text-gray-400 font-mono flex items-center gap-2"><i data-lucide="file-code-2" class="w-4 h-4"></i> {{ part.language || 'code' }}</span>
|
||||
<button @click="downloadFile(part.content, part.language)" class="text-aethas-cyan hover:text-white flex items-center gap-1 text-xs transition-colors bg-gray-700 hover:bg-gray-600 px-2 py-1 rounded"><i data-lucide="download" class="w-3 h-3"></i> Fichier</button>
|
||||
</div>
|
||||
<pre class="p-4 text-xs font-mono text-gray-300 overflow-x-auto custom-scrollbar"><code>{{ part.content }}</code></pre>
|
||||
</div>
|
||||
<pre class="p-4 text-xs font-mono text-gray-300 overflow-x-auto custom-scrollbar"><code>{{ part.content }}</code></pre>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div v-if="msg.role !== 'user'" class="mt-3 flex items-center gap-3 border-t border-gray-700/50 pt-2 opacity-50 hover:opacity-100 transition-opacity">
|
||||
<button @click="copyToClipboard(msg.content)" class="text-xs text-gray-400 hover:text-aethas-cyan flex items-center gap-1"><i data-lucide="copy" class="w-3 h-3"></i> Copier</button>
|
||||
<button @click="downloadMessage(msg.content, msg.created_at)" class="text-xs text-gray-400 hover:text-aethas-cyan flex items-center gap-1"><i data-lucide="file-down" class="w-3 h-3"></i> Extraire</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="isAiThinking" class="max-w-3xl rounded-2xl p-4 bg-aethas-panel mr-auto border border-aethas-cyan/30 w-24">
|
||||
<div class="flex space-x-1.5 h-4 items-center">
|
||||
<div class="w-2 h-2 bg-aethas-cyan rounded-full animate-bounce"></div>
|
||||
<div class="w-2 h-2 bg-aethas-cyan rounded-full animate-bounce" style="animation-delay: 0.15s"></div>
|
||||
<div class="w-2 h-2 bg-aethas-cyan rounded-full animate-bounce" style="animation-delay: 0.3s"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ZONE SÉLECTION MODÈLES PAR REQUÊTE -->
|
||||
<div v-if="activeProject" class="p-4 md:p-6 w-full max-w-5xl mx-auto space-y-2">
|
||||
<div class="bg-gray-800/80 border border-gray-700 rounded-xl p-3 flex flex-wrap gap-4 items-center text-xs shadow-md">
|
||||
<div class="flex items-center gap-2 flex-1 min-w-[200px]">
|
||||
<span class="text-aethas-cyan font-semibold w-20"><i data-lucide="users" class="w-3 h-3 inline"></i> Travailleurs:</span>
|
||||
<select multiple v-model="selectedWorkers" @change="limitWorkers" class="bg-aethas-dark border border-gray-600 rounded px-2 py-1 text-gray-200 w-full h-16 outline-none focus:border-aethas-cyan custom-scrollbar">
|
||||
<option value="gemini-3.5-flash-lite">Gemini 3.5 Flash-Lite (Direct)</option>
|
||||
<option v-for="m in modelInfo.models" :key="m.model_id" :value="m.model_id">{{ m.name || m.model_id }} ({{ m.domain }})</option>
|
||||
</select>
|
||||
<span class="text-gray-500 ml-1">{{ selectedWorkers.length }}/5</span>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2 flex-1 min-w-[200px]" :class="{'opacity-30 pointer-events-none': selectedWorkers.length <= 1}">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="text-gray-400 font-semibold w-24"><i data-lucide="edit-3" class="w-3 h-3 inline"></i> Prompteur:</span>
|
||||
<select v-model="selectedPrompter" class="bg-aethas-dark border border-gray-600 rounded px-2 py-1 text-gray-200 flex-1 outline-none truncate">
|
||||
<option value="gemini-3.5-flash-lite">Gemini 3.5 Flash-Lite (Direct)</option>
|
||||
<option v-for="m in modelInfo.models" :key="m.model_id" :value="m.model_id">{{ m.name || m.model_id }}</option>
|
||||
</select>
|
||||
</template>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="text-aethas-purple font-semibold w-24"><i data-lucide="git-merge" class="w-3 h-3 inline"></i> Concaténeur:</span>
|
||||
<select v-model="selectedConcatenator" class="bg-aethas-dark border border-gray-600 rounded px-2 py-1 text-gray-200 flex-1 outline-none truncate">
|
||||
<option value="gemini-3.5-flash-lite">Gemini 3.5 Flash-Lite (Direct)</option>
|
||||
<option v-for="m in modelInfo.models" :key="m.model_id" :value="m.model_id">{{ m.name || m.model_id }}</option>
|
||||
</select>
|
||||
|
||||
<div v-if="msg.role !== 'user'" class="mt-3 flex items-center gap-3 border-t border-gray-700/50 pt-2 opacity-50 hover:opacity-100 transition-opacity">
|
||||
<button @click="copyToClipboard(msg.content)" class="text-xs text-gray-400 hover:text-aethas-cyan flex items-center gap-1"><i data-lucide="copy" class="w-3 h-3"></i> Copier</button>
|
||||
<button @click="downloadMessage(msg.content, msg.created_at)" class="text-xs text-gray-400 hover:text-aethas-cyan flex items-center gap-1"><i data-lucide="file-down" class="w-3 h-3"></i> Extraire</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="isAiThinking" class="max-w-3xl rounded-2xl p-4 bg-aethas-panel mr-auto border border-aethas-cyan/30 w-24">
|
||||
<div class="flex space-x-1.5 h-4 items-center">
|
||||
<div class="w-2 h-2 bg-aethas-cyan rounded-full animate-bounce"></div>
|
||||
<div class="w-2 h-2 bg-aethas-cyan rounded-full animate-bounce" style="animation-delay: 0.15s"></div>
|
||||
<div class="w-2 h-2 bg-aethas-cyan rounded-full animate-bounce" style="animation-delay: 0.3s"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="relative flex items-end bg-gray-800 border border-gray-600 rounded-2xl p-2 shadow-lg focus-within:border-aethas-cyan">
|
||||
<textarea v-model="prompt" @input="autoResize" @keydown.enter.exact.prevent="sendMessage" ref="promptTextarea" :disabled="isAiThinking" rows="1" class="w-full bg-transparent text-gray-200 p-3 max-h-[200px] overflow-y-auto focus:outline-none resize-none disabled:opacity-50 custom-scrollbar" placeholder="Sélectionnez vos modèles ci-dessus, puis posez votre question..."></textarea>
|
||||
<button @click="sendMessage" :disabled="!prompt.trim() || isAiThinking" class="p-3 text-aethas-cyan hover:text-white disabled:opacity-50"><i data-lucide="send" class="w-5 h-5"></i></button>
|
||||
<!-- BARRE DE SÉLECTION DE STYLE TABULAIRE (9 COLONNES STRICTES) -->
|
||||
<div class="p-4 md:p-6 w-full max-w-7xl mx-auto space-y-2 flex-shrink-0">
|
||||
<div class="grid grid-cols-9 border border-black bg-gray-900 rounded-lg overflow-hidden text-center text-xs font-bold shadow-lg">
|
||||
|
||||
<!-- 1. PAYANT / GRATUIT -->
|
||||
<div class="border-r border-black p-1.5 bg-gray-800 flex flex-col justify-center">
|
||||
<label class="block text-[9px] text-gray-400 mb-1">PRIX</label>
|
||||
<select v-model="colPricing" class="w-full bg-aethas-dark border border-gray-700 rounded text-gray-200 text-[10px] p-1 outline-none">
|
||||
<option value="">TOUS</option>
|
||||
<option value="free">GRATUIT</option>
|
||||
<option value="paid">PAYANT</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- 2. TYPE (DOMAINE) -->
|
||||
<div class="border-r border-black p-1.5 bg-gray-800 flex flex-col justify-center">
|
||||
<label class="block text-[9px] text-gray-400 mb-1">TYPE</label>
|
||||
<select v-model="colDomain" class="w-full bg-aethas-dark border border-gray-700 rounded text-gray-200 text-[10px] p-1 outline-none">
|
||||
<option value="">TOUS</option>
|
||||
<option value="Texte Polyvalent">Texte</option>
|
||||
<option value="Code & Logique">Codage</option>
|
||||
<option value="Vision & Texte">Vision</option>
|
||||
<option value="Audio">Audio</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- 3. TRAVAILLEUR 1 -->
|
||||
<div class="border-r border-black p-1.5 bg-gray-800 flex flex-col justify-center">
|
||||
<label class="block text-[9px] text-aethas-cyan mb-1">TRAVAILLEUR 1</label>
|
||||
<select v-model="workers[0]" class="w-full bg-aethas-dark border border-gray-700 rounded text-gray-200 text-[10px] p-1 outline-none truncate">
|
||||
<option value="">(Aucun)</option>
|
||||
<option v-for="m in getFilteredModelsForCol(colPricing, colDomain, workers[0])" :key="m.model_id" :value="m.model_id">{{ m.name || m.model_id }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- 4. TRAVAILLEUR 2 -->
|
||||
<div class="border-r border-black p-1.5 bg-gray-800 flex flex-col justify-center">
|
||||
<label class="block text-[9px] text-aethas-cyan mb-1">TRAVAILLEUR 2</label>
|
||||
<select v-model="workers[1]" class="w-full bg-aethas-dark border border-gray-700 rounded text-gray-200 text-[10px] p-1 outline-none truncate">
|
||||
<option value="">(Aucun)</option>
|
||||
<option v-for="m in getFilteredModelsForCol(colPricing, colDomain, workers[1])" :key="m.model_id" :value="m.model_id">{{ m.name || m.model_id }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- 5. TRAVAILLEUR 3 -->
|
||||
<div class="border-r border-black p-1.5 bg-gray-800 flex flex-col justify-center">
|
||||
<label class="block text-[9px] text-aethas-cyan mb-1">TRAVAILLEUR 3</label>
|
||||
<select v-model="workers[2]" class="w-full bg-aethas-dark border border-gray-700 rounded text-gray-200 text-[10px] p-1 outline-none truncate">
|
||||
<option value="">(Aucun)</option>
|
||||
<option v-for="m in getFilteredModelsForCol(colPricing, colDomain, workers[2])" :key="m.model_id" :value="m.model_id">{{ m.name || m.model_id }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- 6. TRAVAILLEUR 4 -->
|
||||
<div class="border-r border-black p-1.5 bg-gray-800 flex flex-col justify-center">
|
||||
<label class="block text-[9px] text-aethas-cyan mb-1">TRAVAILLEUR 4</label>
|
||||
<select v-model="workers[3]" class="w-full bg-aethas-dark border border-gray-700 rounded text-gray-200 text-[10px] p-1 outline-none truncate">
|
||||
<option value="">(Aucun)</option>
|
||||
<option v-for="m in getFilteredModelsForCol(colPricing, colDomain, workers[3])" :key="m.model_id" :value="m.model_id">{{ m.name || m.model_id }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- 7. TRAVAILLEUR 5 -->
|
||||
<div class="border-r border-black p-1.5 bg-gray-800 flex flex-col justify-center">
|
||||
<label class="block text-[9px] text-aethas-cyan mb-1">TRAVAILLEUR 5</label>
|
||||
<select v-model="workers[4]" class="w-full bg-aethas-dark border border-gray-700 rounded text-gray-200 text-[10px] p-1 outline-none truncate">
|
||||
<option value="">(Aucun)</option>
|
||||
<option v-for="m in getFilteredModelsForCol(colPricing, colDomain, workers[4])" :key="m.model_id" :value="m.model_id">{{ m.name || m.model_id }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- 8. PROMPTEUR -->
|
||||
<div class="border-r border-black p-1.5 bg-gray-800 flex flex-col justify-center">
|
||||
<label class="block text-[9px] text-gray-400 mb-1">PROMPTEUR</label>
|
||||
<select v-model="selectedPrompter" class="w-full bg-aethas-dark border border-gray-700 rounded text-gray-200 text-[10px] p-1 outline-none truncate">
|
||||
<option value="gemini-3.5-flash-lite">Gemini Flash</option>
|
||||
<option v-for="m in getFilteredModelsForCol(colPricing, colDomain, selectedPrompter)" :key="m.model_id" :value="m.model_id">{{ m.name || m.model_id }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- 9. CONCATENEUR -->
|
||||
<div class="p-1.5 bg-gray-800 flex flex-col justify-center">
|
||||
<label class="block text-[9px] text-aethas-purple mb-1">CONCATENEUR</label>
|
||||
<select v-model="selectedConcatenator" class="w-full bg-aethas-dark border border-gray-700 rounded text-gray-200 text-[10px] p-1 outline-none truncate">
|
||||
<option value="gemini-3.5-flash-lite">Gemini Flash</option>
|
||||
<option v-for="m in getFilteredModelsForCol(colPricing, colDomain, selectedConcatenator)" :key="m.model_id" :value="m.model_id">{{ m.name || m.model_id }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Champ de texte et boutons d'envoi / fichiers -->
|
||||
<div class="relative flex items-end bg-gray-800 border border-gray-600 rounded-2xl p-2 shadow-lg focus-within:border-aethas-cyan">
|
||||
<!-- Bouton d'import de fichiers -->
|
||||
<label class="p-3 text-gray-400 hover:text-aethas-cyan cursor-pointer transition-colors" title="Joindre un fichier (code, texte, script, etc.)">
|
||||
<i data-lucide="paperclip" class="w-5 h-5"></i>
|
||||
<input type="file" @change="handleFileUpload" class="hidden">
|
||||
</label>
|
||||
|
||||
<textarea v-model="prompt" @input="autoResize" @paste="handlePaste" @keydown.enter.exact.prevent="sendMessage" ref="promptTextarea" :disabled="isAiThinking" rows="1" class="w-full bg-transparent text-gray-200 p-3 max-h-[200px] overflow-y-auto focus:outline-none resize-none disabled:opacity-50 custom-scrollbar" :placeholder="attachedFile ? 'Fichier attaché : ' + attachedFile.name : 'Posez votre question ou glissez un fichier ici...'"></textarea>
|
||||
|
||||
<button v-if="attachedFile" @click="removeFile" class="p-2 text-red-400 hover:text-red-300 text-xs flex items-center gap-1 mr-2" title="Retirer le fichier"><i data-lucide="x-circle" class="w-4 h-4"></i></button>
|
||||
|
||||
<button @click="sendMessage" :disabled="(!prompt.trim() && !attachedFile) || isAiThinking" class="p-3 text-aethas-cyan hover:text-white disabled:opacity-50"><i data-lucide="send" class="w-5 h-5"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@@ -357,6 +424,7 @@
|
||||
const isSyncing = ref(false);
|
||||
const isSavingSettings = ref(false);
|
||||
|
||||
const isSettingsModalOpen = ref(false);
|
||||
const settingsMessage = ref("");
|
||||
const passForm = reactive({ old: '', new: '', confirm: '' });
|
||||
|
||||
@@ -366,10 +434,15 @@
|
||||
const filterDomain = ref("");
|
||||
const filterPricing = ref("");
|
||||
|
||||
const selectedWorkers = ref(["gemini-3.5-flash-lite"]);
|
||||
const colPricing = ref("");
|
||||
const colDomain = ref("");
|
||||
|
||||
const workers = ref(["gemini-3.5-flash-lite", "", "", "", ""]);
|
||||
const selectedPrompter = ref("gemini-3.5-flash-lite");
|
||||
const selectedConcatenator = ref("gemini-3.5-flash-lite");
|
||||
|
||||
const attachedFile = ref(null);
|
||||
|
||||
const pinnedProjects = computed(() => projects.value.filter(p => p.is_pinned));
|
||||
const recentProjects = computed(() => projects.value.filter(p => !p.is_pinned));
|
||||
|
||||
@@ -384,6 +457,17 @@
|
||||
});
|
||||
});
|
||||
|
||||
const getFilteredModelsForCol = (pricingFilter, domainFilter, currentSelectedId) => {
|
||||
return modelInfo.models.filter(m => {
|
||||
if (m.model_id === currentSelectedId) return true;
|
||||
const matchDomain = domainFilter === "" || m.domain === domainFilter;
|
||||
let matchPrice = true;
|
||||
if (pricingFilter === 'free') matchPrice = m.is_free;
|
||||
if (pricingFilter === 'paid') matchPrice = !m.is_free;
|
||||
return matchDomain && matchPrice;
|
||||
});
|
||||
};
|
||||
|
||||
const formatDate = (isoString) => {
|
||||
if (!isoString) return "Jamais";
|
||||
const d = new Date(isoString);
|
||||
@@ -394,6 +478,9 @@
|
||||
const autoResize = () => { const el = promptTextarea.value; if(el){ el.style.height = 'auto'; el.style.height = el.scrollHeight + 'px'; }};
|
||||
const scrollToBottom = () => { nextTick(() => { const c = document.getElementById('chat-container'); if (c) c.scrollTop = c.scrollHeight; }); };
|
||||
|
||||
const openSettings = () => { isSettingsModalOpen.value = true; nextTick(() => lucide.createIcons()); };
|
||||
const closeSettings = () => { isSettingsModalOpen.value = false; };
|
||||
|
||||
const fetchUser = async () => { try { const res = await fetch('/api/users/me'); if(res.ok) user.value = await res.json(); } catch(e){} };
|
||||
const fetchModelsInfo = async () => { try { const res = await fetch('/api/models/info'); if(res.ok) { const data = await res.json(); modelInfo.last_sync_date = data.last_sync_date; modelInfo.last_sync_type = data.last_sync_type; modelInfo.models = data.models; } } catch(e){} };
|
||||
const fetchFinances = async () => { try { const res = await fetch('/api/finances'); if(res.ok) financesList.value = await res.json(); } catch(e){} };
|
||||
@@ -405,12 +492,13 @@
|
||||
if(res.ok) {
|
||||
await fetchModelsInfo();
|
||||
await fetchFinances();
|
||||
alert("Synchronisation terminée !");
|
||||
alert("Synchronisation réussie !");
|
||||
} else {
|
||||
const err = await res.json();
|
||||
alert("Erreur: " + err.detail);
|
||||
let errText = await res.text();
|
||||
try { const errObj = JSON.parse(errText); errText = errObj.detail || errText; } catch(e){}
|
||||
alert("Erreur retournée par le serveur : " + errText);
|
||||
}
|
||||
} catch(e) { alert("Erreur réseau de synchronisation."); }
|
||||
} catch(e) { alert("Erreur réseau: impossible de contacter le serveur."); }
|
||||
isSyncing.value = false;
|
||||
};
|
||||
|
||||
@@ -427,6 +515,34 @@
|
||||
event.target.value = null;
|
||||
};
|
||||
|
||||
const handleFileUpload = (event) => {
|
||||
const file = event.target.files[0];
|
||||
if (!file) return;
|
||||
processFile(file);
|
||||
event.target.value = null;
|
||||
};
|
||||
|
||||
const handlePaste = (event) => {
|
||||
const items = (event.clipboardData || event.originalEvent.clipboardData).items;
|
||||
for (let index in items) {
|
||||
let item = items[index];
|
||||
if (item.kind === 'file') {
|
||||
let file = item.getAsFile();
|
||||
if (file) processFile(file);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const processFile = (file) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = (e) => {
|
||||
attachedFile.value = { name: file.name, content: e.target.result };
|
||||
};
|
||||
reader.readAsText(file);
|
||||
};
|
||||
|
||||
const removeFile = () => { attachedFile.value = null; };
|
||||
|
||||
const exportProject = (format) => { if(activeProject.value) window.open(`/api/projects/${activeProject.value.id}/export?format=${format}`, '_blank'); };
|
||||
const copyToClipboard = async (text) => { try { await navigator.clipboard.writeText(text); alert("Copié !"); } catch (e) {} };
|
||||
const downloadFile = (content, hint) => { let fname = hint ? hint.trim() : 'code.txt'; if (!fname.includes('.')) fname += '.txt'; const blob = new Blob([content], { type: 'text/plain;charset=utf-8' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = fname; a.click(); URL.revokeObjectURL(url); };
|
||||
@@ -438,17 +554,40 @@
|
||||
const createNewProject = async () => { activeView.value = 'chat'; isLoading.value = true; try { const res = await fetch('/api/projects', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({title: "Nouvelle discussion"})}); if(res.ok){ const np = await res.json(); projects.value.unshift(np); selectProject(np); } } catch(e){} finally{isLoading.value = false;} };
|
||||
|
||||
const sendMessage = async () => {
|
||||
if (!prompt.value.trim() || !activeProject.value || selectedWorkers.value.length === 0) return;
|
||||
const userText = prompt.value.trim(); prompt.value = ""; autoResize();
|
||||
messages.value.push({ id: Date.now(), role: 'user', content: userText });
|
||||
isAiThinking.value = true; scrollToBottom();
|
||||
const payload = { role: 'user', content: userText, config: { workers: selectedWorkers.value, prompter: selectedPrompter.value, concatenator: selectedConcatenator.value } };
|
||||
const activeWorkers = workers.value.filter(w => w && w.trim() !== "");
|
||||
if ((!prompt.value.trim() && !attachedFile.value) || !activeProject.value || activeWorkers.length === 0) {
|
||||
alert("Veuillez sélectionner au moins un travailleur et rédiger ou joindre un contenu.");
|
||||
return;
|
||||
}
|
||||
const userText = prompt.value.trim();
|
||||
prompt.value = "";
|
||||
autoResize();
|
||||
|
||||
messages.value.push({ id: Date.now(), role: 'user', content: userText + (attachedFile.value ? `\n[Fichier joint: ${attachedFile.value.name}]` : "") });
|
||||
isAiThinking.value = true;
|
||||
scrollToBottom();
|
||||
|
||||
const payload = {
|
||||
role: 'user',
|
||||
content: userText || "Analyse ce fichier joint.",
|
||||
config: {
|
||||
workers: activeWorkers,
|
||||
prompter: selectedPrompter.value,
|
||||
concatenator: selectedConcatenator.value
|
||||
},
|
||||
file_content: attachedFile.value ? attachedFile.value.content : null,
|
||||
file_name: attachedFile.value ? attachedFile.value.name : null
|
||||
};
|
||||
|
||||
// DESTRUCTION IMMÉDIATE DU FICHIER CÔTÉ FRONTEND APRÈS ENVOI
|
||||
attachedFile.value = null;
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/projects/${activeProject.value.id}/messages`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) });
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
if (Array.isArray(data)) messages.value = data;
|
||||
await fetchFinances(); // MAJ du budget sous le nom
|
||||
await fetchFinances();
|
||||
} else {
|
||||
const err = await response.json(); alert("Erreur API IA : " + err.detail);
|
||||
}
|
||||
@@ -466,7 +605,6 @@
|
||||
const renameProject = async (project) => { const nt = window.prompt("Nom :", project.title); if (!nt || nt.trim() === "" || nt === project.title) return; try { const res = await fetch(`/api/projects/${project.id}/rename`, { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ title: nt.trim() }) }); if (res.ok) { const up = await res.json(); const i = projects.value.findIndex(p => p.id === project.id); if (i !== -1) projects.value[i] = up; if (activeProject.value && activeProject.value.id === project.id) activeProject.value.title = up.title; } } catch (e) {} };
|
||||
const togglePin = async (pid) => { try { const res = await fetch(`/api/projects/${pid}/pin`, { method: 'PUT' }); if (res.ok) { const up = await res.json(); const i = projects.value.findIndex(p => p.id === pid); if (i !== -1) projects.value[i] = up; } } catch (e) {} };
|
||||
const deleteProject = async (pid) => { if (!confirm("Supprimer ce projet ?")) return; try { const res = await fetch(`/api/projects/${pid}`, { method: 'DELETE' }); if (res.ok) { projects.value = projects.value.filter(p => p.id !== pid); if (activeProject.value && activeProject.value.id === pid) activeProject.value = null; } } catch (e) {} };
|
||||
const limitWorkers = () => { if(selectedWorkers.value.length > 5) { selectedWorkers.value.pop(); alert("Max 5 travailleurs."); } };
|
||||
|
||||
onMounted(() => { lucide.createIcons(); fetchUser(); fetchProjects(); fetchModelsInfo(); fetchFinances(); });
|
||||
|
||||
@@ -474,9 +612,10 @@
|
||||
user, activeView, settingsTab, isSidebarOpen, toggleSidebar, prompt, autoResize, promptTextarea,
|
||||
projects, pinnedProjects, recentProjects, activeProject, messages, isAiThinking,
|
||||
createNewProject, selectProject, renameProject, sendMessage, isLoading, togglePin, deleteProject,
|
||||
passForm, settingsMessage, isSavingSettings, changePassword, uploadAvatar,
|
||||
modelInfo, financesList, filterSearch, filterDomain, filterPricing, filteredModels, formatDate, syncModels, isSyncing,
|
||||
selectedWorkers, selectedPrompter, selectedConcatenator, limitWorkers,
|
||||
isSettingsModalOpen, openSettings, closeSettings, passForm, settingsMessage, isSavingSettings, changePassword, uploadAvatar,
|
||||
modelInfo, financesList, filterSearch, filterDomain, filterPricing, filteredModels, getFilteredModelsForCol, formatDate, syncModels, isSyncing,
|
||||
workers, selectedPrompter, selectedConcatenator, colPricing, colDomain,
|
||||
attachedFile, handleFileUpload, handlePaste, removeFile,
|
||||
exportProject, copyToClipboard, downloadFile, downloadMessage, parseMessage
|
||||
};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user