feat: Add Ai Profiles
This commit is contained in:
100
src/GreenHome.Application/Dtos/AI/AIProfileDtos.cs
Normal file
100
src/GreenHome.Application/Dtos/AI/AIProfileDtos.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using GreenHome.Domain;
|
||||
|
||||
namespace GreenHome.Application;
|
||||
|
||||
// ==================== AI Profile ====================
|
||||
|
||||
/// <summary>
|
||||
/// An AI profile as shown in the admin list, with aggregated usage.
|
||||
/// </summary>
|
||||
public sealed class AIProfileDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public AIProvider Provider { get; set; }
|
||||
public string BaseUrl { get; set; } = string.Empty;
|
||||
public string Model { get; set; } = string.Empty;
|
||||
public bool IsActive { get; set; }
|
||||
public double? Temperature { get; set; }
|
||||
public decimal? PromptPricePer1M { get; set; }
|
||||
public decimal? CompletionPricePer1M { get; set; }
|
||||
|
||||
// Last known balance (may be null if the provider has no balance endpoint)
|
||||
public decimal? BalanceUsd { get; set; }
|
||||
public string? BalanceCurrency { get; set; }
|
||||
public DateTime? BalanceUpdatedAt { get; set; }
|
||||
|
||||
// Aggregated usage for this profile (from the AIQueries log)
|
||||
public int QueryCount { get; set; }
|
||||
public int TotalPromptTokens { get; set; }
|
||||
public int TotalCompletionTokens { get; set; }
|
||||
public int TotalTokens { get; set; }
|
||||
public decimal TotalCostUsd { get; set; }
|
||||
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
}
|
||||
|
||||
public sealed class AIProfileCreateRequest
|
||||
{
|
||||
public required string Name { get; set; }
|
||||
public AIProvider Provider { get; set; }
|
||||
public string? BaseUrl { get; set; }
|
||||
public required string ApiKey { get; set; }
|
||||
public required string Model { get; set; }
|
||||
public double? Temperature { get; set; }
|
||||
public int? MaxTokens { get; set; }
|
||||
public decimal? PromptPricePer1M { get; set; }
|
||||
public decimal? CompletionPricePer1M { get; set; }
|
||||
}
|
||||
|
||||
public sealed class AIProfileUpdateRequest
|
||||
{
|
||||
public required string Name { get; set; }
|
||||
public AIProvider Provider { get; set; }
|
||||
public string? BaseUrl { get; set; }
|
||||
public required string ApiKey { get; set; }
|
||||
public required string Model { get; set; }
|
||||
public double? Temperature { get; set; }
|
||||
public int? MaxTokens { get; set; }
|
||||
public decimal? PromptPricePer1M { get; set; }
|
||||
public decimal? CompletionPricePer1M { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Best-effort account balance for a provider (null = unavailable).
|
||||
/// </summary>
|
||||
public sealed class AIBalance
|
||||
{
|
||||
public decimal Amount { get; set; }
|
||||
public string? Currency { get; set; }
|
||||
}
|
||||
|
||||
// ==================== AI Profile Usage ====================
|
||||
|
||||
/// <summary>
|
||||
/// Aggregated usage for a single profile.
|
||||
/// </summary>
|
||||
public sealed class AIProfileUsageDto
|
||||
{
|
||||
public int QueryCount { get; set; }
|
||||
public int TotalPromptTokens { get; set; }
|
||||
public int TotalCompletionTokens { get; set; }
|
||||
public int TotalTokens { get; set; }
|
||||
public decimal TotalCostUsd { get; set; }
|
||||
public decimal? BalanceUsd { get; set; }
|
||||
public string? BalanceCurrency { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// One day of AI usage for a profile (for charting).
|
||||
/// </summary>
|
||||
public sealed class AIProfileUsageDayDto
|
||||
{
|
||||
public DateOnly Date { get; set; }
|
||||
public int QueryCount { get; set; }
|
||||
public int PromptTokens { get; set; }
|
||||
public int CompletionTokens { get; set; }
|
||||
public int TotalTokens { get; set; }
|
||||
public decimal CostUsd { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user