feat: 完成图片生成功能

This commit is contained in:
ccnetcore
2026-01-02 19:26:09 +08:00
parent 3f53eb14ab
commit 560a76558a
14 changed files with 251 additions and 134 deletions

View File

@@ -984,11 +984,12 @@ public class AiGateWayManager : DomainService
var data = await chatService.GenerateContentAsync(modelDescribe, request, cancellationToken);
//解析json获取base64字符串
var imageBase64 = GeminiGenerateContentAcquirer.GetImageBase64(data);
var imageBase64 = GeminiGenerateContentAcquirer.GetImagePrefixBase64(data);
//远程调用上传接口将base64转换为URL
var httpClient = LazyServiceProvider.LazyGetRequiredService<IHttpClientFactory>().CreateClient();
var uploadUrl = $"https://ccnetcore.com/prod-api/ai-hub/ai-image/upload-base64";
// var uploadUrl = $"https://ccnetcore.com/prod-api/ai-hub/ai-image/upload-base64";
var uploadUrl = $"http://localhost:19001/api/app/ai-image/upload-base64";
var content = new StringContent(JsonSerializer.Serialize(imageBase64), Encoding.UTF8, "application/json");
var uploadResponse = await httpClient.PostAsync(uploadUrl, content, cancellationToken);
uploadResponse.EnsureSuccessStatusCode();
@@ -1020,7 +1021,7 @@ public class AiGateWayManager : DomainService
}
//设置存储base64和url
imageStoreTask.StoreBase64 = imageBase64;
imageStoreTask.StorePrefixBase64 = imageBase64;
imageStoreTask.SetSuccess(storeUrl);
await _imageStoreTaskRepository.UpdateAsync(imageStoreTask);
}