Skip to content

Commit 9e55a65

Browse files
committed
Write latest workflows used in App_Data/workflows
1 parent ac3fa6f commit 9e55a65

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

AiServer.ServiceInterface/AppData.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,20 @@ public MediaProvider AssertComfyProvider(string name) => ComfyProviders.FirstOrD
4747
.Where(x => x.MediaType.Provider == AiServiceProvider.Comfy)
4848
.ToArray();
4949

50-
string? ReadTextFile(string path)
50+
public string? ReadTextFile(string path)
5151
{
5252
var fullPath = Path.Combine(env.ContentRootPath, path);
5353
return File.Exists(fullPath)
5454
? File.ReadAllText(fullPath)
5555
: null;
5656
}
57+
58+
public void WriteTextFile(string path, string contents)
59+
{
60+
var fullPath = Path.Combine(env.ContentRootPath, path);
61+
Path.GetDirectoryName(fullPath).AssertDir();
62+
File.WriteAllText(fullPath, contents);
63+
}
5764

5865
T[] LoadModels<T>(string name) where T : IHasId<string>
5966
{

AiServer.ServiceInterface/Comfy/ComfyClient.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@ public async Task<ComfyWorkflowResponse> PromptGenerationAsync(ComfyWorkflowRequ
198198
}
199199

200200
var workflowJson = await PopulateWorkflowAsync(workflowArgs, templatePath, token);
201+
202+
if (mediaModel != null)
203+
{
204+
AppData.Instance.WriteTextFile($"App_Data/workflows/{mediaModel.Id}.json", workflowJson);
205+
}
206+
201207
// Convert to ComfyUI API JSON format
202208
var apiJson = await ConvertWorkflowToApiAsync(workflowJson, token);
203209

0 commit comments

Comments
 (0)