Integrated data sources into any chat (#282)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2025-02-15 15:41:12 +01:00
1 parent 954cf44939
commit f4780939fc
70 files changed
+1506 -250

No files matched your search

+17
View File
@@ -115,6 +115,7 @@ internal sealed class Program
builder.Services.AddMudMarkdownClipboardService<MarkdownClipboardService>();
builder.Services.AddSingleton<SettingsManager>();
builder.Services.AddSingleton<ThreadSafeRandom>();
builder.Services.AddSingleton<DataSourceService>();
builder.Services.AddTransient<HTMLParser>();
builder.Services.AddTransient<AgentTextContentCleaner>();
builder.Services.AddHostedService<UpdateService>();
@@ -143,12 +144,18 @@ internal sealed class Program
// Execute the builder to get the app:
var app = builder.Build();
// Get a program logger:
var programLogger = app.Services.GetRequiredService<ILogger<Program>>();
programLogger.LogInformation("Starting the AI Studio server.");
// Initialize the encryption service:
programLogger.LogInformation("Initializing the encryption service.");
var encryptionLogger = app.Services.GetRequiredService<ILogger<Encryption>>();
var encryption = new Encryption(encryptionLogger, secretPassword, secretKeySalt);
var encryptionInitializer = encryption.Initialize();
// Set the logger for the Rust service:
programLogger.LogInformation("Initializing the Rust service.");
var rustLogger = app.Services.GetRequiredService<ILogger<RustService>>();
rust.SetLogger(rustLogger);
rust.SetEncryptor(encryption);
@@ -156,6 +163,7 @@ internal sealed class Program
RUST_SERVICE = rust;
ENCRYPTION = encryption;
programLogger.LogInformation("Initialize internal file system.");
app.Use(Redirect.HandlerContentAsync);
#if DEBUG
@@ -175,9 +183,18 @@ internal sealed class Program
.AddInteractiveServerRenderMode();
var serverTask = app.RunAsync();
programLogger.LogInformation("Server was started successfully.");
await encryptionInitializer;
await rust.AppIsReady();
programLogger.LogInformation("The AI Studio server is ready.");
TaskScheduler.UnobservedTaskException += (sender, taskArgs) =>
{
programLogger.LogError(taskArgs.Exception, $"Unobserved task exception by sender '{sender ?? "n/a"}'.");
taskArgs.SetObserved();
};
await serverTask;
}
}