diff --git a/AiServer.ServiceInterface/ImageServices.Generation.cs b/AiServer.ServiceInterface/ImageServices.Generation.cs index 733ee78..d2e6b61 100644 --- a/AiServer.ServiceInterface/ImageServices.Generation.cs +++ b/AiServer.ServiceInterface/ImageServices.Generation.cs @@ -47,7 +47,7 @@ public async Task Any(QueueTextToImage request) return await diffRequest.ProcessQueuedGenerationAsync(jobs, diffServices); } - public async Task Any(QueueImageUpscale request) + public async Task Any(QueueImageUpscale request) { if(Request?.Files == null || Request.Files.Length == 0) { @@ -70,10 +70,10 @@ public async Task Any(QueueImageUpscale request) }; await using var diffServices = ResolveService(); - return await diffRequest.ProcessSyncGenerationAsync(jobs, diffServices); + return await diffRequest.ProcessQueuedGenerationAsync(jobs, diffServices); } - public async Task Any(QueueImageToImage request) + public async Task Any(QueueImageToImage request) { if (Request?.Files == null || Request.Files.Length == 0) { @@ -100,10 +100,10 @@ public async Task Any(QueueImageToImage request) }; await using var diffServices = ResolveService(); - return await diffRequest.ProcessSyncGenerationAsync(jobs, diffServices); + return await diffRequest.ProcessQueuedGenerationAsync(jobs, diffServices); } - public async Task Any(QueueImageWithMask request) + public async Task Any(QueueImageWithMask request) { if (Request?.Files == null || Request.Files.Length > 2) { @@ -129,10 +129,10 @@ public async Task Any(QueueImageWithMask request) }; await using var diffServices = ResolveService(); - return await diffRequest.ProcessSyncGenerationAsync(jobs, diffServices); + return await diffRequest.ProcessQueuedGenerationAsync(jobs, diffServices); } - public async Task Any(QueueImageToText request) + public async Task Any(QueueImageToText request) { var diffRequest = new CreateGeneration { @@ -147,7 +147,7 @@ public async Task Any(QueueImageToText request) }; await using var genServices = ResolveService(); - return await diffRequest.ProcessSyncGenerationAsync(jobs, genServices); + return await diffRequest.ProcessQueuedGenerationAsync(jobs, genServices); } } diff --git a/AiServer.ServiceInterface/OpenAiChatServices.cs b/AiServer.ServiceInterface/OpenAiChatServices.cs index f06d0db..42891de 100644 --- a/AiServer.ServiceInterface/OpenAiChatServices.cs +++ b/AiServer.ServiceInterface/OpenAiChatServices.cs @@ -121,7 +121,7 @@ public async Task Post(OpenAiChatCompletion request) return await chatRequest.ProcessSync(jobs, this); } - public async Task Any(QueueOpenAiChatCompletion request) + public QueueOpenAiChatResponse Any(QueueOpenAiChatCompletion request) { if (request.Request == null) throw new ArgumentNullException(nameof(request.Request)); @@ -428,15 +428,14 @@ public object Any(DeleteAiProvider request) public static class OpenAiChatServiceExtensions { - public static async Task ProcessSync(this QueueOpenAiChatCompletion chatRequest, - IBackgroundJobs jobs, - OpenAiChatServices chatService) + public static async Task ProcessSync(this QueueOpenAiChatCompletion chatRequest, + IBackgroundJobs jobs, OpenAiChatServices chatService) { QueueOpenAiChatResponse? chatResponse = null; try { - var response = await chatService.Any(chatRequest); - chatResponse = response as QueueOpenAiChatResponse; + var response = chatService.Any(chatRequest); + chatResponse = response; } catch (Exception e) { @@ -458,14 +457,12 @@ public static async Task ProcessSync(this QueueOpenAiChatCompletion chat // We know at this point, we definitely have a job JobResult queuedJob = job; - var completedResponse = new OpenAiChatResponse() - { - }; + var completedResponse = new OpenAiChatResponse(); // Handle failed jobs if (job.Failed != null) { - throw new Exception(job.Failed.Error.Message); + throw new Exception(job.Failed.Error!.Message); } // Wait for the job to complete max 1 minute diff --git a/AiServer.ServiceInterface/VideoServices.cs b/AiServer.ServiceInterface/VideoServices.cs index 1bd183a..76e3ee4 100644 --- a/AiServer.ServiceInterface/VideoServices.cs +++ b/AiServer.ServiceInterface/VideoServices.cs @@ -126,7 +126,7 @@ private void ValidateTimeFormat(string time, string fieldName) } } - public async Task Any(QueueScaleVideo request) + public async Task Any(QueueScaleVideo request) { // Convert request var transformRequest = new CreateMediaTransform @@ -144,7 +144,7 @@ public async Task Any(QueueScaleVideo request) return await transformRequest.ProcessQueuedTransformAsync(jobs, transformService); } - public async Task Any(QueueWatermarkVideo request) + public async Task Any(QueueWatermarkVideo request) { string watermarkPosition; switch (request.Position) @@ -205,7 +205,7 @@ private bool IsVideoFormat(MediaOutputFormat outputFormat) } } - public async Task Any(QueueConvertVideo request) + public async Task Any(QueueConvertVideo request) { if (Request?.Files == null || Request.Files.Length == 0) throw new ArgumentException("No video file provided"); @@ -230,7 +230,7 @@ public async Task Any(QueueConvertVideo request) return await transformRequest.ProcessQueuedTransformAsync(jobs, transformService); } - public async Task Any(QueueCropVideo request) + public async Task Any(QueueCropVideo request) { // Convert request var transformRequest = new CreateMediaTransform @@ -251,7 +251,7 @@ public async Task Any(QueueCropVideo request) return await transformRequest.ProcessQueuedTransformAsync(jobs, transformService); } - public async Task Any(QueueTrimVideo request) + public async Task Any(QueueTrimVideo request) { if (Request?.Files == null || Request.Files.Length == 0) throw new ArgumentException("No video file provided");