Formatting, linting, and hopefully a CI build.

This commit is contained in:
2023-04-22 15:43:22 -07:00
parent 2759c8d7fb
commit 4bf5ceefbe
13 changed files with 117 additions and 68 deletions

View File

@ -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()