This commit is contained in:
2026-04-10 17:41:01 +03:30
parent 523ad16b3c
commit e4ddceafa0
11 changed files with 416 additions and 50 deletions
+32
View File
@@ -6,6 +6,7 @@ using Microsoft.Extensions.Logging;
using xAiApi.AI.Interfaces;
using xAiApi.Base;
using xCommons.Configurations;
using xCommons.Extensions;
using xCommons.Providers;
using xIdentityService.Interfaces;
@@ -57,6 +58,37 @@ namespace xAiApi.Controllers.V1
return result;
}
}
[AllowAnonymous]
[HttpGet("AskAIStream")]
public async Task AskAIStream(
[FromQuery] string prompt
)
{
//
// Do ...
try
{
//
var stream = aiService
.GetTextReponseStreamAsync(prompt);
await foreach (var message in stream)
{
//
// Do What we Have to Do with Message ...
//
var msgBytes = message.Text.ToBytes();
await Response.Body.WriteAsync(msgBytes, 0, msgBytes.Length);
await Response.Body.FlushAsync();
}
//
await Response.Body.FlushAsync();
}
catch
{ }
}
#endregion
}
}