-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add generating item history using AI #72
Conversation
This is based on the Łukasz's prompts implemented in March Co-Authored-By: Ornez <[email protected]> Co-Authored-By: Łukasz Chudy <[email protected]>
Generating of item history using AI is now behind a feature flag which must be set in
|
DO NOT MERGE YET! Still - if there is no secrets configuration, the AIProvider cannot be constructed and throws. How should we proceed? We should not use FeatureManagement in a constructor (as it is async), and we cannot register services based on features? I am not sure. |
you actually can use featuremanagement outside a service scope: https://stackoverflow.com/questions/61659144/how-to-get-featuremanager-in-configureservices we'd just have to manually create the feature manager class and pass to it our config file |
Ok, so I created a |
Additionally, codestral suggested me something which may be even better: public static class FeatureFlagServiceExtension
{
public static IServiceCollection AddTransientIfFeatureEnabled<TInterface, TImplementation>(this IServiceCollection services, string featureName) where TImplementation : class, TInterface
=> services.AddTransientIfFeatureEnabled(featureName, typeof(TInterface), typeof(TImplementation));
public static IServiceCollection AddTransientIfFeatureEnabled(this IServiceCollection services, string featureName, Type serviceType, Type implementationType)
{
var featureManager = services.BuildServiceProvider().GetRequiredService<IFeatureManagerSnapshot>();
if (featureManager[featureName].Value)
return services.AddTransient(serviceType, implementationType);
return services;
}
// Add similar methods for AddScoped and AddSingleton if needed...
} So it should be used something like: services.AddSingletonIfFeatureEnabled<IMyService, MyService>("MyFeatureFlag"); Not sure if it is more readable than current version. |
i actually like this one better! |
No description provided.