More work
This commit is contained in:
1 parent
c06f06c6ce
commit
8b476e6939
20 files changed
+871
-22
No files matched your search
+23
-1
@@ -1,6 +1,9 @@
|
||||
using System.Net.Http.Headers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PaperlessAI.Context;
|
||||
using PaperlessAI.Interfaces;
|
||||
using PaperlessAI.Jobs;
|
||||
using PaperlessAI.Models;
|
||||
using PaperlessAI.Repositories;
|
||||
using PaperlessAI.Services;
|
||||
using Serilog;
|
||||
@@ -8,8 +11,27 @@ using Serilog;
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Services
|
||||
builder.Services.AddScoped<PaperlessDocumentService>();
|
||||
builder.Services.AddScoped<Configuration>();
|
||||
builder.Services.AddSingleton<DocumentProcessingService>();
|
||||
builder.Services.AddScoped<PaperlessDocumentService>();
|
||||
builder.Services.AddScoped<LLMAgentService>();
|
||||
builder.Services.AddHttpClient<ApiService>((serviceProvider, client) =>
|
||||
{
|
||||
var config = serviceProvider.GetRequiredService<IConfiguration>();
|
||||
|
||||
var baseUrl = config["LlmAgent:Url"] ?? throw new InvalidOperationException("LlmAgent:Url configuration missing.");
|
||||
var token = config["LlmAgent:Token"] ?? throw new InvalidOperationException("LlmAgent:Token configuration missing.");
|
||||
var acceptMediaType = config["LlmAgent:MediaType"] ?? throw new InvalidOperationException("LlmAgent:MediaType configuration missing.");
|
||||
var timeoutSeconds = int.Parse(config["LlmAgent:TimeoutSeconds"] ?? throw new InvalidOperationException("LlmAgent:TimeoutSeconds configuration missing."));
|
||||
|
||||
client.Timeout = TimeSpan.FromSeconds(timeoutSeconds);
|
||||
client.BaseAddress = new Uri(baseUrl);
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
||||
client.DefaultRequestHeaders.Accept.Clear();
|
||||
client.DefaultRequestHeaders.Accept.Add(
|
||||
new MediaTypeWithQualityHeaderValue(acceptMediaType)
|
||||
);
|
||||
});
|
||||
|
||||
// Repositories
|
||||
builder.Services.AddScoped<PaperlessDocumentRepository>();
|
||||
|
||||
Reference in new issue
Block a user