Update ollamaService.ts

This commit is contained in:
Damien 2025-02-04 13:44:59 -05:00
parent 434af6e48a
commit c7b831668e

View File

@ -61,7 +61,36 @@ class OllamaService {
await this.makeRequest<any>('/api/tags'); await this.makeRequest<any>('/api/tags');
return { installed: true, running: true }; return { installed: true, running: true };
} catch (error) { } catch (error) {
return { installed: true, running: false }; // Server not running, attempt to start it
try {
console.log('Attempting to start Ollama server...');
exec('ollama serve', (error, stdout, stderr) => {
if (error) {
console.error('Failed to start Ollama server:', error);
}
if (stderr) {
console.error('Ollama server stderr:', stderr);
}
if (stdout) {
console.log('Ollama server stdout:', stdout);
}
});
// Give the server a moment to start
await new Promise(resolve => setTimeout(resolve, 2000));
// Check again if it's running
try {
await this.makeRequest<any>('/api/tags');
return { installed: true, running: true };
} catch (retryError) {
console.error('Server still not responding after start attempt:', retryError);
return { installed: true, running: false };
}
} catch (startError) {
console.error('Error starting Ollama server:', startError);
return { installed: true, running: false };
}
} }
} catch (error) { } catch (error) {
return { installed: false, running: false }; return { installed: false, running: false };