2023-04-22 14:52:27 -07:00
|
|
|
//
|
|
|
|
// DO NOT EDIT.
|
|
|
|
//
|
|
|
|
// Generated by the protocol buffer compiler.
|
|
|
|
// Source: StableDiffusion.proto
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// Copyright 2018, gRPC Authors All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
import GRPC
|
|
|
|
import NIO
|
|
|
|
import NIOConcurrencyHelpers
|
|
|
|
import SwiftProtobuf
|
|
|
|
|
|
|
|
|
2023-04-23 02:09:50 -07:00
|
|
|
///*
|
|
|
|
/// The model service, for management and loading of models.
|
|
|
|
///
|
2023-04-22 14:52:27 -07:00
|
|
|
/// Usage: instantiate `SdModelServiceClient`, then call methods of this protocol to make API calls.
|
|
|
|
public protocol SdModelServiceClientProtocol: GRPCClient {
|
|
|
|
var serviceName: String { get }
|
|
|
|
var interceptors: SdModelServiceClientInterceptorFactoryProtocol? { get }
|
|
|
|
|
|
|
|
func listModels(
|
|
|
|
_ request: SdListModelsRequest,
|
|
|
|
callOptions: CallOptions?
|
|
|
|
) -> UnaryCall<SdListModelsRequest, SdListModelsResponse>
|
|
|
|
|
|
|
|
func loadModel(
|
|
|
|
_ request: SdLoadModelRequest,
|
|
|
|
callOptions: CallOptions?
|
|
|
|
) -> UnaryCall<SdLoadModelRequest, SdLoadModelResponse>
|
|
|
|
}
|
|
|
|
|
|
|
|
extension SdModelServiceClientProtocol {
|
|
|
|
public var serviceName: String {
|
|
|
|
return "gay.pizza.stable.diffusion.ModelService"
|
|
|
|
}
|
|
|
|
|
2023-04-23 02:09:50 -07:00
|
|
|
///*
|
|
|
|
/// Lists the available models on the host.
|
|
|
|
/// This will return both models that are currently loaded, and models that are not yet loaded.
|
2023-04-22 14:52:27 -07:00
|
|
|
///
|
|
|
|
/// - Parameters:
|
|
|
|
/// - request: Request to send to ListModels.
|
|
|
|
/// - callOptions: Call options.
|
|
|
|
/// - Returns: A `UnaryCall` with futures for the metadata, status and response.
|
|
|
|
public func listModels(
|
|
|
|
_ request: SdListModelsRequest,
|
|
|
|
callOptions: CallOptions? = nil
|
|
|
|
) -> UnaryCall<SdListModelsRequest, SdListModelsResponse> {
|
|
|
|
return self.makeUnaryCall(
|
|
|
|
path: SdModelServiceClientMetadata.Methods.listModels.path,
|
|
|
|
request: request,
|
|
|
|
callOptions: callOptions ?? self.defaultCallOptions,
|
|
|
|
interceptors: self.interceptors?.makeListModelsInterceptors() ?? []
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2023-04-23 02:09:50 -07:00
|
|
|
///*
|
|
|
|
/// Loads a model onto a compute unit.
|
2023-04-22 14:52:27 -07:00
|
|
|
///
|
|
|
|
/// - Parameters:
|
|
|
|
/// - request: Request to send to LoadModel.
|
|
|
|
/// - callOptions: Call options.
|
|
|
|
/// - Returns: A `UnaryCall` with futures for the metadata, status and response.
|
|
|
|
public func loadModel(
|
|
|
|
_ request: SdLoadModelRequest,
|
|
|
|
callOptions: CallOptions? = nil
|
|
|
|
) -> UnaryCall<SdLoadModelRequest, SdLoadModelResponse> {
|
|
|
|
return self.makeUnaryCall(
|
|
|
|
path: SdModelServiceClientMetadata.Methods.loadModel.path,
|
|
|
|
request: request,
|
|
|
|
callOptions: callOptions ?? self.defaultCallOptions,
|
|
|
|
interceptors: self.interceptors?.makeLoadModelInterceptors() ?? []
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if compiler(>=5.6)
|
|
|
|
@available(*, deprecated)
|
|
|
|
extension SdModelServiceClient: @unchecked Sendable {}
|
|
|
|
#endif // compiler(>=5.6)
|
|
|
|
|
|
|
|
@available(*, deprecated, renamed: "SdModelServiceNIOClient")
|
|
|
|
public final class SdModelServiceClient: SdModelServiceClientProtocol {
|
|
|
|
private let lock = Lock()
|
|
|
|
private var _defaultCallOptions: CallOptions
|
|
|
|
private var _interceptors: SdModelServiceClientInterceptorFactoryProtocol?
|
|
|
|
public let channel: GRPCChannel
|
|
|
|
public var defaultCallOptions: CallOptions {
|
|
|
|
get { self.lock.withLock { return self._defaultCallOptions } }
|
|
|
|
set { self.lock.withLockVoid { self._defaultCallOptions = newValue } }
|
|
|
|
}
|
|
|
|
public var interceptors: SdModelServiceClientInterceptorFactoryProtocol? {
|
|
|
|
get { self.lock.withLock { return self._interceptors } }
|
|
|
|
set { self.lock.withLockVoid { self._interceptors = newValue } }
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Creates a client for the gay.pizza.stable.diffusion.ModelService service.
|
|
|
|
///
|
|
|
|
/// - Parameters:
|
|
|
|
/// - channel: `GRPCChannel` to the service host.
|
|
|
|
/// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
|
|
|
|
/// - interceptors: A factory providing interceptors for each RPC.
|
|
|
|
public init(
|
|
|
|
channel: GRPCChannel,
|
|
|
|
defaultCallOptions: CallOptions = CallOptions(),
|
|
|
|
interceptors: SdModelServiceClientInterceptorFactoryProtocol? = nil
|
|
|
|
) {
|
|
|
|
self.channel = channel
|
|
|
|
self._defaultCallOptions = defaultCallOptions
|
|
|
|
self._interceptors = interceptors
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public struct SdModelServiceNIOClient: SdModelServiceClientProtocol {
|
|
|
|
public var channel: GRPCChannel
|
|
|
|
public var defaultCallOptions: CallOptions
|
|
|
|
public var interceptors: SdModelServiceClientInterceptorFactoryProtocol?
|
|
|
|
|
|
|
|
/// Creates a client for the gay.pizza.stable.diffusion.ModelService service.
|
|
|
|
///
|
|
|
|
/// - Parameters:
|
|
|
|
/// - channel: `GRPCChannel` to the service host.
|
|
|
|
/// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
|
|
|
|
/// - interceptors: A factory providing interceptors for each RPC.
|
|
|
|
public init(
|
|
|
|
channel: GRPCChannel,
|
|
|
|
defaultCallOptions: CallOptions = CallOptions(),
|
|
|
|
interceptors: SdModelServiceClientInterceptorFactoryProtocol? = nil
|
|
|
|
) {
|
|
|
|
self.channel = channel
|
|
|
|
self.defaultCallOptions = defaultCallOptions
|
|
|
|
self.interceptors = interceptors
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if compiler(>=5.6)
|
2023-04-23 02:09:50 -07:00
|
|
|
///*
|
|
|
|
/// The model service, for management and loading of models.
|
2023-04-22 14:52:27 -07:00
|
|
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
|
|
|
public protocol SdModelServiceAsyncClientProtocol: GRPCClient {
|
|
|
|
static var serviceDescriptor: GRPCServiceDescriptor { get }
|
|
|
|
var interceptors: SdModelServiceClientInterceptorFactoryProtocol? { get }
|
|
|
|
|
|
|
|
func makeListModelsCall(
|
|
|
|
_ request: SdListModelsRequest,
|
|
|
|
callOptions: CallOptions?
|
|
|
|
) -> GRPCAsyncUnaryCall<SdListModelsRequest, SdListModelsResponse>
|
|
|
|
|
|
|
|
func makeLoadModelCall(
|
|
|
|
_ request: SdLoadModelRequest,
|
|
|
|
callOptions: CallOptions?
|
|
|
|
) -> GRPCAsyncUnaryCall<SdLoadModelRequest, SdLoadModelResponse>
|
|
|
|
}
|
|
|
|
|
|
|
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
|
|
|
extension SdModelServiceAsyncClientProtocol {
|
|
|
|
public static var serviceDescriptor: GRPCServiceDescriptor {
|
|
|
|
return SdModelServiceClientMetadata.serviceDescriptor
|
|
|
|
}
|
|
|
|
|
|
|
|
public var interceptors: SdModelServiceClientInterceptorFactoryProtocol? {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
public func makeListModelsCall(
|
|
|
|
_ request: SdListModelsRequest,
|
|
|
|
callOptions: CallOptions? = nil
|
|
|
|
) -> GRPCAsyncUnaryCall<SdListModelsRequest, SdListModelsResponse> {
|
|
|
|
return self.makeAsyncUnaryCall(
|
|
|
|
path: SdModelServiceClientMetadata.Methods.listModels.path,
|
|
|
|
request: request,
|
|
|
|
callOptions: callOptions ?? self.defaultCallOptions,
|
|
|
|
interceptors: self.interceptors?.makeListModelsInterceptors() ?? []
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
public func makeLoadModelCall(
|
|
|
|
_ request: SdLoadModelRequest,
|
|
|
|
callOptions: CallOptions? = nil
|
|
|
|
) -> GRPCAsyncUnaryCall<SdLoadModelRequest, SdLoadModelResponse> {
|
|
|
|
return self.makeAsyncUnaryCall(
|
|
|
|
path: SdModelServiceClientMetadata.Methods.loadModel.path,
|
|
|
|
request: request,
|
|
|
|
callOptions: callOptions ?? self.defaultCallOptions,
|
|
|
|
interceptors: self.interceptors?.makeLoadModelInterceptors() ?? []
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
|
|
|
extension SdModelServiceAsyncClientProtocol {
|
|
|
|
public func listModels(
|
|
|
|
_ request: SdListModelsRequest,
|
|
|
|
callOptions: CallOptions? = nil
|
|
|
|
) async throws -> SdListModelsResponse {
|
|
|
|
return try await self.performAsyncUnaryCall(
|
|
|
|
path: SdModelServiceClientMetadata.Methods.listModels.path,
|
|
|
|
request: request,
|
|
|
|
callOptions: callOptions ?? self.defaultCallOptions,
|
|
|
|
interceptors: self.interceptors?.makeListModelsInterceptors() ?? []
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
public func loadModel(
|
|
|
|
_ request: SdLoadModelRequest,
|
|
|
|
callOptions: CallOptions? = nil
|
|
|
|
) async throws -> SdLoadModelResponse {
|
|
|
|
return try await self.performAsyncUnaryCall(
|
|
|
|
path: SdModelServiceClientMetadata.Methods.loadModel.path,
|
|
|
|
request: request,
|
|
|
|
callOptions: callOptions ?? self.defaultCallOptions,
|
|
|
|
interceptors: self.interceptors?.makeLoadModelInterceptors() ?? []
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
|
|
|
public struct SdModelServiceAsyncClient: SdModelServiceAsyncClientProtocol {
|
|
|
|
public var channel: GRPCChannel
|
|
|
|
public var defaultCallOptions: CallOptions
|
|
|
|
public var interceptors: SdModelServiceClientInterceptorFactoryProtocol?
|
|
|
|
|
|
|
|
public init(
|
|
|
|
channel: GRPCChannel,
|
|
|
|
defaultCallOptions: CallOptions = CallOptions(),
|
|
|
|
interceptors: SdModelServiceClientInterceptorFactoryProtocol? = nil
|
|
|
|
) {
|
|
|
|
self.channel = channel
|
|
|
|
self.defaultCallOptions = defaultCallOptions
|
|
|
|
self.interceptors = interceptors
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // compiler(>=5.6)
|
|
|
|
|
|
|
|
public protocol SdModelServiceClientInterceptorFactoryProtocol: GRPCSendable {
|
|
|
|
|
|
|
|
/// - Returns: Interceptors to use when invoking 'listModels'.
|
|
|
|
func makeListModelsInterceptors() -> [ClientInterceptor<SdListModelsRequest, SdListModelsResponse>]
|
|
|
|
|
|
|
|
/// - Returns: Interceptors to use when invoking 'loadModel'.
|
|
|
|
func makeLoadModelInterceptors() -> [ClientInterceptor<SdLoadModelRequest, SdLoadModelResponse>]
|
|
|
|
}
|
|
|
|
|
|
|
|
public enum SdModelServiceClientMetadata {
|
|
|
|
public static let serviceDescriptor = GRPCServiceDescriptor(
|
|
|
|
name: "ModelService",
|
|
|
|
fullName: "gay.pizza.stable.diffusion.ModelService",
|
|
|
|
methods: [
|
|
|
|
SdModelServiceClientMetadata.Methods.listModels,
|
|
|
|
SdModelServiceClientMetadata.Methods.loadModel,
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
public enum Methods {
|
|
|
|
public static let listModels = GRPCMethodDescriptor(
|
|
|
|
name: "ListModels",
|
|
|
|
path: "/gay.pizza.stable.diffusion.ModelService/ListModels",
|
|
|
|
type: GRPCCallType.unary
|
|
|
|
)
|
|
|
|
|
|
|
|
public static let loadModel = GRPCMethodDescriptor(
|
|
|
|
name: "LoadModel",
|
|
|
|
path: "/gay.pizza.stable.diffusion.ModelService/LoadModel",
|
|
|
|
type: GRPCCallType.unary
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-23 02:09:50 -07:00
|
|
|
///*
|
|
|
|
/// The image generation service, for generating images from loaded models.
|
|
|
|
///
|
2023-04-22 14:52:27 -07:00
|
|
|
/// Usage: instantiate `SdImageGenerationServiceClient`, then call methods of this protocol to make API calls.
|
|
|
|
public protocol SdImageGenerationServiceClientProtocol: GRPCClient {
|
|
|
|
var serviceName: String { get }
|
|
|
|
var interceptors: SdImageGenerationServiceClientInterceptorFactoryProtocol? { get }
|
|
|
|
|
2023-04-23 02:09:50 -07:00
|
|
|
func generateImages(
|
2023-04-22 14:52:27 -07:00
|
|
|
_ request: SdGenerateImagesRequest,
|
|
|
|
callOptions: CallOptions?
|
|
|
|
) -> UnaryCall<SdGenerateImagesRequest, SdGenerateImagesResponse>
|
2023-04-23 14:22:10 -07:00
|
|
|
|
|
|
|
func generateImagesStreaming(
|
|
|
|
_ request: SdGenerateImagesRequest,
|
|
|
|
callOptions: CallOptions?,
|
|
|
|
handler: @escaping (SdGenerateImagesStreamUpdate) -> Void
|
|
|
|
) -> ServerStreamingCall<SdGenerateImagesRequest, SdGenerateImagesStreamUpdate>
|
2023-04-22 14:52:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
extension SdImageGenerationServiceClientProtocol {
|
|
|
|
public var serviceName: String {
|
|
|
|
return "gay.pizza.stable.diffusion.ImageGenerationService"
|
|
|
|
}
|
|
|
|
|
2023-04-23 02:09:50 -07:00
|
|
|
///*
|
|
|
|
/// Generates images using a loaded model.
|
2023-04-22 14:52:27 -07:00
|
|
|
///
|
|
|
|
/// - Parameters:
|
2023-04-23 02:09:50 -07:00
|
|
|
/// - request: Request to send to GenerateImages.
|
2023-04-22 14:52:27 -07:00
|
|
|
/// - callOptions: Call options.
|
|
|
|
/// - Returns: A `UnaryCall` with futures for the metadata, status and response.
|
2023-04-23 02:09:50 -07:00
|
|
|
public func generateImages(
|
2023-04-22 14:52:27 -07:00
|
|
|
_ request: SdGenerateImagesRequest,
|
|
|
|
callOptions: CallOptions? = nil
|
|
|
|
) -> UnaryCall<SdGenerateImagesRequest, SdGenerateImagesResponse> {
|
|
|
|
return self.makeUnaryCall(
|
2023-04-23 02:09:50 -07:00
|
|
|
path: SdImageGenerationServiceClientMetadata.Methods.generateImages.path,
|
2023-04-22 14:52:27 -07:00
|
|
|
request: request,
|
|
|
|
callOptions: callOptions ?? self.defaultCallOptions,
|
2023-04-23 02:09:50 -07:00
|
|
|
interceptors: self.interceptors?.makeGenerateImagesInterceptors() ?? []
|
2023-04-22 14:52:27 -07:00
|
|
|
)
|
|
|
|
}
|
2023-04-23 14:22:10 -07:00
|
|
|
|
2023-04-23 14:50:45 -07:00
|
|
|
///*
|
|
|
|
/// Generates images using a loaded model, providing updates along the way.
|
2023-04-23 14:22:10 -07:00
|
|
|
///
|
|
|
|
/// - Parameters:
|
|
|
|
/// - request: Request to send to GenerateImagesStreaming.
|
|
|
|
/// - callOptions: Call options.
|
|
|
|
/// - handler: A closure called when each response is received from the server.
|
|
|
|
/// - Returns: A `ServerStreamingCall` with futures for the metadata and status.
|
|
|
|
public func generateImagesStreaming(
|
|
|
|
_ request: SdGenerateImagesRequest,
|
|
|
|
callOptions: CallOptions? = nil,
|
|
|
|
handler: @escaping (SdGenerateImagesStreamUpdate) -> Void
|
|
|
|
) -> ServerStreamingCall<SdGenerateImagesRequest, SdGenerateImagesStreamUpdate> {
|
|
|
|
return self.makeServerStreamingCall(
|
|
|
|
path: SdImageGenerationServiceClientMetadata.Methods.generateImagesStreaming.path,
|
|
|
|
request: request,
|
|
|
|
callOptions: callOptions ?? self.defaultCallOptions,
|
|
|
|
interceptors: self.interceptors?.makeGenerateImagesStreamingInterceptors() ?? [],
|
|
|
|
handler: handler
|
|
|
|
)
|
|
|
|
}
|
2023-04-22 14:52:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#if compiler(>=5.6)
|
|
|
|
@available(*, deprecated)
|
|
|
|
extension SdImageGenerationServiceClient: @unchecked Sendable {}
|
|
|
|
#endif // compiler(>=5.6)
|
|
|
|
|
|
|
|
@available(*, deprecated, renamed: "SdImageGenerationServiceNIOClient")
|
|
|
|
public final class SdImageGenerationServiceClient: SdImageGenerationServiceClientProtocol {
|
|
|
|
private let lock = Lock()
|
|
|
|
private var _defaultCallOptions: CallOptions
|
|
|
|
private var _interceptors: SdImageGenerationServiceClientInterceptorFactoryProtocol?
|
|
|
|
public let channel: GRPCChannel
|
|
|
|
public var defaultCallOptions: CallOptions {
|
|
|
|
get { self.lock.withLock { return self._defaultCallOptions } }
|
|
|
|
set { self.lock.withLockVoid { self._defaultCallOptions = newValue } }
|
|
|
|
}
|
|
|
|
public var interceptors: SdImageGenerationServiceClientInterceptorFactoryProtocol? {
|
|
|
|
get { self.lock.withLock { return self._interceptors } }
|
|
|
|
set { self.lock.withLockVoid { self._interceptors = newValue } }
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Creates a client for the gay.pizza.stable.diffusion.ImageGenerationService service.
|
|
|
|
///
|
|
|
|
/// - Parameters:
|
|
|
|
/// - channel: `GRPCChannel` to the service host.
|
|
|
|
/// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
|
|
|
|
/// - interceptors: A factory providing interceptors for each RPC.
|
|
|
|
public init(
|
|
|
|
channel: GRPCChannel,
|
|
|
|
defaultCallOptions: CallOptions = CallOptions(),
|
|
|
|
interceptors: SdImageGenerationServiceClientInterceptorFactoryProtocol? = nil
|
|
|
|
) {
|
|
|
|
self.channel = channel
|
|
|
|
self._defaultCallOptions = defaultCallOptions
|
|
|
|
self._interceptors = interceptors
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public struct SdImageGenerationServiceNIOClient: SdImageGenerationServiceClientProtocol {
|
|
|
|
public var channel: GRPCChannel
|
|
|
|
public var defaultCallOptions: CallOptions
|
|
|
|
public var interceptors: SdImageGenerationServiceClientInterceptorFactoryProtocol?
|
|
|
|
|
|
|
|
/// Creates a client for the gay.pizza.stable.diffusion.ImageGenerationService service.
|
|
|
|
///
|
|
|
|
/// - Parameters:
|
|
|
|
/// - channel: `GRPCChannel` to the service host.
|
|
|
|
/// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
|
|
|
|
/// - interceptors: A factory providing interceptors for each RPC.
|
|
|
|
public init(
|
|
|
|
channel: GRPCChannel,
|
|
|
|
defaultCallOptions: CallOptions = CallOptions(),
|
|
|
|
interceptors: SdImageGenerationServiceClientInterceptorFactoryProtocol? = nil
|
|
|
|
) {
|
|
|
|
self.channel = channel
|
|
|
|
self.defaultCallOptions = defaultCallOptions
|
|
|
|
self.interceptors = interceptors
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if compiler(>=5.6)
|
2023-04-23 02:09:50 -07:00
|
|
|
///*
|
|
|
|
/// The image generation service, for generating images from loaded models.
|
2023-04-22 14:52:27 -07:00
|
|
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
|
|
|
public protocol SdImageGenerationServiceAsyncClientProtocol: GRPCClient {
|
|
|
|
static var serviceDescriptor: GRPCServiceDescriptor { get }
|
|
|
|
var interceptors: SdImageGenerationServiceClientInterceptorFactoryProtocol? { get }
|
|
|
|
|
2023-04-23 02:09:50 -07:00
|
|
|
func makeGenerateImagesCall(
|
2023-04-22 14:52:27 -07:00
|
|
|
_ request: SdGenerateImagesRequest,
|
|
|
|
callOptions: CallOptions?
|
|
|
|
) -> GRPCAsyncUnaryCall<SdGenerateImagesRequest, SdGenerateImagesResponse>
|
2023-04-23 14:22:10 -07:00
|
|
|
|
|
|
|
func makeGenerateImagesStreamingCall(
|
|
|
|
_ request: SdGenerateImagesRequest,
|
|
|
|
callOptions: CallOptions?
|
|
|
|
) -> GRPCAsyncServerStreamingCall<SdGenerateImagesRequest, SdGenerateImagesStreamUpdate>
|
2023-04-22 14:52:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
|
|
|
extension SdImageGenerationServiceAsyncClientProtocol {
|
|
|
|
public static var serviceDescriptor: GRPCServiceDescriptor {
|
|
|
|
return SdImageGenerationServiceClientMetadata.serviceDescriptor
|
|
|
|
}
|
|
|
|
|
|
|
|
public var interceptors: SdImageGenerationServiceClientInterceptorFactoryProtocol? {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-04-23 02:09:50 -07:00
|
|
|
public func makeGenerateImagesCall(
|
2023-04-22 14:52:27 -07:00
|
|
|
_ request: SdGenerateImagesRequest,
|
|
|
|
callOptions: CallOptions? = nil
|
|
|
|
) -> GRPCAsyncUnaryCall<SdGenerateImagesRequest, SdGenerateImagesResponse> {
|
|
|
|
return self.makeAsyncUnaryCall(
|
2023-04-23 02:09:50 -07:00
|
|
|
path: SdImageGenerationServiceClientMetadata.Methods.generateImages.path,
|
2023-04-22 14:52:27 -07:00
|
|
|
request: request,
|
|
|
|
callOptions: callOptions ?? self.defaultCallOptions,
|
2023-04-23 02:09:50 -07:00
|
|
|
interceptors: self.interceptors?.makeGenerateImagesInterceptors() ?? []
|
2023-04-22 14:52:27 -07:00
|
|
|
)
|
|
|
|
}
|
2023-04-23 14:22:10 -07:00
|
|
|
|
|
|
|
public func makeGenerateImagesStreamingCall(
|
|
|
|
_ request: SdGenerateImagesRequest,
|
|
|
|
callOptions: CallOptions? = nil
|
|
|
|
) -> GRPCAsyncServerStreamingCall<SdGenerateImagesRequest, SdGenerateImagesStreamUpdate> {
|
|
|
|
return self.makeAsyncServerStreamingCall(
|
|
|
|
path: SdImageGenerationServiceClientMetadata.Methods.generateImagesStreaming.path,
|
|
|
|
request: request,
|
|
|
|
callOptions: callOptions ?? self.defaultCallOptions,
|
|
|
|
interceptors: self.interceptors?.makeGenerateImagesStreamingInterceptors() ?? []
|
|
|
|
)
|
|
|
|
}
|
2023-04-22 14:52:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
|
|
|
extension SdImageGenerationServiceAsyncClientProtocol {
|
2023-04-23 02:09:50 -07:00
|
|
|
public func generateImages(
|
2023-04-22 14:52:27 -07:00
|
|
|
_ request: SdGenerateImagesRequest,
|
|
|
|
callOptions: CallOptions? = nil
|
|
|
|
) async throws -> SdGenerateImagesResponse {
|
|
|
|
return try await self.performAsyncUnaryCall(
|
2023-04-23 02:09:50 -07:00
|
|
|
path: SdImageGenerationServiceClientMetadata.Methods.generateImages.path,
|
2023-04-22 14:52:27 -07:00
|
|
|
request: request,
|
|
|
|
callOptions: callOptions ?? self.defaultCallOptions,
|
2023-04-23 02:09:50 -07:00
|
|
|
interceptors: self.interceptors?.makeGenerateImagesInterceptors() ?? []
|
2023-04-22 14:52:27 -07:00
|
|
|
)
|
|
|
|
}
|
2023-04-23 14:22:10 -07:00
|
|
|
|
|
|
|
public func generateImagesStreaming(
|
|
|
|
_ request: SdGenerateImagesRequest,
|
|
|
|
callOptions: CallOptions? = nil
|
|
|
|
) -> GRPCAsyncResponseStream<SdGenerateImagesStreamUpdate> {
|
|
|
|
return self.performAsyncServerStreamingCall(
|
|
|
|
path: SdImageGenerationServiceClientMetadata.Methods.generateImagesStreaming.path,
|
|
|
|
request: request,
|
|
|
|
callOptions: callOptions ?? self.defaultCallOptions,
|
|
|
|
interceptors: self.interceptors?.makeGenerateImagesStreamingInterceptors() ?? []
|
|
|
|
)
|
|
|
|
}
|
2023-04-22 14:52:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
|
|
|
public struct SdImageGenerationServiceAsyncClient: SdImageGenerationServiceAsyncClientProtocol {
|
|
|
|
public var channel: GRPCChannel
|
|
|
|
public var defaultCallOptions: CallOptions
|
|
|
|
public var interceptors: SdImageGenerationServiceClientInterceptorFactoryProtocol?
|
|
|
|
|
|
|
|
public init(
|
|
|
|
channel: GRPCChannel,
|
|
|
|
defaultCallOptions: CallOptions = CallOptions(),
|
|
|
|
interceptors: SdImageGenerationServiceClientInterceptorFactoryProtocol? = nil
|
|
|
|
) {
|
|
|
|
self.channel = channel
|
|
|
|
self.defaultCallOptions = defaultCallOptions
|
|
|
|
self.interceptors = interceptors
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // compiler(>=5.6)
|
|
|
|
|
|
|
|
public protocol SdImageGenerationServiceClientInterceptorFactoryProtocol: GRPCSendable {
|
|
|
|
|
2023-04-23 02:09:50 -07:00
|
|
|
/// - Returns: Interceptors to use when invoking 'generateImages'.
|
|
|
|
func makeGenerateImagesInterceptors() -> [ClientInterceptor<SdGenerateImagesRequest, SdGenerateImagesResponse>]
|
2023-04-23 14:22:10 -07:00
|
|
|
|
|
|
|
/// - Returns: Interceptors to use when invoking 'generateImagesStreaming'.
|
|
|
|
func makeGenerateImagesStreamingInterceptors() -> [ClientInterceptor<SdGenerateImagesRequest, SdGenerateImagesStreamUpdate>]
|
2023-04-22 14:52:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public enum SdImageGenerationServiceClientMetadata {
|
|
|
|
public static let serviceDescriptor = GRPCServiceDescriptor(
|
|
|
|
name: "ImageGenerationService",
|
|
|
|
fullName: "gay.pizza.stable.diffusion.ImageGenerationService",
|
|
|
|
methods: [
|
2023-04-23 02:09:50 -07:00
|
|
|
SdImageGenerationServiceClientMetadata.Methods.generateImages,
|
2023-04-23 14:22:10 -07:00
|
|
|
SdImageGenerationServiceClientMetadata.Methods.generateImagesStreaming,
|
2023-04-22 14:52:27 -07:00
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
public enum Methods {
|
2023-04-23 02:09:50 -07:00
|
|
|
public static let generateImages = GRPCMethodDescriptor(
|
|
|
|
name: "GenerateImages",
|
|
|
|
path: "/gay.pizza.stable.diffusion.ImageGenerationService/GenerateImages",
|
2023-04-22 14:52:27 -07:00
|
|
|
type: GRPCCallType.unary
|
|
|
|
)
|
2023-04-23 14:22:10 -07:00
|
|
|
|
|
|
|
public static let generateImagesStreaming = GRPCMethodDescriptor(
|
|
|
|
name: "GenerateImagesStreaming",
|
|
|
|
path: "/gay.pizza.stable.diffusion.ImageGenerationService/GenerateImagesStreaming",
|
|
|
|
type: GRPCCallType.serverStreaming
|
|
|
|
)
|
2023-04-22 14:52:27 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-23 18:49:52 -07:00
|
|
|
///*
|
|
|
|
/// The tokenizer service, for analyzing tokens for a loaded model.
|
|
|
|
///
|
|
|
|
/// Usage: instantiate `SdTokenizerServiceClient`, then call methods of this protocol to make API calls.
|
|
|
|
public protocol SdTokenizerServiceClientProtocol: GRPCClient {
|
|
|
|
var serviceName: String { get }
|
|
|
|
var interceptors: SdTokenizerServiceClientInterceptorFactoryProtocol? { get }
|
|
|
|
|
|
|
|
func tokenize(
|
|
|
|
_ request: SdTokenizeRequest,
|
|
|
|
callOptions: CallOptions?
|
|
|
|
) -> UnaryCall<SdTokenizeRequest, SdTokenizeResponse>
|
|
|
|
}
|
|
|
|
|
|
|
|
extension SdTokenizerServiceClientProtocol {
|
|
|
|
public var serviceName: String {
|
|
|
|
return "gay.pizza.stable.diffusion.TokenizerService"
|
|
|
|
}
|
|
|
|
|
|
|
|
///*
|
|
|
|
/// Analyze the input using a loaded model and return the results.
|
|
|
|
///
|
|
|
|
/// - Parameters:
|
|
|
|
/// - request: Request to send to Tokenize.
|
|
|
|
/// - callOptions: Call options.
|
|
|
|
/// - Returns: A `UnaryCall` with futures for the metadata, status and response.
|
|
|
|
public func tokenize(
|
|
|
|
_ request: SdTokenizeRequest,
|
|
|
|
callOptions: CallOptions? = nil
|
|
|
|
) -> UnaryCall<SdTokenizeRequest, SdTokenizeResponse> {
|
|
|
|
return self.makeUnaryCall(
|
|
|
|
path: SdTokenizerServiceClientMetadata.Methods.tokenize.path,
|
|
|
|
request: request,
|
|
|
|
callOptions: callOptions ?? self.defaultCallOptions,
|
|
|
|
interceptors: self.interceptors?.makeTokenizeInterceptors() ?? []
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if compiler(>=5.6)
|
|
|
|
@available(*, deprecated)
|
|
|
|
extension SdTokenizerServiceClient: @unchecked Sendable {}
|
|
|
|
#endif // compiler(>=5.6)
|
|
|
|
|
|
|
|
@available(*, deprecated, renamed: "SdTokenizerServiceNIOClient")
|
|
|
|
public final class SdTokenizerServiceClient: SdTokenizerServiceClientProtocol {
|
|
|
|
private let lock = Lock()
|
|
|
|
private var _defaultCallOptions: CallOptions
|
|
|
|
private var _interceptors: SdTokenizerServiceClientInterceptorFactoryProtocol?
|
|
|
|
public let channel: GRPCChannel
|
|
|
|
public var defaultCallOptions: CallOptions {
|
|
|
|
get { self.lock.withLock { return self._defaultCallOptions } }
|
|
|
|
set { self.lock.withLockVoid { self._defaultCallOptions = newValue } }
|
|
|
|
}
|
|
|
|
public var interceptors: SdTokenizerServiceClientInterceptorFactoryProtocol? {
|
|
|
|
get { self.lock.withLock { return self._interceptors } }
|
|
|
|
set { self.lock.withLockVoid { self._interceptors = newValue } }
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Creates a client for the gay.pizza.stable.diffusion.TokenizerService service.
|
|
|
|
///
|
|
|
|
/// - Parameters:
|
|
|
|
/// - channel: `GRPCChannel` to the service host.
|
|
|
|
/// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
|
|
|
|
/// - interceptors: A factory providing interceptors for each RPC.
|
|
|
|
public init(
|
|
|
|
channel: GRPCChannel,
|
|
|
|
defaultCallOptions: CallOptions = CallOptions(),
|
|
|
|
interceptors: SdTokenizerServiceClientInterceptorFactoryProtocol? = nil
|
|
|
|
) {
|
|
|
|
self.channel = channel
|
|
|
|
self._defaultCallOptions = defaultCallOptions
|
|
|
|
self._interceptors = interceptors
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public struct SdTokenizerServiceNIOClient: SdTokenizerServiceClientProtocol {
|
|
|
|
public var channel: GRPCChannel
|
|
|
|
public var defaultCallOptions: CallOptions
|
|
|
|
public var interceptors: SdTokenizerServiceClientInterceptorFactoryProtocol?
|
|
|
|
|
|
|
|
/// Creates a client for the gay.pizza.stable.diffusion.TokenizerService service.
|
|
|
|
///
|
|
|
|
/// - Parameters:
|
|
|
|
/// - channel: `GRPCChannel` to the service host.
|
|
|
|
/// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
|
|
|
|
/// - interceptors: A factory providing interceptors for each RPC.
|
|
|
|
public init(
|
|
|
|
channel: GRPCChannel,
|
|
|
|
defaultCallOptions: CallOptions = CallOptions(),
|
|
|
|
interceptors: SdTokenizerServiceClientInterceptorFactoryProtocol? = nil
|
|
|
|
) {
|
|
|
|
self.channel = channel
|
|
|
|
self.defaultCallOptions = defaultCallOptions
|
|
|
|
self.interceptors = interceptors
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if compiler(>=5.6)
|
|
|
|
///*
|
|
|
|
/// The tokenizer service, for analyzing tokens for a loaded model.
|
|
|
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
|
|
|
public protocol SdTokenizerServiceAsyncClientProtocol: GRPCClient {
|
|
|
|
static var serviceDescriptor: GRPCServiceDescriptor { get }
|
|
|
|
var interceptors: SdTokenizerServiceClientInterceptorFactoryProtocol? { get }
|
|
|
|
|
|
|
|
func makeTokenizeCall(
|
|
|
|
_ request: SdTokenizeRequest,
|
|
|
|
callOptions: CallOptions?
|
|
|
|
) -> GRPCAsyncUnaryCall<SdTokenizeRequest, SdTokenizeResponse>
|
|
|
|
}
|
|
|
|
|
|
|
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
|
|
|
extension SdTokenizerServiceAsyncClientProtocol {
|
|
|
|
public static var serviceDescriptor: GRPCServiceDescriptor {
|
|
|
|
return SdTokenizerServiceClientMetadata.serviceDescriptor
|
|
|
|
}
|
|
|
|
|
|
|
|
public var interceptors: SdTokenizerServiceClientInterceptorFactoryProtocol? {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
public func makeTokenizeCall(
|
|
|
|
_ request: SdTokenizeRequest,
|
|
|
|
callOptions: CallOptions? = nil
|
|
|
|
) -> GRPCAsyncUnaryCall<SdTokenizeRequest, SdTokenizeResponse> {
|
|
|
|
return self.makeAsyncUnaryCall(
|
|
|
|
path: SdTokenizerServiceClientMetadata.Methods.tokenize.path,
|
|
|
|
request: request,
|
|
|
|
callOptions: callOptions ?? self.defaultCallOptions,
|
|
|
|
interceptors: self.interceptors?.makeTokenizeInterceptors() ?? []
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
|
|
|
extension SdTokenizerServiceAsyncClientProtocol {
|
|
|
|
public func tokenize(
|
|
|
|
_ request: SdTokenizeRequest,
|
|
|
|
callOptions: CallOptions? = nil
|
|
|
|
) async throws -> SdTokenizeResponse {
|
|
|
|
return try await self.performAsyncUnaryCall(
|
|
|
|
path: SdTokenizerServiceClientMetadata.Methods.tokenize.path,
|
|
|
|
request: request,
|
|
|
|
callOptions: callOptions ?? self.defaultCallOptions,
|
|
|
|
interceptors: self.interceptors?.makeTokenizeInterceptors() ?? []
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
|
|
|
public struct SdTokenizerServiceAsyncClient: SdTokenizerServiceAsyncClientProtocol {
|
|
|
|
public var channel: GRPCChannel
|
|
|
|
public var defaultCallOptions: CallOptions
|
|
|
|
public var interceptors: SdTokenizerServiceClientInterceptorFactoryProtocol?
|
|
|
|
|
|
|
|
public init(
|
|
|
|
channel: GRPCChannel,
|
|
|
|
defaultCallOptions: CallOptions = CallOptions(),
|
|
|
|
interceptors: SdTokenizerServiceClientInterceptorFactoryProtocol? = nil
|
|
|
|
) {
|
|
|
|
self.channel = channel
|
|
|
|
self.defaultCallOptions = defaultCallOptions
|
|
|
|
self.interceptors = interceptors
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // compiler(>=5.6)
|
|
|
|
|
|
|
|
public protocol SdTokenizerServiceClientInterceptorFactoryProtocol: GRPCSendable {
|
|
|
|
|
|
|
|
/// - Returns: Interceptors to use when invoking 'tokenize'.
|
|
|
|
func makeTokenizeInterceptors() -> [ClientInterceptor<SdTokenizeRequest, SdTokenizeResponse>]
|
|
|
|
}
|
|
|
|
|
|
|
|
public enum SdTokenizerServiceClientMetadata {
|
|
|
|
public static let serviceDescriptor = GRPCServiceDescriptor(
|
|
|
|
name: "TokenizerService",
|
|
|
|
fullName: "gay.pizza.stable.diffusion.TokenizerService",
|
|
|
|
methods: [
|
|
|
|
SdTokenizerServiceClientMetadata.Methods.tokenize,
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
public enum Methods {
|
|
|
|
public static let tokenize = GRPCMethodDescriptor(
|
|
|
|
name: "Tokenize",
|
|
|
|
path: "/gay.pizza.stable.diffusion.TokenizerService/Tokenize",
|
|
|
|
type: GRPCCallType.unary
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-23 02:09:50 -07:00
|
|
|
///*
|
|
|
|
/// The model service, for management and loading of models.
|
|
|
|
///
|
2023-04-22 14:52:27 -07:00
|
|
|
/// To build a server, implement a class that conforms to this protocol.
|
|
|
|
public protocol SdModelServiceProvider: CallHandlerProvider {
|
|
|
|
var interceptors: SdModelServiceServerInterceptorFactoryProtocol? { get }
|
|
|
|
|
2023-04-23 02:09:50 -07:00
|
|
|
///*
|
|
|
|
/// Lists the available models on the host.
|
|
|
|
/// This will return both models that are currently loaded, and models that are not yet loaded.
|
2023-04-22 14:52:27 -07:00
|
|
|
func listModels(request: SdListModelsRequest, context: StatusOnlyCallContext) -> EventLoopFuture<SdListModelsResponse>
|
|
|
|
|
2023-04-23 02:09:50 -07:00
|
|
|
///*
|
|
|
|
/// Loads a model onto a compute unit.
|
2023-04-22 14:52:27 -07:00
|
|
|
func loadModel(request: SdLoadModelRequest, context: StatusOnlyCallContext) -> EventLoopFuture<SdLoadModelResponse>
|
|
|
|
}
|
|
|
|
|
|
|
|
extension SdModelServiceProvider {
|
|
|
|
public var serviceName: Substring {
|
|
|
|
return SdModelServiceServerMetadata.serviceDescriptor.fullName[...]
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Determines, calls and returns the appropriate request handler, depending on the request's method.
|
|
|
|
/// Returns nil for methods not handled by this service.
|
|
|
|
public func handle(
|
|
|
|
method name: Substring,
|
|
|
|
context: CallHandlerContext
|
|
|
|
) -> GRPCServerHandlerProtocol? {
|
|
|
|
switch name {
|
|
|
|
case "ListModels":
|
|
|
|
return UnaryServerHandler(
|
|
|
|
context: context,
|
|
|
|
requestDeserializer: ProtobufDeserializer<SdListModelsRequest>(),
|
|
|
|
responseSerializer: ProtobufSerializer<SdListModelsResponse>(),
|
|
|
|
interceptors: self.interceptors?.makeListModelsInterceptors() ?? [],
|
|
|
|
userFunction: self.listModels(request:context:)
|
|
|
|
)
|
|
|
|
|
|
|
|
case "LoadModel":
|
|
|
|
return UnaryServerHandler(
|
|
|
|
context: context,
|
|
|
|
requestDeserializer: ProtobufDeserializer<SdLoadModelRequest>(),
|
|
|
|
responseSerializer: ProtobufSerializer<SdLoadModelResponse>(),
|
|
|
|
interceptors: self.interceptors?.makeLoadModelInterceptors() ?? [],
|
|
|
|
userFunction: self.loadModel(request:context:)
|
|
|
|
)
|
|
|
|
|
|
|
|
default:
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if compiler(>=5.6)
|
|
|
|
|
2023-04-23 02:09:50 -07:00
|
|
|
///*
|
|
|
|
/// The model service, for management and loading of models.
|
|
|
|
///
|
2023-04-22 14:52:27 -07:00
|
|
|
/// To implement a server, implement an object which conforms to this protocol.
|
|
|
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
|
|
|
public protocol SdModelServiceAsyncProvider: CallHandlerProvider {
|
|
|
|
static var serviceDescriptor: GRPCServiceDescriptor { get }
|
|
|
|
var interceptors: SdModelServiceServerInterceptorFactoryProtocol? { get }
|
|
|
|
|
2023-04-23 02:09:50 -07:00
|
|
|
///*
|
|
|
|
/// Lists the available models on the host.
|
|
|
|
/// This will return both models that are currently loaded, and models that are not yet loaded.
|
2023-04-22 14:52:27 -07:00
|
|
|
@Sendable func listModels(
|
|
|
|
request: SdListModelsRequest,
|
|
|
|
context: GRPCAsyncServerCallContext
|
|
|
|
) async throws -> SdListModelsResponse
|
|
|
|
|
2023-04-23 02:09:50 -07:00
|
|
|
///*
|
|
|
|
/// Loads a model onto a compute unit.
|
2023-04-22 14:52:27 -07:00
|
|
|
@Sendable func loadModel(
|
|
|
|
request: SdLoadModelRequest,
|
|
|
|
context: GRPCAsyncServerCallContext
|
|
|
|
) async throws -> SdLoadModelResponse
|
|
|
|
}
|
|
|
|
|
|
|
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
|
|
|
extension SdModelServiceAsyncProvider {
|
|
|
|
public static var serviceDescriptor: GRPCServiceDescriptor {
|
|
|
|
return SdModelServiceServerMetadata.serviceDescriptor
|
|
|
|
}
|
|
|
|
|
|
|
|
public var serviceName: Substring {
|
|
|
|
return SdModelServiceServerMetadata.serviceDescriptor.fullName[...]
|
|
|
|
}
|
|
|
|
|
|
|
|
public var interceptors: SdModelServiceServerInterceptorFactoryProtocol? {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
public func handle(
|
|
|
|
method name: Substring,
|
|
|
|
context: CallHandlerContext
|
|
|
|
) -> GRPCServerHandlerProtocol? {
|
|
|
|
switch name {
|
|
|
|
case "ListModels":
|
|
|
|
return GRPCAsyncServerHandler(
|
|
|
|
context: context,
|
|
|
|
requestDeserializer: ProtobufDeserializer<SdListModelsRequest>(),
|
|
|
|
responseSerializer: ProtobufSerializer<SdListModelsResponse>(),
|
|
|
|
interceptors: self.interceptors?.makeListModelsInterceptors() ?? [],
|
|
|
|
wrapping: self.listModels(request:context:)
|
|
|
|
)
|
|
|
|
|
|
|
|
case "LoadModel":
|
|
|
|
return GRPCAsyncServerHandler(
|
|
|
|
context: context,
|
|
|
|
requestDeserializer: ProtobufDeserializer<SdLoadModelRequest>(),
|
|
|
|
responseSerializer: ProtobufSerializer<SdLoadModelResponse>(),
|
|
|
|
interceptors: self.interceptors?.makeLoadModelInterceptors() ?? [],
|
|
|
|
wrapping: self.loadModel(request:context:)
|
|
|
|
)
|
|
|
|
|
|
|
|
default:
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // compiler(>=5.6)
|
|
|
|
|
|
|
|
public protocol SdModelServiceServerInterceptorFactoryProtocol {
|
|
|
|
|
|
|
|
/// - Returns: Interceptors to use when handling 'listModels'.
|
|
|
|
/// Defaults to calling `self.makeInterceptors()`.
|
|
|
|
func makeListModelsInterceptors() -> [ServerInterceptor<SdListModelsRequest, SdListModelsResponse>]
|
|
|
|
|
|
|
|
/// - Returns: Interceptors to use when handling 'loadModel'.
|
|
|
|
/// Defaults to calling `self.makeInterceptors()`.
|
|
|
|
func makeLoadModelInterceptors() -> [ServerInterceptor<SdLoadModelRequest, SdLoadModelResponse>]
|
|
|
|
}
|
|
|
|
|
|
|
|
public enum SdModelServiceServerMetadata {
|
|
|
|
public static let serviceDescriptor = GRPCServiceDescriptor(
|
|
|
|
name: "ModelService",
|
|
|
|
fullName: "gay.pizza.stable.diffusion.ModelService",
|
|
|
|
methods: [
|
|
|
|
SdModelServiceServerMetadata.Methods.listModels,
|
|
|
|
SdModelServiceServerMetadata.Methods.loadModel,
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
public enum Methods {
|
|
|
|
public static let listModels = GRPCMethodDescriptor(
|
|
|
|
name: "ListModels",
|
|
|
|
path: "/gay.pizza.stable.diffusion.ModelService/ListModels",
|
|
|
|
type: GRPCCallType.unary
|
|
|
|
)
|
|
|
|
|
|
|
|
public static let loadModel = GRPCMethodDescriptor(
|
|
|
|
name: "LoadModel",
|
|
|
|
path: "/gay.pizza.stable.diffusion.ModelService/LoadModel",
|
|
|
|
type: GRPCCallType.unary
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2023-04-23 02:09:50 -07:00
|
|
|
///*
|
|
|
|
/// The image generation service, for generating images from loaded models.
|
|
|
|
///
|
2023-04-22 14:52:27 -07:00
|
|
|
/// To build a server, implement a class that conforms to this protocol.
|
|
|
|
public protocol SdImageGenerationServiceProvider: CallHandlerProvider {
|
|
|
|
var interceptors: SdImageGenerationServiceServerInterceptorFactoryProtocol? { get }
|
|
|
|
|
2023-04-23 02:09:50 -07:00
|
|
|
///*
|
|
|
|
/// Generates images using a loaded model.
|
|
|
|
func generateImages(request: SdGenerateImagesRequest, context: StatusOnlyCallContext) -> EventLoopFuture<SdGenerateImagesResponse>
|
2023-04-23 14:22:10 -07:00
|
|
|
|
2023-04-23 14:50:45 -07:00
|
|
|
///*
|
|
|
|
/// Generates images using a loaded model, providing updates along the way.
|
2023-04-23 14:22:10 -07:00
|
|
|
func generateImagesStreaming(request: SdGenerateImagesRequest, context: StreamingResponseCallContext<SdGenerateImagesStreamUpdate>) -> EventLoopFuture<GRPCStatus>
|
2023-04-22 14:52:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
extension SdImageGenerationServiceProvider {
|
|
|
|
public var serviceName: Substring {
|
|
|
|
return SdImageGenerationServiceServerMetadata.serviceDescriptor.fullName[...]
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Determines, calls and returns the appropriate request handler, depending on the request's method.
|
|
|
|
/// Returns nil for methods not handled by this service.
|
|
|
|
public func handle(
|
|
|
|
method name: Substring,
|
|
|
|
context: CallHandlerContext
|
|
|
|
) -> GRPCServerHandlerProtocol? {
|
|
|
|
switch name {
|
2023-04-23 02:09:50 -07:00
|
|
|
case "GenerateImages":
|
2023-04-22 14:52:27 -07:00
|
|
|
return UnaryServerHandler(
|
|
|
|
context: context,
|
|
|
|
requestDeserializer: ProtobufDeserializer<SdGenerateImagesRequest>(),
|
|
|
|
responseSerializer: ProtobufSerializer<SdGenerateImagesResponse>(),
|
2023-04-23 02:09:50 -07:00
|
|
|
interceptors: self.interceptors?.makeGenerateImagesInterceptors() ?? [],
|
|
|
|
userFunction: self.generateImages(request:context:)
|
2023-04-22 14:52:27 -07:00
|
|
|
)
|
|
|
|
|
2023-04-23 14:22:10 -07:00
|
|
|
case "GenerateImagesStreaming":
|
|
|
|
return ServerStreamingServerHandler(
|
|
|
|
context: context,
|
|
|
|
requestDeserializer: ProtobufDeserializer<SdGenerateImagesRequest>(),
|
|
|
|
responseSerializer: ProtobufSerializer<SdGenerateImagesStreamUpdate>(),
|
|
|
|
interceptors: self.interceptors?.makeGenerateImagesStreamingInterceptors() ?? [],
|
|
|
|
userFunction: self.generateImagesStreaming(request:context:)
|
|
|
|
)
|
|
|
|
|
2023-04-22 14:52:27 -07:00
|
|
|
default:
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if compiler(>=5.6)
|
|
|
|
|
2023-04-23 02:09:50 -07:00
|
|
|
///*
|
|
|
|
/// The image generation service, for generating images from loaded models.
|
|
|
|
///
|
2023-04-22 14:52:27 -07:00
|
|
|
/// To implement a server, implement an object which conforms to this protocol.
|
|
|
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
|
|
|
public protocol SdImageGenerationServiceAsyncProvider: CallHandlerProvider {
|
|
|
|
static var serviceDescriptor: GRPCServiceDescriptor { get }
|
|
|
|
var interceptors: SdImageGenerationServiceServerInterceptorFactoryProtocol? { get }
|
|
|
|
|
2023-04-23 02:09:50 -07:00
|
|
|
///*
|
|
|
|
/// Generates images using a loaded model.
|
|
|
|
@Sendable func generateImages(
|
2023-04-22 14:52:27 -07:00
|
|
|
request: SdGenerateImagesRequest,
|
|
|
|
context: GRPCAsyncServerCallContext
|
|
|
|
) async throws -> SdGenerateImagesResponse
|
2023-04-23 14:22:10 -07:00
|
|
|
|
2023-04-23 14:50:45 -07:00
|
|
|
///*
|
|
|
|
/// Generates images using a loaded model, providing updates along the way.
|
2023-04-23 14:22:10 -07:00
|
|
|
@Sendable func generateImagesStreaming(
|
|
|
|
request: SdGenerateImagesRequest,
|
|
|
|
responseStream: GRPCAsyncResponseStreamWriter<SdGenerateImagesStreamUpdate>,
|
|
|
|
context: GRPCAsyncServerCallContext
|
|
|
|
) async throws
|
2023-04-22 14:52:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
|
|
|
extension SdImageGenerationServiceAsyncProvider {
|
|
|
|
public static var serviceDescriptor: GRPCServiceDescriptor {
|
|
|
|
return SdImageGenerationServiceServerMetadata.serviceDescriptor
|
|
|
|
}
|
|
|
|
|
|
|
|
public var serviceName: Substring {
|
|
|
|
return SdImageGenerationServiceServerMetadata.serviceDescriptor.fullName[...]
|
|
|
|
}
|
|
|
|
|
|
|
|
public var interceptors: SdImageGenerationServiceServerInterceptorFactoryProtocol? {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
public func handle(
|
|
|
|
method name: Substring,
|
|
|
|
context: CallHandlerContext
|
|
|
|
) -> GRPCServerHandlerProtocol? {
|
|
|
|
switch name {
|
2023-04-23 02:09:50 -07:00
|
|
|
case "GenerateImages":
|
2023-04-22 14:52:27 -07:00
|
|
|
return GRPCAsyncServerHandler(
|
|
|
|
context: context,
|
|
|
|
requestDeserializer: ProtobufDeserializer<SdGenerateImagesRequest>(),
|
|
|
|
responseSerializer: ProtobufSerializer<SdGenerateImagesResponse>(),
|
2023-04-23 02:09:50 -07:00
|
|
|
interceptors: self.interceptors?.makeGenerateImagesInterceptors() ?? [],
|
|
|
|
wrapping: self.generateImages(request:context:)
|
2023-04-22 14:52:27 -07:00
|
|
|
)
|
|
|
|
|
2023-04-23 14:22:10 -07:00
|
|
|
case "GenerateImagesStreaming":
|
|
|
|
return GRPCAsyncServerHandler(
|
|
|
|
context: context,
|
|
|
|
requestDeserializer: ProtobufDeserializer<SdGenerateImagesRequest>(),
|
|
|
|
responseSerializer: ProtobufSerializer<SdGenerateImagesStreamUpdate>(),
|
|
|
|
interceptors: self.interceptors?.makeGenerateImagesStreamingInterceptors() ?? [],
|
|
|
|
wrapping: self.generateImagesStreaming(request:responseStream:context:)
|
|
|
|
)
|
|
|
|
|
2023-04-22 14:52:27 -07:00
|
|
|
default:
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // compiler(>=5.6)
|
|
|
|
|
|
|
|
public protocol SdImageGenerationServiceServerInterceptorFactoryProtocol {
|
|
|
|
|
2023-04-23 02:09:50 -07:00
|
|
|
/// - Returns: Interceptors to use when handling 'generateImages'.
|
2023-04-22 14:52:27 -07:00
|
|
|
/// Defaults to calling `self.makeInterceptors()`.
|
2023-04-23 02:09:50 -07:00
|
|
|
func makeGenerateImagesInterceptors() -> [ServerInterceptor<SdGenerateImagesRequest, SdGenerateImagesResponse>]
|
2023-04-23 14:22:10 -07:00
|
|
|
|
|
|
|
/// - Returns: Interceptors to use when handling 'generateImagesStreaming'.
|
|
|
|
/// Defaults to calling `self.makeInterceptors()`.
|
|
|
|
func makeGenerateImagesStreamingInterceptors() -> [ServerInterceptor<SdGenerateImagesRequest, SdGenerateImagesStreamUpdate>]
|
2023-04-22 14:52:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public enum SdImageGenerationServiceServerMetadata {
|
|
|
|
public static let serviceDescriptor = GRPCServiceDescriptor(
|
|
|
|
name: "ImageGenerationService",
|
|
|
|
fullName: "gay.pizza.stable.diffusion.ImageGenerationService",
|
|
|
|
methods: [
|
2023-04-23 02:09:50 -07:00
|
|
|
SdImageGenerationServiceServerMetadata.Methods.generateImages,
|
2023-04-23 14:22:10 -07:00
|
|
|
SdImageGenerationServiceServerMetadata.Methods.generateImagesStreaming,
|
2023-04-22 14:52:27 -07:00
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
public enum Methods {
|
2023-04-23 02:09:50 -07:00
|
|
|
public static let generateImages = GRPCMethodDescriptor(
|
|
|
|
name: "GenerateImages",
|
|
|
|
path: "/gay.pizza.stable.diffusion.ImageGenerationService/GenerateImages",
|
2023-04-22 14:52:27 -07:00
|
|
|
type: GRPCCallType.unary
|
|
|
|
)
|
2023-04-23 14:22:10 -07:00
|
|
|
|
|
|
|
public static let generateImagesStreaming = GRPCMethodDescriptor(
|
|
|
|
name: "GenerateImagesStreaming",
|
|
|
|
path: "/gay.pizza.stable.diffusion.ImageGenerationService/GenerateImagesStreaming",
|
|
|
|
type: GRPCCallType.serverStreaming
|
|
|
|
)
|
2023-04-22 14:52:27 -07:00
|
|
|
}
|
|
|
|
}
|
2023-04-23 18:49:52 -07:00
|
|
|
///*
|
|
|
|
/// The tokenizer service, for analyzing tokens for a loaded model.
|
|
|
|
///
|
|
|
|
/// To build a server, implement a class that conforms to this protocol.
|
|
|
|
public protocol SdTokenizerServiceProvider: CallHandlerProvider {
|
|
|
|
var interceptors: SdTokenizerServiceServerInterceptorFactoryProtocol? { get }
|
|
|
|
|
|
|
|
///*
|
|
|
|
/// Analyze the input using a loaded model and return the results.
|
|
|
|
func tokenize(request: SdTokenizeRequest, context: StatusOnlyCallContext) -> EventLoopFuture<SdTokenizeResponse>
|
|
|
|
}
|
|
|
|
|
|
|
|
extension SdTokenizerServiceProvider {
|
|
|
|
public var serviceName: Substring {
|
|
|
|
return SdTokenizerServiceServerMetadata.serviceDescriptor.fullName[...]
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Determines, calls and returns the appropriate request handler, depending on the request's method.
|
|
|
|
/// Returns nil for methods not handled by this service.
|
|
|
|
public func handle(
|
|
|
|
method name: Substring,
|
|
|
|
context: CallHandlerContext
|
|
|
|
) -> GRPCServerHandlerProtocol? {
|
|
|
|
switch name {
|
|
|
|
case "Tokenize":
|
|
|
|
return UnaryServerHandler(
|
|
|
|
context: context,
|
|
|
|
requestDeserializer: ProtobufDeserializer<SdTokenizeRequest>(),
|
|
|
|
responseSerializer: ProtobufSerializer<SdTokenizeResponse>(),
|
|
|
|
interceptors: self.interceptors?.makeTokenizeInterceptors() ?? [],
|
|
|
|
userFunction: self.tokenize(request:context:)
|
|
|
|
)
|
|
|
|
|
|
|
|
default:
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if compiler(>=5.6)
|
|
|
|
|
|
|
|
///*
|
|
|
|
/// The tokenizer service, for analyzing tokens for a loaded model.
|
|
|
|
///
|
|
|
|
/// To implement a server, implement an object which conforms to this protocol.
|
|
|
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
|
|
|
public protocol SdTokenizerServiceAsyncProvider: CallHandlerProvider {
|
|
|
|
static var serviceDescriptor: GRPCServiceDescriptor { get }
|
|
|
|
var interceptors: SdTokenizerServiceServerInterceptorFactoryProtocol? { get }
|
|
|
|
|
|
|
|
///*
|
|
|
|
/// Analyze the input using a loaded model and return the results.
|
|
|
|
@Sendable func tokenize(
|
|
|
|
request: SdTokenizeRequest,
|
|
|
|
context: GRPCAsyncServerCallContext
|
|
|
|
) async throws -> SdTokenizeResponse
|
|
|
|
}
|
|
|
|
|
|
|
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
|
|
|
extension SdTokenizerServiceAsyncProvider {
|
|
|
|
public static var serviceDescriptor: GRPCServiceDescriptor {
|
|
|
|
return SdTokenizerServiceServerMetadata.serviceDescriptor
|
|
|
|
}
|
|
|
|
|
|
|
|
public var serviceName: Substring {
|
|
|
|
return SdTokenizerServiceServerMetadata.serviceDescriptor.fullName[...]
|
|
|
|
}
|
|
|
|
|
|
|
|
public var interceptors: SdTokenizerServiceServerInterceptorFactoryProtocol? {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
public func handle(
|
|
|
|
method name: Substring,
|
|
|
|
context: CallHandlerContext
|
|
|
|
) -> GRPCServerHandlerProtocol? {
|
|
|
|
switch name {
|
|
|
|
case "Tokenize":
|
|
|
|
return GRPCAsyncServerHandler(
|
|
|
|
context: context,
|
|
|
|
requestDeserializer: ProtobufDeserializer<SdTokenizeRequest>(),
|
|
|
|
responseSerializer: ProtobufSerializer<SdTokenizeResponse>(),
|
|
|
|
interceptors: self.interceptors?.makeTokenizeInterceptors() ?? [],
|
|
|
|
wrapping: self.tokenize(request:context:)
|
|
|
|
)
|
|
|
|
|
|
|
|
default:
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // compiler(>=5.6)
|
|
|
|
|
|
|
|
public protocol SdTokenizerServiceServerInterceptorFactoryProtocol {
|
|
|
|
|
|
|
|
/// - Returns: Interceptors to use when handling 'tokenize'.
|
|
|
|
/// Defaults to calling `self.makeInterceptors()`.
|
|
|
|
func makeTokenizeInterceptors() -> [ServerInterceptor<SdTokenizeRequest, SdTokenizeResponse>]
|
|
|
|
}
|
|
|
|
|
|
|
|
public enum SdTokenizerServiceServerMetadata {
|
|
|
|
public static let serviceDescriptor = GRPCServiceDescriptor(
|
|
|
|
name: "TokenizerService",
|
|
|
|
fullName: "gay.pizza.stable.diffusion.TokenizerService",
|
|
|
|
methods: [
|
|
|
|
SdTokenizerServiceServerMetadata.Methods.tokenize,
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
public enum Methods {
|
|
|
|
public static let tokenize = GRPCMethodDescriptor(
|
|
|
|
name: "Tokenize",
|
|
|
|
path: "/gay.pizza.stable.diffusion.TokenizerService/Tokenize",
|
|
|
|
type: GRPCCallType.unary
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|