-
Notifications
You must be signed in to change notification settings - Fork 1
/
AIController.cs
28 lines (23 loc) · 987 Bytes
/
AIController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System.Threading.Tasks;
using ReportingApp.Services;
using Microsoft.AspNetCore.Mvc;
namespace ReportingApp.Controllers {
public class AIController : ControllerBase {
IAIAssistantProvider AIAssistantProvider { get; set; }
public AIController(IAIAssistantProvider assistantProvider) {
AIAssistantProvider = assistantProvider;
}
public async Task<string> CreateUserAssistant() {
var assistantName = await AIAssistantProvider.CreateAssistant(AssistantType.UserAssistant);
return assistantName;
}
public async Task<string> GetAnswer([FromForm] string chatId, [FromForm] string text) {
var assistant = AIAssistantProvider.GetAssistant(chatId);
return await assistant.GetAnswerAsync(text);
}
public ActionResult CloseChat([FromForm] string chatId) {
AIAssistantProvider.DisposeAssistant(chatId);
return Ok();
}
}
}