Skip to content

Commit

Permalink
finished alpha version,
Browse files Browse the repository at this point in the history
  • Loading branch information
itishermann committed Jun 25, 2024
1 parent 8503fff commit 231220d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class GenerateCommitAction: AnAction(), DumbAware {
if (commitPanel == null || processing) {
return
}
ProgressManager.getInstance().run(object : Task.Backgroundable(event.project, "Generating commit", false) {
ProgressManager.getInstance().run(object : Task.Backgroundable(event.project, "Ollama commit summarizer", false) {
override fun run(@NotNull indicator: ProgressIndicator) {
indicator.text = "Generating commit message"
processing = true
Expand All @@ -48,6 +48,7 @@ class GenerateCommitAction: AnAction(), DumbAware {
}

private fun handleEvent(e: AnActionEvent, commitPanel: CommitMessageI, indicator: ProgressIndicator) {
indicator.text = "Building prompt"
val project = checkNotNull(e.project)
// get included changes
val abstractCommitWorkflowHandler =
Expand All @@ -70,16 +71,20 @@ class GenerateCommitAction: AnAction(), DumbAware {
}

private fun generateCommitMessage(prompt: String, commitPanel: CommitMessageI, indicator: ProgressIndicator) {
indicator.text = "Preparing inference"
val client = service<OllamaService>().getOllamaClient()
val modelName = OllamaSettingsState.instance.state.modelName
val streamHandler = OllamaStreamHandler { s: String? ->
ApplicationManager.getApplication().invokeLater {
indicator.text = "Streaming response"
indicator.fraction += 0.05
commitPanel.setCommitMessage(s)
}
}
indicator.text = "Setting temperature and top-k"
val options = OptionsBuilder().setTemperature(1.5f).setTopP(0.9f).setTopK(40).build()
try {
indicator.text = "Inferring"
client.generate(modelName, prompt, options, streamHandler)
processing = false
Notifications.Bus.notify(
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<action id="Commit.Button" class="me.itishermann.ollamacommitsummarizer.actions.GenerateCommitAction"
text="Generate Commit"
description="Generate commit message"
icon="com.intellij.icons.ExpUiIcons.General.Refresh">
icon="com.intellij.icons.AllIcons.Actions.EditScheme">
<add-to-group group-id="Vcs.MessageActionGroup" anchor="last"/>
</action>
</actions>
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/META-INF/pluginIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 231220d

Please sign in to comment.