feat: Add Ai Profiles

This commit is contained in:
2026-09-26 20:26:39 +03:30
parent 4e8b14906f
commit 34f820b3ca
19 changed files with 3548 additions and 144 deletions

View File

@@ -20,6 +20,7 @@ public sealed class GreenHomeDbContext : DbContext
public DbSet<Domain.AlertNotification> AlertNotifications => Set<Domain.AlertNotification>();
public DbSet<Domain.AlertLog> AlertLogs => Set<Domain.AlertLog>();
public DbSet<Domain.AIQuery> AIQueries => Set<Domain.AIQuery>();
public DbSet<Domain.AIProfile> AIProfiles => Set<Domain.AIProfile>();
public DbSet<Domain.DailyReport> DailyReports => Set<Domain.DailyReport>();
public DbSet<Domain.UserDailyReport> UserDailyReports => Set<Domain.UserDailyReport>();
public DbSet<Domain.ReportImage> ReportImages => Set<Domain.ReportImage>();
@@ -236,6 +237,7 @@ public sealed class GreenHomeDbContext : DbContext
b.Property(x => x.Question).IsRequired();
b.Property(x => x.Answer).IsRequired();
b.Property(x => x.Model).HasMaxLength(100);
b.Property(x => x.CostUsd).HasColumnType("decimal(18,8)");
b.HasOne(x => x.Device)
.WithMany()
.HasForeignKey(x => x.DeviceId)
@@ -244,11 +246,32 @@ public sealed class GreenHomeDbContext : DbContext
.WithMany()
.HasForeignKey(x => x.UserId)
.OnDelete(DeleteBehavior.SetNull);
b.HasOne(x => x.Profile)
.WithMany()
.HasForeignKey(x => x.ProfileId)
.OnDelete(DeleteBehavior.SetNull);
b.HasIndex(x => x.DeviceId);
b.HasIndex(x => x.UserId);
b.HasIndex(x => x.ProfileId);
b.HasIndex(x => x.CreatedAt);
});
modelBuilder.Entity<Domain.AIProfile>(b =>
{
b.ToTable("AIProfiles");
b.HasKey(x => x.Id);
b.Property(x => x.Name).IsRequired().HasMaxLength(100);
b.Property(x => x.Provider).IsRequired().HasConversion<int>();
b.Property(x => x.BaseUrl).IsRequired().HasMaxLength(300);
b.Property(x => x.ApiKey).IsRequired().HasMaxLength(500);
b.Property(x => x.Model).IsRequired().HasMaxLength(100);
b.Property(x => x.PromptPricePer1M).HasColumnType("decimal(18,6)");
b.Property(x => x.CompletionPricePer1M).HasColumnType("decimal(18,6)");
b.Property(x => x.BalanceUsd).HasColumnType("decimal(18,6)");
b.Property(x => x.BalanceCurrency).HasMaxLength(10);
b.HasIndex(x => x.IsActive);
});
modelBuilder.Entity<Domain.DailyReport>(b =>
{
b.ToTable("DailyReports");