2026-08-02 21:41:12 +02:00
|
|
|
using AIStudio.Chat;
|
2026-11-28 11:52:17 +01:00
|
|
|
using AIStudio.Tools.Imports;
|
2026-08-02 21:41:12 +02:00
|
|
|
using AIStudio.Tools.Media;
|
|
|
|
|
|
|
|
|
|
namespace AIStudio.Assistants.VisualBriefing;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Defines <c>VisualBriefingTranscriptStorage</c> for the visual briefing feature.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class VisualBriefingTranscriptStorage(VisualBriefingStore store) : IMediaTranscriptStorage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Defines <c>CanStore</c> for the visual briefing feature.
|
|
|
|
|
/// </summary>
|
2026-11-28 11:52:17 +01:00
|
|
|
public bool CanStore(ImportOwner owner) =>
|
|
|
|
|
owner.Kind is ImportOwnerKind.VISUAL_BRIEFING &&
|
2026-08-02 21:41:12 +02:00
|
|
|
Guid.TryParse(owner.Id, out _);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Defines <c>StoreAsync</c> for the visual briefing feature.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public async Task<FileAttachment> StoreAsync(
|
2026-11-28 11:52:17 +01:00
|
|
|
ImportTarget target,
|
2026-08-02 21:41:12 +02:00
|
|
|
string originalMediaPath,
|
|
|
|
|
string transcript,
|
|
|
|
|
CancellationToken token)
|
|
|
|
|
{
|
|
|
|
|
if (!Guid.TryParse(target.Owner.Id, out var briefingId))
|
|
|
|
|
throw new InvalidDataException("The visual briefing media owner is invalid.");
|
|
|
|
|
|
|
|
|
|
var sourceId = await store.FindSourceIdByPathAsync(briefingId, originalMediaPath, token)
|
|
|
|
|
?? throw new InvalidDataException("The visual briefing media source is not registered.");
|
|
|
|
|
await store.SetTranscriptCurrentAsync(briefingId, sourceId, transcript, token);
|
|
|
|
|
var transcriptPath = store.GetTranscriptPath(briefingId, sourceId);
|
|
|
|
|
return FileAttachment.FromPath(transcriptPath);
|
|
|
|
|
}
|
|
|
|
|
}
|