feat: add update service dependency and has_update filter

- Pass ModelUpdateService to CheckpointService, EmbeddingService, and LoraService constructors
- Add has_update query parameter filter to model listing handler
- Update BaseModelService to accept optional update_service parameter

These changes enable model update functionality across different model types and provide filtering capability for models with available updates.
This commit is contained in:
Will Miao
2025-10-15 17:25:16 +08:00
parent 5a6ff444b9
commit a5b2e9b0bf
9 changed files with 209 additions and 15 deletions

View File

@@ -20,8 +20,8 @@ class CheckpointRoutes(BaseModelRoutes):
async def initialize_services(self):
"""Initialize services from ServiceRegistry"""
checkpoint_scanner = await ServiceRegistry.get_checkpoint_scanner()
self.service = CheckpointService(checkpoint_scanner)
update_service = await ServiceRegistry.get_model_update_service()
self.service = CheckpointService(checkpoint_scanner, update_service=update_service)
self.set_model_update_service(update_service)
# Attach service dependencies
@@ -95,4 +95,4 @@ class CheckpointRoutes(BaseModelRoutes):
return web.json_response({
"success": False,
"error": str(e)
}, status=500)
}, status=500)

View File

@@ -19,8 +19,8 @@ class EmbeddingRoutes(BaseModelRoutes):
async def initialize_services(self):
"""Initialize services from ServiceRegistry"""
embedding_scanner = await ServiceRegistry.get_embedding_scanner()
self.service = EmbeddingService(embedding_scanner)
update_service = await ServiceRegistry.get_model_update_service()
self.service = EmbeddingService(embedding_scanner, update_service=update_service)
self.set_model_update_service(update_service)
# Attach service dependencies

View File

@@ -6,7 +6,7 @@ import json
import logging
import os
from dataclasses import dataclass
from typing import Awaitable, Callable, Dict, Iterable, Mapping, Optional
from typing import Awaitable, Callable, Dict, Iterable, List, Mapping, Optional
from aiohttp import web
import jinja2
@@ -166,6 +166,11 @@ class ModelListingHandler:
except (json.JSONDecodeError, TypeError):
pass
has_update = request.query.get("has_update", "false")
has_update_filter = (
has_update.lower() in {"1", "true", "yes"} if isinstance(has_update, str) else False
)
return {
"page": page,
"page_size": page_size,
@@ -178,6 +183,7 @@ class ModelListingHandler:
"search_options": search_options,
"hash_filters": hash_filters,
"favorites_only": favorites_only,
"has_update": has_update_filter,
**self._parse_specific_params(request),
}

View File

@@ -23,8 +23,8 @@ class LoraRoutes(BaseModelRoutes):
async def initialize_services(self):
"""Initialize services from ServiceRegistry"""
lora_scanner = await ServiceRegistry.get_lora_scanner()
self.service = LoraService(lora_scanner)
update_service = await ServiceRegistry.get_model_update_service()
self.service = LoraService(lora_scanner, update_service=update_service)
self.set_model_update_service(update_service)
# Attach service dependencies