Skip to content
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

Adds experimental.OpenAIModel #2637

Merged
merged 2 commits into from
May 17, 2023
Merged

Conversation

sadasant
Copy link
Contributor

@sadasant sadasant commented Apr 15, 2023

Description

Adds a gitlens.experimental.OpenAIModel setting to specify the OpenAI model to use to generate commit messages when using the GitLens: Generate Commit Message command.

Fixes #2636

Checklist

  • I have followed the guidelines in the Contributing document
  • My changes follow the coding style of this project
  • My changes build without any errors or warnings
  • My changes have been formatted and linted
  • My changes include any required corresponding changes to the documentation (including CHANGELOG.md and README.md)
  • My changes have been rebased and squashed to the minimal number (typically 1) of relevant commits
  • My changes have a descriptive commit message with a short title, including a Fixes $XXX - or Closes #XXX - prefix to auto-close the issue that your PR addresses

@sadasant sadasant force-pushed the sadasant/openai-model branch from 5b66a96 to e7fb3e4 Compare April 15, 2023 00:37
@sadasant sadasant changed the title wip Adds experimental.OpenAIModel Apr 15, 2023
@sadasant sadasant force-pushed the sadasant/openai-model branch 2 times, most recently from 683e92c to 8bb61b5 Compare April 17, 2023 17:29
@sadasant
Copy link
Contributor Author

This builds, linting passes, I was able to debug it and to see the model reflect in the debugger after specifying it in the configs (I tested with gpt-4). I also tested auto-completion.

Untitled.mov

@sadasant sadasant marked this pull request as ready for review April 17, 2023 17:34

constructor(private readonly container: Container) {}

dispose() {}

async generateCommitMessage(diff: string, options?: { context?: string }): Promise<string | undefined> {
this.model = configuration.get('experimental.openAIModel') || 'gpt-3.5-turbo';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could pull this code into its own method (something like ensureModel) which is (force = false): void.

Suggested change
this.model = configuration.get('experimental.openAIModel') || 'gpt-3.5-turbo';
this.ensureModel();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To take that a step further, you could hook up a listener for config changes in the constructor. Something like:

constructor(private readonly container: Container) {
  this._disposable = [
    configuration.onDidChange(this.onConfigurationChanged, this),
  ];
}

private onConfigurationChanged(e?: ConfigurationChangeEvent) {
  if (!configuration.changed(e, 'experimental.openAIModel')) return;
  this.ensureModel(true);
 }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, @d13 ! I focused on something else. I should have followed up sooner.

sadasant and others added 2 commits May 16, 2023 23:07
 - Moves AI settings into a new AI section
 - Renames new setting into a `gitlens.ai` namespace and changes it to be an enum for easier selection
 - Updates max characters to be dependent on selected model
@eamodio eamodio force-pushed the sadasant/openai-model branch from 8bb61b5 to 3b83b25 Compare May 17, 2023 03:11
@eamodio eamodio merged commit 1e976d2 into gitkraken:main May 17, 2023
@eamodio
Copy link
Member

eamodio commented May 17, 2023

Thank you so much for your contribution!

Thank you!

@sadasant sadasant deleted the sadasant/openai-model branch May 30, 2023 18:58
@sadasant
Copy link
Contributor Author

Thank you all! I'll try to come back to this repo more often 🙇‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow specifying the OpenAI model to use to generate commit messages
3 participants