using CodeBase.Services; using CodeBase.Warehouse; using Qdrant.Client; using Qdrant.Client.Grpc; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddSingleton(new QdrantClient("localhost", 6334)); builder.Services.AddSingleton(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddScoped(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddControllers(); builder.Services.AddSwaggerGen(); var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); using (var scope = app.Services.CreateScope()) { var qdrantClient = scope.ServiceProvider.GetRequiredService(); // Получаем список существующих коллекций var collections = await qdrantClient.ListCollectionsAsync(); if (!collections.Contains("CodeBaseCollection")) { Console.WriteLine("Создаем новую коллекцию в Qdrant..."); await qdrantClient.CreateCollectionAsync( collectionName: "CodeBaseCollection", vectorsConfig: new VectorParams { Size = 768, // Размер вектора GraphCodeBERT Distance = Distance.Cosine // Сразу задаем алгоритм поиска (косинусное сходство) } ); } } app.Run();