Skip to content

Commit 32e4b60

Browse files
committed
Add logging.
1 parent 53ac831 commit 32e4b60

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/Automation/Responders/StableDiffusionResponder.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
using Discord;
22
using Estranged.Automation.Events;
33
using Microsoft.Extensions.AI;
4+
using Estranged.Automation.Events;
5+
using Microsoft.Extensions.AI;
46
using Microsoft.Extensions.Configuration;
7+
using Microsoft.Extensions.Logging;
58
using System;
69
using System.IO;
710
using System.Net.Http;
@@ -19,13 +22,15 @@ namespace Estranged.Automation.Responders
1922
internal sealed class StableDiffusionResponder : IResponder
2023
{
2124
private readonly IHttpClientFactory _httpClientFactory;
25+
private readonly ILogger<StableDiffusionResponder> _logger;
2226
private readonly IConfiguration _configuration;
2327
private readonly IFeatureFlags _featureFlags;
2428
private readonly IChatClientFactory _chatClientFactory;
2529
private int _steps = 20;
2630

27-
public StableDiffusionResponder(IHttpClientFactory httpClientFactory, IConfiguration configuration, IFeatureFlags featureFlags, IChatClientFactory chatClientFactory)
31+
public StableDiffusionResponder(ILogger<StableDiffusionResponder> logger, IHttpClientFactory httpClientFactory, IConfiguration configuration, IFeatureFlags featureFlags, IChatClientFactory chatClientFactory)
2832
{
33+
_logger = logger;
2934
_httpClientFactory = httpClientFactory;
3035
_configuration = configuration;
3136
_featureFlags = featureFlags;
@@ -72,6 +77,8 @@ public async Task ProcessMessage(IMessage message, CancellationToken token)
7277

7378
var enhancedPrompt = response.Text.Trim();
7479

80+
_logger.LogInformation("Enhanced prompt: {EnhancedPrompt}", enhancedPrompt);
81+
7582
var result = await GenerateImageWithGif(enhancedPrompt, token);
7683
using var gifStream = result.gifStream;
7784
await message.Channel.SendFileAsync(gifStream, $"{Guid.NewGuid()}.gif", text: enhancedPrompt, messageReference: new MessageReference(message.Id), options: token.ToRequestOptions());

0 commit comments

Comments
 (0)