Implement LLM provider configuration and update user settings
- Added functionality to update the default LLM provider for users via a new endpoint in UserController. - Introduced LlmProvider enum to manage available LLM options: Auto, Gemini, OpenAI, and Claude. - Updated User and UserEntity models to include DefaultLlmProvider property. - Enhanced database context and migrations to support the new LLM provider configuration. - Integrated LLM services into the application bootstrap for dependency injection. - Updated TypeScript API client to include methods for managing LLM providers and chat requests.
This commit is contained in:
@@ -34,6 +34,9 @@ public class UserEntity
|
||||
[Column(TypeName = "decimal(5,4)")] public decimal? SignalAgreementThreshold { get; set; } = 0.5m; // Default: 50% agreement required
|
||||
public bool? AllowSignalTrendOverride { get; set; } = true; // Default: Allow signal strategies to override trends
|
||||
public TradingExchanges? DefaultExchange { get; set; } = TradingExchanges.GmxV2; // Default exchange
|
||||
|
||||
// User Settings - LLM Configuration
|
||||
public LlmProvider? DefaultLlmProvider { get; set; } = LlmProvider.Auto; // Default LLM provider
|
||||
|
||||
// Navigation properties
|
||||
public virtual ICollection<AccountEntity> Accounts { get; set; } = new List<AccountEntity>();
|
||||
|
||||
@@ -105,6 +105,9 @@ public class ManagingDbContext : DbContext
|
||||
.HasConversion<string>(); // Store enum as string
|
||||
entity.Property(e => e.DefaultExchange)
|
||||
.HasConversion<string>(); // Store enum as string
|
||||
entity.Property(e => e.DefaultLlmProvider)
|
||||
.HasConversion<string>() // Store enum as string
|
||||
.HasDefaultValueSql("'Auto'"); // Default LLM provider
|
||||
|
||||
// Create indexes for performance
|
||||
entity.HasIndex(e => e.Name).IsUnique();
|
||||
|
||||
@@ -146,6 +146,7 @@ public static class PostgreSqlMappers
|
||||
SignalAgreementThreshold = entity.SignalAgreementThreshold,
|
||||
AllowSignalTrendOverride = entity.AllowSignalTrendOverride,
|
||||
DefaultExchange = entity.DefaultExchange,
|
||||
DefaultLlmProvider = entity.DefaultLlmProvider,
|
||||
Accounts = entity.Accounts?.Select(MapAccountWithoutUser).ToList() ?? new List<Account>()
|
||||
};
|
||||
}
|
||||
@@ -193,7 +194,8 @@ public static class PostgreSqlMappers
|
||||
TrendStrongAgreementThreshold = user.TrendStrongAgreementThreshold,
|
||||
SignalAgreementThreshold = user.SignalAgreementThreshold,
|
||||
AllowSignalTrendOverride = user.AllowSignalTrendOverride,
|
||||
DefaultExchange = user.DefaultExchange
|
||||
DefaultExchange = user.DefaultExchange,
|
||||
DefaultLlmProvider = user.DefaultLlmProvider
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -269,6 +269,7 @@ public class PostgreSqlUserRepository : BaseRepositoryWithLogging, IUserReposito
|
||||
existingUser.SignalAgreementThreshold = user.SignalAgreementThreshold;
|
||||
existingUser.AllowSignalTrendOverride = user.AllowSignalTrendOverride;
|
||||
existingUser.DefaultExchange = user.DefaultExchange;
|
||||
existingUser.DefaultLlmProvider = user.DefaultLlmProvider;
|
||||
|
||||
_context.Users.Update(existingUser);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user