Date: 20/01/2026 00:21 Statut: En attente de validation
NeedFinder appelle actuellement Ollama directement sur win11:11434 depuis deux fichiers:
src/services/analyzer.ts - analyse des posts pour extraire les besoinssrc/services/matcher.ts - matching besoins/discoveriesL'AI Orchestrator (prod-portainer:5501) dispose déjà d'un executor Ollama fonctionnel (execute_ollama_job) qui:
NeedFinder (dev-portainer:5200)
│
└──► Ollama DIRECT (win11:11434) ← Bypass du système de queue
Risques:
NeedFinder (dev-portainer:5200)
│
└──► AI Orchestrator (prod-portainer:5501)
│
└──► Queue Redis → Ollama (win11:11434)
1. Créer un module client orchestrator (src/services/orchestrator-client.ts):
const ORCHESTRATOR_URL = 'http://192.168.1.12:5501';
export async function submitOllamaJob(prompt: string, options?: {
model?: string;
temperature?: number;
maxTokens?: number;
priority?: number;
}): Promise<string> {
// 1. Créer le job
const response = await fetch(`${ORCHESTRATOR_URL}/api/jobs`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
tool_id: 'ollama',
job_type: 'generate',
input_params: {
prompt,
model: options?.model || 'mistral:latest',
temperature: options?.temperature || 0.3,
max_tokens: options?.maxTokens || 500
},
priority: options?.priority || 0
})
});
const job = await response.json();
const jobId = job.id;
// 2. Polling jusqu'à completion
while (true) {
await new Promise(r => setTimeout(r, 1000)); // 1s entre polls
const statusResp = await fetch(`${ORCHESTRATOR_URL}/api/jobs/${jobId}`);
const status = await statusResp.json();
if (status.status === 'completed') {
return status.output_result?.response || '';
}
if (status.status === 'failed') {
throw new Error(status.error_message || 'Job failed');
}
}
}
2. Modifier analyzer.ts:
// AVANT
async function callOllama(prompt: string): Promise<string> {
const response = await fetch(`${OLLAMA_URL}/api/generate`, {...});
...
}
// APRÈS
import { submitOllamaJob } from './orchestrator-client';
async function callOllama(prompt: string): Promise<string> {
return submitOllamaJob(prompt, {
model: 'mistral:latest',
temperature: 0.3,
maxTokens: 500,
priority: 0 // Normal priority
});
}
3. Modifier matcher.ts (même changement)
| Fichier | Changement |
|---|---|
src/services/orchestrator-client.ts |
NOUVEAU - Client API orchestrator |
src/services/analyzer.ts |
Remplacer callOllama |
src/services/matcher.ts |
Remplacer callOllama |
.env / docker-compose.yml |
Ajouter ORCHESTRATOR_URL |
# NeedFinder .env
ORCHESTRATOR_URL=http://192.168.1.12:5501
# Supprimer: OLLAMA_URL, OLLAMA_MODEL (plus utilisés directement)
| Option | Pros | Cons |
|---|---|---|
| A. Via Orchestrator (proposé) | Centralisation, queue, historique | Latence légèrement plus élevée |
| B. Garder appel direct | Rapide, simple | Pas de gestion conflits VRAM |
| C. Déplacer NeedFinder sur PROD | Plus proche de l'orchestrator | Mélange DEV/PROD |
orchestrator-client.ts sur dev-portaineranalyzer.ts pour utiliser le clientmatcher.ts pour utiliser le client.env et docker-compose.yml/api/analyze et /api/matchEn attente de ta validation avant exécution.