mirror of
https://github.com/GayPizzaSpecifications/stable-diffusion-rpc.git
synced 2025-08-04 05:51:32 +00:00
Formatting, linting, and hopefully a CI build.
This commit is contained in:
@ -1,29 +1,30 @@
|
||||
import Foundation
|
||||
import GRPC
|
||||
import StableDiffusionCore
|
||||
import StableDiffusionProtos
|
||||
|
||||
class ModelServiceProvider: SdModelServiceAsyncProvider {
|
||||
private let modelManager: ModelManager
|
||||
|
||||
|
||||
init(modelManager: ModelManager) {
|
||||
self.modelManager = modelManager
|
||||
}
|
||||
|
||||
func listModels(request: SdListModelsRequest, context: GRPCAsyncServerCallContext) async throws -> SdListModelsResponse {
|
||||
|
||||
func listModels(request _: SdListModelsRequest, context _: GRPCAsyncServerCallContext) async throws -> SdListModelsResponse {
|
||||
let models = await modelManager.listModels()
|
||||
var response = SdListModelsResponse()
|
||||
response.models.append(contentsOf: models)
|
||||
return response
|
||||
}
|
||||
|
||||
func reloadModels(request: SdReloadModelsRequest, context: GRPCAsyncServerCallContext) async throws -> SdReloadModelsResponse {
|
||||
|
||||
func reloadModels(request _: SdReloadModelsRequest, context _: GRPCAsyncServerCallContext) async throws -> SdReloadModelsResponse {
|
||||
try await modelManager.reloadModels()
|
||||
return SdReloadModelsResponse()
|
||||
}
|
||||
|
||||
func loadModel(request: SdLoadModelRequest, context: GRPCAsyncServerCallContext) async throws -> SdLoadModelResponse {
|
||||
|
||||
func loadModel(request: SdLoadModelRequest, context _: GRPCAsyncServerCallContext) async throws -> SdLoadModelResponse {
|
||||
guard let state = await modelManager.getModelState(name: request.modelName) else {
|
||||
throw SdServerError.modelNotFound
|
||||
throw SdCoreError.modelNotFound
|
||||
}
|
||||
try await state.load()
|
||||
return SdLoadModelResponse()
|
||||
|
Reference in New Issue
Block a user