Skip to content

Commit 082274e

Browse files
committed
test
1 parent a703fc4 commit 082274e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/api/Elastic.Documentation.Api.Infrastructure/MappingsExtensions.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ private static void MapAskAiEndpoint(IEndpointRouteBuilder group)
3535
// Flush headers to the client immediately
3636
await context.Response.StartAsync(ctx);
3737

38+
// Send an immediate "reasoning" event so the client knows the stream is active
39+
// This provides instant feedback before we wait for the AI gateway
40+
var timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
41+
var connectionEvent = System.Text.Encoding.UTF8.GetBytes(
42+
$"data: {{\"type\":\"reasoning\",\"id\":\"{Guid.NewGuid()}\",\"timestamp\":{timestamp},\"message\":\"Connecting to AI...\"}}\n\n"
43+
);
44+
await context.Response.Body.WriteAsync(connectionEvent, ctx);
45+
await context.Response.Body.FlushAsync(ctx);
46+
3847
var stream = await askAiUsecase.AskAi(askAiRequest, ctx);
3948

4049
// Stream the response

0 commit comments

Comments
 (0)