-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAIController.cs
More file actions
27 lines (22 loc) · 935 Bytes
/
AIController.cs
File metadata and controls
27 lines (22 loc) · 935 Bytes
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
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() {
return await AIAssistantProvider.CreateUserAssistant();
}
public async Task<string> GetAnswer([FromForm] string chatId, [FromForm] string text) {
var assistant = AIAssistantProvider.GetAssistant(chatId);
return await assistant.GetAnswerAsync(text);
}
public async Task<ActionResult> CloseChat([FromForm] string chatId) {
await AIAssistantProvider.DisposeAssistant(chatId);
return Ok();
}
}
}