feature: simple implementation for generating commit message by OpenAI (#456)

This commit is contained in:
leo 2024-09-11 18:22:05 +08:00
parent a63450f73f
commit 16f8e2fd0b
No known key found for this signature in database
16 changed files with 496 additions and 30 deletions

View file

@ -88,5 +88,23 @@ namespace SourceGit.Views
e.Handled = true;
}
}
private void OnOpenAIAssist(object _, RoutedEventArgs e)
{
if (!Models.OpenAI.IsValid)
{
App.RaiseException(null, $"Bad configuration for OpenAI");
return;
}
if (DataContext is ViewModels.WorkingCopy vm && vm.Staged is { Count: > 0 })
{
var dialog = new AIAssistant() { DataContext = vm };
dialog.GenerateCommitMessage();
App.OpenDialog(dialog);
}
e.Handled = true;
}
}
}