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

Add OpenRouter client configuration and panel for AI commit generation #267

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chernistry
Copy link

@chernistry chernistry commented Oct 13, 2024

This PR introduces OpenRouter integration, enabling users to generate commit messages with various free AI models.

Key Changes:

  • Added OpenRouterClientConfiguration, Panel, Service, and SharedState.
  • Updated LLMClientTable and AppSettings2 to support OpenRouter.
  • Integrated free nousresearch/hermes-3-llama-3.1-405b:free

Models can be accessed here: OpenRouter Models.

Testing:

  • Verified OpenRouter settings configuration.
  • Tested API connection and commit message generation using one of the free models (hermes-3-llama-3.1-405b:free).

Copy link
Owner

@Blarc Blarc left a comment

Choose a reason for hiding this comment

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

Hey @chernistry,

thanks a lot for opening this PR. If I see correctly, you've re-used the OpenAI client. Since everything is the same, I'm wondering why couldn't you just use the existing OpenAI client to generate commits with OpenRouter? The host and modelId fields are editable, meaning you can add you own host and modelIds.



settings.openRouter.token.example=sk-or-v1-...
settings.openRouter.token.comment=Your OpenRouter API key. You can find it in your OpenRouter account settings.
Copy link
Owner

Choose a reason for hiding this comment

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

Could you maybe add a link (with ) to the account settings? Check how it's done for the others.

],
style = XCollection.Style.v2
)
var llmClientConfigurations = setOf<LLMClientConfiguration>(
OpenAiClientConfiguration()
OpenAiClientConfiguration(),
OpenRouterClientConfiguration()
Copy link
Owner

Choose a reason for hiding this comment

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

This is not necessary. Users can create new configurations via the add button. OpenAiClientConfiguration is added just as an example.

@@ -2,6 +2,9 @@ package com.github.blarc.ai.commits.intellij.plugin.settings.clients

import com.github.blarc.ai.commits.intellij.plugin.AICommitsBundle.message
import com.github.blarc.ai.commits.intellij.plugin.createColumn
import com.github.blarc.ai.commits.intellij.plugin.settings.clients.openrouter.OpenRouterClientConfiguration
Copy link
Owner

Choose a reason for hiding this comment

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

Don't want to be nit-picky, but are these empty lines should be removed.


override fun getClientName(): String = CLIENT_NAME

override fun getClientIcon(): Icon = Icons.OPEN_AI // You may want to create a custom icon for OpenRouter
Copy link
Owner

Choose a reason for hiding this comment

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

As the comment says, please add the icon for OpenRouter. You can add it to main/resources/icons. Preferably svg and 15px x 15px size. Icon should be added to Icons object and then referenced here. I usually just download it from llm's website an resize it online.

@chernistry
Copy link
Author

Hey @Blarc,

Spot on, mate. Just wanted to get OpenRouter sorted, so I thought a quick tweak might do the trick. Truth be told, I'm barely scraping the surface of Kotlin — for the second time in life today literally for the sake of OpenRouter in this plugin —so you're probably right about those glitches. Time's a bit tight, and honestly, I thought sharing what worked might lend a hand to someone else.
Won’t likely get to those fixes anytime soon, but if it's of any use to someone or they fancy building on it, I'm all for sharing. Also, no worries if we decide to bin this PR.

Cheers! - Sasha

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.

2 participants