mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-07-28 05:42:57 +00:00
Improved presentation slide streaming
This commit is contained in:
parent
f7c3011678
commit
77d3e80765
@ -8,7 +8,7 @@ public static class ContentStreamSseHandler
|
|||||||
private static readonly ConcurrentDictionary<string, List<ContentStreamPptxImageData>> CHUNKED_IMAGES = new();
|
private static readonly ConcurrentDictionary<string, List<ContentStreamPptxImageData>> CHUNKED_IMAGES = new();
|
||||||
private static readonly ConcurrentDictionary<string, int> CURRENT_SLIDE_NUMBERS = new();
|
private static readonly ConcurrentDictionary<string, int> CURRENT_SLIDE_NUMBERS = new();
|
||||||
|
|
||||||
public static string ProcessEvent(ContentStreamSseEvent? sseEvent, bool extractImages = true)
|
public static string? ProcessEvent(ContentStreamSseEvent? sseEvent, bool extractImages = true)
|
||||||
{
|
{
|
||||||
switch (sseEvent)
|
switch (sseEvent)
|
||||||
{
|
{
|
||||||
@ -43,13 +43,16 @@ public static class ContentStreamSseHandler
|
|||||||
var streamId = sseEvent.StreamId;
|
var streamId = sseEvent.StreamId;
|
||||||
|
|
||||||
CURRENT_SLIDE_NUMBERS.TryGetValue(streamId!, out var currentSlideNumber);
|
CURRENT_SLIDE_NUMBERS.TryGetValue(streamId!, out var currentSlideNumber);
|
||||||
|
|
||||||
if (slideNumber != currentSlideNumber)
|
if (slideNumber != currentSlideNumber)
|
||||||
|
{
|
||||||
|
presentationResult.AppendLine();
|
||||||
presentationResult.AppendLine($"# Slide {slideNumber}");
|
presentationResult.AppendLine($"# Slide {slideNumber}");
|
||||||
|
}
|
||||||
|
|
||||||
presentationResult.Append($"{sseEvent.Content}");
|
if(!string.IsNullOrWhiteSpace(sseEvent.Content))
|
||||||
|
presentationResult.AppendLine(sseEvent.Content);
|
||||||
|
|
||||||
if (image is not null)
|
if (extractImages && image is not null)
|
||||||
{
|
{
|
||||||
var imageId = $"{streamId}-{image.Id!}";
|
var imageId = $"{streamId}-{image.Id!}";
|
||||||
var isEnd = ProcessImageSegment(imageId, image);
|
var isEnd = ProcessImageSegment(imageId, image);
|
||||||
@ -58,8 +61,8 @@ public static class ContentStreamSseHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
CURRENT_SLIDE_NUMBERS[streamId!] = slideNumber;
|
CURRENT_SLIDE_NUMBERS[streamId!] = slideNumber;
|
||||||
|
return presentationResult.Length is 0 ? null : presentationResult.ToString();
|
||||||
|
|
||||||
return presentationResult.ToString();
|
|
||||||
default:
|
default:
|
||||||
return sseEvent.Content;
|
return sseEvent.Content;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,9 @@ public sealed partial class RustService
|
|||||||
if (sseEvent is not null)
|
if (sseEvent is not null)
|
||||||
{
|
{
|
||||||
var content = ContentStreamSseHandler.ProcessEvent(sseEvent, false);
|
var content = ContentStreamSseHandler.ProcessEvent(sseEvent, false);
|
||||||
resultBuilder.Append(content);
|
if(content is not null)
|
||||||
|
resultBuilder.AppendLine(content);
|
||||||
|
|
||||||
chunkCount++;
|
chunkCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user