-
Notifications
You must be signed in to change notification settings - Fork 0
/
Startup.cs
48 lines (43 loc) · 1.94 KB
/
Startup.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
38
39
40
41
42
43
44
45
46
47
48
using Microsoft.Azure.Functions.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using OpenAI.GPT3.Extensions;
using ReverseMarkdown;
using System;
using System.IO;
[assembly: FunctionsStartup(typeof(CavendishBanana.Startup))]
namespace CavendishBanana
{
public class Startup : FunctionsStartup
{
public override void ConfigureAppConfiguration(IFunctionsConfigurationBuilder builder)
{
FunctionsHostBuilderContext context = builder.GetContext();
builder.ConfigurationBuilder
.AddJsonFile(Path.Combine(context.ApplicationRootPath, "appsettings.json"), optional: true, reloadOnChange: false)
.AddJsonFile(Path.Combine(context.ApplicationRootPath, $"appsettings.{context.EnvironmentName}.json"), optional: true, reloadOnChange: false)
.AddEnvironmentVariables();
}
public override void Configure(IFunctionsHostBuilder builder)
{
builder.Services.AddOpenAIService().ConfigureHttpClient(c => {
c.Timeout = TimeSpan.FromMinutes(5);
});
builder.Services.AddSingleton<Converter>(sp => {
var config = new Config
{
// Include the unknown tag completely in the result (default as well)
// UnknownTags = ReverseMarkdown.Config.UnknownTagsOption.PassThrough,
UnknownTags = Config.UnknownTagsOption.Bypass,
// generate GitHub flavoured markdown, supported for BR, PRE and table tags
GithubFlavored = true,
// will ignore all comments
RemoveComments = true,
// remove markdown output for links where appropriate
SmartHrefHandling = true
};
return new Converter(config);
});
}
}
}