mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-08-06 03:42:24 +00:00
36 lines
1.4 KiB
C#
36 lines
1.4 KiB
C#
|
|
using AIStudio.Chat;
|
||
|
|
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>
|
||
|
|
public bool CanStore(MediaImportOwner owner) =>
|
||
|
|
owner.Kind is MediaImportOwnerKind.VISUAL_BRIEFING &&
|
||
|
|
Guid.TryParse(owner.Id, out _);
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// Defines <c>StoreAsync</c> for the visual briefing feature.
|
||
|
|
/// </summary>
|
||
|
|
public async Task<FileAttachment> StoreAsync(
|
||
|
|
MediaImportTarget target,
|
||
|
|
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);
|
||
|
|
}
|
||
|
|
}
|