-
Notifications
You must be signed in to change notification settings - Fork 0
/
NatsirtAI.cs
37 lines (31 loc) · 944 Bytes
/
NatsirtAI.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
29
30
31
32
33
34
35
36
37
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using OpenAI_API;
using OpenAI_API.Completions;
using OpenAI_API.Models;
namespace Natsirt;
public class NatsirtAI
{
private readonly IConfiguration _configuration;
private readonly OpenAIAPI _openAIAPI;
public NatsirtAI(IConfiguration config)
{
_configuration = config;
_openAIAPI = new OpenAIAPI(_configuration["OPENAI_API_KEY"]);
}
public async Task<string> PerformCompletion(string prompt)
{
var result = await _openAIAPI.Completions.CreateCompletionAsync(new CompletionRequest()
{
Prompt = prompt,
MaxTokens = 100,
Temperature = 0.5,
TopP = 1,
PresencePenalty = 0,
FrequencyPenalty = 0,
Model = Model.DavinciText,
StopSequence = "\n",
});
return result.Completions[0].Text;
}
}