-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
34 lines (29 loc) · 1.91 KB
/
Program.cs
File metadata and controls
34 lines (29 loc) · 1.91 KB
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
using bsky.bot.Clients;
using bsky.bot.Clients.Interface;
using bsky.bot.Storage;
using bsky.bot.Workers;
namespace bsky.bot;
public class Program
{
private static readonly string blueSky = Environment.GetEnvironmentVariable("bluesky_url") ?? throw new ApplicationException("variable $bluesky_url not found");
private static readonly string ollamaUrl = Environment.GetEnvironmentVariable("ollama_url") ?? throw new ApplicationException("variable $ollama_url not found");
private static readonly string email = Environment.GetEnvironmentVariable("bluesky_email") ?? throw new ApplicationException("variable $bluesky_email not found");
private static readonly string password = Environment.GetEnvironmentVariable("bluesky_password") ?? throw new ApplicationException("variable $bluesky_password not found");
private static readonly string embbedSourceExtractorUrl = Environment.GetEnvironmentVariable("embbed_source_url") ?? throw new ApplicationException("variable $embbed_source_url not found");
private static readonly string llmModel = Environment.GetEnvironmentVariable("model") ?? "gemini";
private static readonly ILogger<Program> logger = LoggerFactory.Create(b =>
{
b.SetMinimumLevel(LogLevel.Debug).AddSimpleConsole();
}).CreateLogger<Program>();
public static void Main() => MainAsync().Wait();
private static async Task MainAsync()
{
logger.LogInformation("Worker \"bsky.bot\" started at: {0}", DateTime.Now);
using var dataRepository = new DataRepository();
var blueSkyApi = new BlueSky(blueSky, email, password, embbedSourceExtractorUrl);
ILllmModel model = llmModel == "gemini" ? new Gemini() : new Ollama(ollamaUrl, "llama3.1");
await blueSkyApi.LoginAsync();
await new InteractionWorker(blueSkyApi, dataRepository, model).ExecuteAsync();
logger.LogInformation("Worker \"bsky.bot\" ended at: {0}", DateTime.Now);
}
}