99 lines
3.9 KiB
Plaintext
99 lines
3.9 KiB
Plaintext
using ChatApi;
|
|
using ChatApi.Services;
|
|
using ChatApi.Services.Bot;
|
|
using ChatApi.Services.Bot.Structs;
|
|
using ChatApi.Services.Classifier;
|
|
using ChatApi.Services.ResponseService;
|
|
using Microsoft.SemanticKernel;
|
|
using Microsoft.SemanticKernel.ChatCompletion;
|
|
using OllamaSharp;
|
|
|
|
#pragma warning disable SKEXP0010 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
|
|
builder.Services.AddControllers();
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSwaggerGen();
|
|
|
|
builder.Services.Configure<DomvsDatabaseSettings>(
|
|
builder.Configuration.GetSection("DomvsDatabase"));
|
|
|
|
builder.Services.AddScoped<ClassifierPersistence>();
|
|
builder.Services.AddSingleton<ChatHistoryService>();
|
|
builder.Services.AddScoped<SharepointDomvsService>();
|
|
builder.Services.AddSingleton<TextFilter>();
|
|
builder.Services.AddScoped<ResponseFactory>();
|
|
|
|
builder.Services.AddScoped<ChatBotRHCall>();
|
|
builder.Services.AddScoped<IResponseService, ResponseChatService>();
|
|
builder.Services.AddScoped<IResponseService, ResponseCompanyService>();
|
|
builder.Services.AddScoped<IResponseService, ResponseBotRHService>();
|
|
|
|
|
|
//builder.Services.AddOllamaChatCompletion("phi3.5", new Uri("http://localhost:11435"));
|
|
//builder.Services.AddOllamaChatCompletion("tinydolphin", new Uri("http://localhost:11435"));
|
|
//var apiClient = new OllamaApiClient(new Uri("http://localhost:11435"), "tinydolphin");
|
|
//builder.Services.AddOllamaChatCompletion("phi3.5", new Uri("http://localhost:11435"));
|
|
//builder.Services.AddOllamaChatCompletion("tinydolphin", new Uri("http://localhost:11435"));
|
|
//builder.Services.AddOllamaChatCompletion("tinyllama", new Uri("http://localhost:11435"));
|
|
//builder.Services.AddOllamaChatCompletion("starling-lm", new Uri("http://localhost:11435"));
|
|
|
|
//ServerSpace - GPT Service
|
|
builder.Services.AddOpenAIChatCompletion("openchat-3.5-0106", new Uri("https://gpt.serverspace.com.br/v1/chat/completions"), "tIAXVf3AkCkkpSX+PjFvktfEeSPyA1ZYam50UO3ye/qmxVZX6PIXstmJsLZXkQ39C33onFD/81mdxvhbGHm7tQ==");
|
|
|
|
builder.Services.AddOllamaTextEmbeddingGeneration("all-minilm", new Uri("http://localhost:11435"));
|
|
//builder.Services.AddOllamaChatCompletion("phi3.5", new Uri("http://localhost:11435"));
|
|
//builder.Services.AddOpenAIChatCompletion("gpt-4o-mini", "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");
|
|
//builder.Services.AddGoogleAIGeminiChatCompletion("gemini-1.5-flash-latest", "AIzaSyDKBMX5yW77vxJFVJVE-5VLxlQRxCepck8");
|
|
|
|
//Anthropic / Claude
|
|
//builder.Services.AddAnthropicChatCompletion(
|
|
// modelId: "claude-3-5-sonnet-latest", // ou outro modelo Claude desejado
|
|
// apiKey: "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"
|
|
//);
|
|
|
|
builder.Services.AddKernel();
|
|
//builder.Services.AddKernel()
|
|
// .AddOllamaChatCompletion("phi3", new Uri("http://localhost:11435"))
|
|
// .AddOllamaTextEmbeddingGeneration()
|
|
// .Build();
|
|
|
|
//builder.Services.AddOllamaChatCompletion("phi3.5", new Uri("http://192.168.0.150:11436"));
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllers();
|
|
|
|
app.Use(async (context, next) =>
|
|
{
|
|
var cookieOpt = new CookieOptions()
|
|
{
|
|
Path = "/",
|
|
Expires = DateTimeOffset.UtcNow.AddDays(1),
|
|
IsEssential = true,
|
|
HttpOnly = false,
|
|
Secure = false,
|
|
};
|
|
|
|
await next();
|
|
});
|
|
|
|
app.Run();
|
|
|
|
#pragma warning restore SKEXP0010 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
|