Ensure required Ollama models are available.
(self)
| 220 | return False |
| 221 | |
| 222 | def ensure_models(self): |
| 223 | """Ensure required Ollama models are available.""" |
| 224 | self.logger.info("📥 Checking required models...") |
| 225 | |
| 226 | required_models = ['qwen3:8b', 'qwen3:0.6b'] |
| 227 | |
| 228 | try: |
| 229 | # Get list of installed models |
| 230 | result = subprocess.run(['ollama', 'list'], |
| 231 | capture_output=True, text=True, timeout=10) |
| 232 | installed_models = result.stdout |
| 233 | |
| 234 | for model in required_models: |
| 235 | if model not in installed_models: |
| 236 | self.logger.info(f"📥 Pulling {model}...") |
| 237 | subprocess.run(['ollama', 'pull', model], |
| 238 | check=True, timeout=300) # 5 min timeout |
| 239 | self.logger.info(f"✅ {model} ready") |
| 240 | else: |
| 241 | self.logger.info(f"✅ {model} already available") |
| 242 | |
| 243 | except subprocess.TimeoutExpired: |
| 244 | self.logger.warning("⚠️ Model check timed out - continuing anyway") |
| 245 | except subprocess.CalledProcessError as e: |
| 246 | self.logger.warning(f"⚠️ Could not check/pull models: {e}") |
| 247 | |
| 248 | def start_service(self, service_name: str, config: ServiceConfig) -> bool: |
| 249 | """Start a single service.""" |