2023-04-22 14:52:27 -07:00
|
|
|
import Foundation
|
|
|
|
import GRPC
|
2023-04-22 15:43:22 -07:00
|
|
|
import StableDiffusionCore
|
2023-04-22 14:52:27 -07:00
|
|
|
import StableDiffusionProtos
|
|
|
|
|
2023-05-08 22:12:24 -07:00
|
|
|
class HostModelServiceProvider: SdHostModelServiceAsyncProvider {
|
2023-04-22 14:52:27 -07:00
|
|
|
private let modelManager: ModelManager
|
2023-04-22 15:43:22 -07:00
|
|
|
|
2023-04-22 14:52:27 -07:00
|
|
|
init(modelManager: ModelManager) {
|
|
|
|
self.modelManager = modelManager
|
|
|
|
}
|
2023-04-22 15:43:22 -07:00
|
|
|
|
|
|
|
func loadModel(request: SdLoadModelRequest, context _: GRPCAsyncServerCallContext) async throws -> SdLoadModelResponse {
|
2023-04-22 16:32:54 -07:00
|
|
|
let state = try await modelManager.createModelState(name: request.modelName)
|
2023-04-23 02:09:50 -07:00
|
|
|
try await state.load(request: request)
|
2023-04-22 14:52:27 -07:00
|
|
|
return SdLoadModelResponse()
|
|
|
|
}
|
|
|
|
}
|