diff --git a/RMuseum/Controllers/ArtifactController.cs b/RMuseum/Controllers/ArtifactController.cs
index 4e07bbe7..9c93d66c 100644
--- a/RMuseum/Controllers/ArtifactController.cs
+++ b/RMuseum/Controllers/ArtifactController.cs
@@ -2114,6 +2114,7 @@ namespace RMuseum.Controllers
///
///
///
+ ///
///
[HttpPut("ai/create/images")]
@@ -2121,11 +2122,11 @@ namespace RMuseum.Controllers
[ProducesResponseType((int)HttpStatusCode.OK)]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
[ProducesResponseType((int)HttpStatusCode.Unauthorized)]
- public async Task OpenAIStartCreatingImagesForPoemsAsync(int startFrom, int count)
+ public async Task OpenAIStartCreatingImagesForPoemsAsync(int startFrom = 0, int count = 0, int poetId = 0)
{
try
{
- await _artifactService.OpenAIStartCreatingImagesForPoemsAsync(startFrom, count);
+ await _artifactService.OpenAIStartCreatingImagesForPoemsAsync(startFrom, count, poetId);
return Ok();
}
catch (Exception exp)
diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml
index 21e9768a..22a0da55 100644
--- a/RMuseum/RMuseum.xml
+++ b/RMuseum/RMuseum.xml
@@ -636,12 +636,13 @@
-
+
create images for ganjoor
+
@@ -15267,12 +15268,13 @@
-
+
create images for ganjoor
+
diff --git a/RMuseum/Services/IArtifactService.cs b/RMuseum/Services/IArtifactService.cs
index e04cd581..f14f3588 100644
--- a/RMuseum/Services/IArtifactService.cs
+++ b/RMuseum/Services/IArtifactService.cs
@@ -604,8 +604,9 @@ namespace RMuseum.Services
///
///
///
+ ///
///
- Task OpenAIStartCreatingImagesForPoemsAsync(int startFrom, int count);
+ Task OpenAIStartCreatingImagesForPoemsAsync(int startFrom, int count, int poetId);
}
}
diff --git a/RMuseum/Services/Implementation/ArtifactService-Partials/ArtificatService-AIImageCreate.cs b/RMuseum/Services/Implementation/ArtifactService-Partials/ArtificatService-AIImageCreate.cs
index 0329aa6a..1902a894 100644
--- a/RMuseum/Services/Implementation/ArtifactService-Partials/ArtificatService-AIImageCreate.cs
+++ b/RMuseum/Services/Implementation/ArtifactService-Partials/ArtificatService-AIImageCreate.cs
@@ -15,6 +15,7 @@ using System.Drawing;
using FluentFTP;
using System.Threading.Tasks;
using RMuseum.Models.GanjoorIntegration;
+using RMuseum.Models.Ganjoor;
namespace RMuseum.Services.Implementation
{
@@ -23,7 +24,7 @@ namespace RMuseum.Services.Implementation
///
public partial class ArtifactService : IArtifactService
{
- public async Task OpenAIStartCreatingImagesForPoemsAsync(int startFrom, int count)
+ public async Task OpenAIStartCreatingImagesForPoemsAsync(int startFrom, int count, int poetId)
{
string systemEmail = $"{Configuration.GetSection("Ganjoor")["SystemEmail"]}";
var systemUserId = (Guid)(await _userService.FindUserByEmail(systemEmail)).Result.Id;
@@ -47,11 +48,14 @@ namespace RMuseum.Services.Implementation
await jobProgressServiceEF.UpdateJob(job.Id, 0, "Query data");
+ List cats = poetId == 0 ? new List() : await context.GanjoorCategories.AsNoTracking().Where(c => c.PoetId == poetId).ToListAsync();
+
var poems =
+ poetId != 0 ?
+ await context.GanjoorPoems.AsNoTracking().Where(p => cats.Any(c => c.Id == p.CatId)).ToListAsync() :
count == 0 ?
startFrom == 0 ?
- await context.GanjoorPoems.AsNoTracking()
- .ToListAsync()
+ await context.GanjoorPoems.AsNoTracking().ToListAsync()
:
await context.GanjoorPoems.AsNoTracking()
.Skip(startFrom)
@@ -91,6 +95,7 @@ namespace RMuseum.Services.Implementation
if (!string.IsNullOrEmpty(poem.PlainText))
{
+ await jobProgressServiceEF.UpdateJob(job.Id, i, $"{i} از {poems.Count} - {poem.FullTitle} - 1");
//1
bool hasStories = false;
var hasStoriesResult = await openAiService.ChatCompletion.CreateCompletion(new ChatCompletionCreateRequest
@@ -122,6 +127,7 @@ namespace RMuseum.Services.Implementation
if (!hasStories) continue;
//2
+ await jobProgressServiceEF.UpdateJob(job.Id, i, $"{i} از {poems.Count} - {poem.FullTitle} - 2");
var storyResult = await openAiService.ChatCompletion.CreateCompletion(new ChatCompletionCreateRequest
{
Messages = new List
@@ -152,6 +158,8 @@ namespace RMuseum.Services.Implementation
if (string.IsNullOrEmpty(story)) continue;
+ await jobProgressServiceEF.UpdateJob(job.Id, i, $"{i} از {poems.Count} - {poem.FullTitle} - 3");
+
//3
var depictionResult = await openAiService.ChatCompletion.CreateCompletion(new ChatCompletionCreateRequest
{
@@ -177,6 +185,8 @@ namespace RMuseum.Services.Implementation
if (string.IsNullOrEmpty(prompt)) continue;
+ await jobProgressServiceEF.UpdateJob(job.Id, i, $"{i} از {poems.Count} - {poem.FullTitle} - 4");
+
//4
var imageCreationResult = await openAiService.Image.CreateImage(new ImageCreateRequest
(